mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
Extract helper methods
for better readability
This commit is contained in:
parent
2c92d74a03
commit
a63f0d67bd
1 changed files with 54 additions and 59 deletions
|
|
@ -80,31 +80,7 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
_buildWarningTile(context),
|
||||||
title: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.warning_amber_outlined,
|
|
||||||
color: context.secondaryColor,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
l10n.calendar_info,
|
|
||||||
softWrap: true,
|
|
||||||
overflow: TextOverflow.clip,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: context.secondaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
@ -142,40 +118,7 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCalendar(
|
_buildCalendar(data, locale),
|
||||||
firstDay: firstDay,
|
|
||||||
lastDay: lastDay,
|
|
||||||
focusedDay: _focusedDay,
|
|
||||||
locale: locale.toLanguageTag(),
|
|
||||||
selectedDayPredicate: (day) =>
|
|
||||||
isSameDay(_selectedDay, day),
|
|
||||||
rangeStartDay: _rangeStart,
|
|
||||||
rangeEndDay: _rangeEnd,
|
|
||||||
calendarFormat: _calendarFormat,
|
|
||||||
rangeSelectionMode: _rangeSelectionMode,
|
|
||||||
eventLoader: (day) => _getEntriesForDay(day, data),
|
|
||||||
startingDayOfWeek: StartingDayOfWeek.monday,
|
|
||||||
calendarStyle: CalendarStyle(
|
|
||||||
outsideDaysVisible: true,
|
|
||||||
weekendTextStyle: TextStyle(
|
|
||||||
color: context.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onDaySelected: (selectedDay, focusedDay) =>
|
|
||||||
_onDaySelected(selectedDay, focusedDay, data),
|
|
||||||
onRangeSelected: (start, end, focusedDay) =>
|
|
||||||
_onRangeSelected(start, end, focusedDay, data),
|
|
||||||
onFormatChanged: (format) {
|
|
||||||
if (_calendarFormat != format) {
|
|
||||||
setState(() {
|
|
||||||
_calendarFormat = format;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPageChanged: (focusedDay) {
|
|
||||||
_focusedDay = focusedDay;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -238,6 +181,58 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildWarningTile(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
title: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.warning_amber_outlined, color: context.secondaryColor),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
context.l10n.calendar_info,
|
||||||
|
softWrap: true,
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
|
style: TextStyle(fontSize: 13, color: context.secondaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCalendar(List<Manga> data, Locale locale) {
|
||||||
|
return TableCalendar(
|
||||||
|
firstDay: firstDay,
|
||||||
|
lastDay: lastDay,
|
||||||
|
focusedDay: _focusedDay,
|
||||||
|
locale: locale.toLanguageTag(),
|
||||||
|
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
|
||||||
|
rangeStartDay: _rangeStart,
|
||||||
|
rangeEndDay: _rangeEnd,
|
||||||
|
calendarFormat: _calendarFormat,
|
||||||
|
rangeSelectionMode: _rangeSelectionMode,
|
||||||
|
eventLoader: (day) => _getEntriesForDay(day, data),
|
||||||
|
startingDayOfWeek: StartingDayOfWeek.monday,
|
||||||
|
calendarStyle: CalendarStyle(
|
||||||
|
outsideDaysVisible: true,
|
||||||
|
weekendTextStyle: TextStyle(color: context.primaryColor),
|
||||||
|
),
|
||||||
|
onDaySelected: (selectedDay, focusedDay) =>
|
||||||
|
_onDaySelected(selectedDay, focusedDay, data),
|
||||||
|
onRangeSelected: (start, end, focusedDay) =>
|
||||||
|
_onRangeSelected(start, end, focusedDay, data),
|
||||||
|
onFormatChanged: (format) {
|
||||||
|
if (_calendarFormat != format) {
|
||||||
|
setState(() => _calendarFormat = format);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPageChanged: (focusedDay) => _focusedDay = focusedDay,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
||||||
return data.where((e) {
|
return data.where((e) {
|
||||||
final lastChapter = e.chapters
|
final lastChapter = e.chapters
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue