fixed some of the widget bugs and removed assets

This commit is contained in:
Kima 2023-08-25 23:20:44 +02:00
parent bad9ed000b
commit 360426d851
18 changed files with 1142 additions and 1084 deletions

View File

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools" package="hu.refilc.naplo"> xmlns:tools="http://schemas.android.com/tools" package="hu.refilc.naplo">
<application android:name="${applicationName}" android:label="reFilc" tools:replace="android:label" android:icon="@mipmap/ic_launcher" <application android:name="${applicationName}" android:label="reFilc" tools:replace="android:label" android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true"> android:requestLegacyExternalStorage="true">
<activity android:exported="true" android:name=".MainActivity" <activity android:exported="true" android:name="hu.refilc.naplo.MainActivity"
android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:launchMode="singleTop" android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"
@ -20,16 +20,26 @@
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with https://api.filcnaplo.hu --> <!-- Accepts URIs that begin with https://api.refilcapp.hu -->
<data <data
android:scheme="https" android:scheme="https"
android:host="api.filcnaplo.hu" android:host="api.refilcapp.hu"
android:pathPrefix="/callback" /> android:pathPrefix="/v1/auth/callback" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with https://refilc.hu -->
<data
android:scheme="https"
android:host="refilc.hu"
android:pathPrefix="/app" />
</intent-filter> </intent-filter>
</activity> </activity>
<meta-data android:name="flutterEmbedding" android:value="2" /> <meta-data android:name="flutterEmbedding" android:value="2" />
<receiver android:name=".widget_timetable.WidgetTimetable" <receiver android:name="hu.refilc.naplo.widget_timetable.WidgetTimetable"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@ -45,7 +55,7 @@
android:resource="@xml/home_widget_test_info" /> android:resource="@xml/home_widget_test_info" />
</receiver> </receiver>
<service android:name=".widget_timetable.WidgetTimetableService" <service android:name="hu.refilc.naplo.widget_timetable.WidgetTimetableService"
android:permission="android.permission.BIND_REMOTEVIEWS" /> android:permission="android.permission.BIND_REMOTEVIEWS" />
<receiver android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver" <receiver android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver"

View File

@ -1 +0,0 @@
../../../../../../../../../filcnaplo_premium/android/database

View File

@ -1 +0,0 @@
../../../../../../../../../filcnaplo_premium/android/utils

View File

@ -1 +0,0 @@
../../../../../../../../../filcnaplo_premium/android/widget_timetable

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:id="@+id/main_lay" android:id="@+id/main_lay"
android:layout_height="50dp" android:layout_height="50dp"
@ -15,12 +16,14 @@
android:id="@+id/tt_item_num" android:id="@+id/tt_item_num"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fontFamily="@font/montserrat_medium"
android:gravity="center"
android:text="1."
android:textColor="@color/filc"
android:textColorLink="#ff3D7BF4"
android:textSize="30sp" android:textSize="30sp"
android:textStyle="bold" android:textStyle="bold"
android:fontFamily="@font/montserrat_medium" tools:ignore="HardcodedText" />
android:text="1."
android:gravity="center"
android:textColor="@color/filc"></TextView>
<TextView <TextView
android:id="@+id/tt_item_name" android:id="@+id/tt_item_name"
@ -33,10 +36,11 @@
android:text="Óra neve" android:text="Óra neve"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:layout_toLeftOf="@id/tt_item_room" android:layout_toStartOf="@id/tt_item_room"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_toRightOf="@id/tt_item_num" android:layout_toEndOf="@id/tt_item_num"
android:textColor="@color/text"></TextView> android:textColor="@color/text"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/tt_item_name_nodesc" android:id="@+id/tt_item_name_nodesc"
@ -47,13 +51,14 @@
android:fontFamily="@font/montserrat_medium" android:fontFamily="@font/montserrat_medium"
android:visibility="gone" android:visibility="gone"
android:layout_marginTop="2.5dp" android:layout_marginTop="2.5dp"
android:layout_toLeftOf="@id/tt_item_room" android:layout_toStartOf="@id/tt_item_room"
android:text="Óra neve" android:text="Óra neve"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_toRightOf="@id/tt_item_num" android:layout_toEndOf="@id/tt_item_num"
android:textColor="@color/text"></TextView> android:textColor="@color/text"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/tt_item_desc" android:id="@+id/tt_item_desc"
@ -67,10 +72,11 @@
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_toRightOf="@id/tt_item_num" android:layout_toEndOf="@id/tt_item_num"
android:layout_toLeftOf="@id/tt_item_room" android:layout_toStartOf="@id/tt_item_room"
android:layout_below="@id/tt_item_name" android:layout_below="@id/tt_item_name"
android:textColor="@color/text_desc"></TextView> android:textColor="@color/text_desc"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/tt_item_room" android:id="@+id/tt_item_room"
@ -84,8 +90,9 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:gravity="center" android:gravity="center"
android:layout_toLeftOf="@id/tt_item_time" android:layout_toStartOf="@id/tt_item_time"
android:textColor="@color/text_desc"></TextView> android:textColor="@color/text_desc"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/tt_item_time" android:id="@+id/tt_item_time"
@ -95,11 +102,12 @@
android:textFontWeight="500" android:textFontWeight="500"
android:fontFamily="@font/montserrat_medium" android:fontFamily="@font/montserrat_medium"
android:textStyle="bold" android:textStyle="bold"
android:layout_marginLeft="2dp" android:layout_marginStart="2dp"
android:layout_marginTop="-2dp" android:layout_marginTop="-2dp"
android:text="8:30\n9:10" android:text="8:30\n9:10"
android:gravity="center" android:gravity="center"
android:layout_alignParentRight="true" android:layout_alignParentEnd="true"
android:textColor="@color/white"></TextView> android:textColor="@color/white"
tools:ignore="HardcodedText" />
</RelativeLayout> </RelativeLayout>

View File

@ -19,10 +19,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:text="Empty" android:text="Üres / Empty"
android:background="@drawable/widget_card_bottom_dark"
android:textColor="@color/text" android:textColor="@color/text"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold"
tools:ignore="HardcodedText" />
<ListView <ListView
android:id="@+id/widget_list" android:id="@+id/widget_list"
@ -43,57 +45,63 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:background="@drawable/widget_card_top_dark"> android:background="@drawable/widget_card_top_dark">
<ImageView <ImageView
android:id="@+id/nav_refresh" android:id="@+id/nav_refresh"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_toStartOf="@id/nav_to_left"
android:clickable="true" android:clickable="true"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:padding="10dp"
android:src="@drawable/ic_refresh_cw" android:src="@drawable/ic_refresh_cw"
android:layout_toLeftOf="@id/nav_to_left"
android:tint="@color/text_desc" android:tint="@color/text_desc"
tools:ignore="UseAppTint" tools:ignore="UseAppTint"
android:padding="10dp" /> android:focusable="true" />
<ImageView <ImageView
android:id="@+id/nav_to_left" android:id="@+id/nav_to_left"
android:layout_width="50dp" android:layout_width="45dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_toStartOf="@id/nav_to_right"
android:clickable="true" android:clickable="true"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:padding="10dp"
android:src="@drawable/ic_chevron_left" android:src="@drawable/ic_chevron_left"
android:layout_toLeftOf="@id/nav_to_right"
android:tint="@color/text_desc" android:tint="@color/text_desc"
tools:ignore="UseAppTint" tools:ignore="UseAppTint"
android:padding="10dp" /> android:focusable="true" />
<ImageView <ImageView
android:id="@+id/nav_to_right" android:id="@+id/nav_to_right"
android:layout_width="50dp" android:layout_width="45dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_marginEnd="5dp"
android:clickable="true" android:clickable="true"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:padding="10dp"
android:src="@drawable/ic_chevron_right" android:src="@drawable/ic_chevron_right"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:tint="@color/text_desc" android:tint="@color/text_desc"
tools:ignore="UseAppTint" tools:ignore="UseAppTint"
android:padding="10dp" /> android:focusable="true" />
<TextView <TextView
android:id="@+id/nav_current" android:id="@+id/nav_current"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentStart="true"
android:layout_marginLeft="20sp" android:layout_marginStart="15sp"
android:layout_toLeftOf="@id/nav_refresh" android:layout_marginTop="2sp"
android:layout_toStartOf="@id/nav_refresh"
android:fontFamily="@font/montserrat_medium" android:fontFamily="@font/montserrat_medium"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:text="Timetable" android:text="Órarend"
android:textColor="@color/text" android:textColor="@color/text"
android:textSize="24sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold"
tools:ignore="HardcodedText" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
@ -131,8 +139,9 @@
android:text="A widget használatához, bejelentkezés szükséges." android:text="A widget használatához, bejelentkezés szükséges."
android:textColor="@color/black" android:textColor="@color/black"
android:paddingTop="10dp" android:paddingTop="10dp"
android:textSize="17dp" android:textSize="17sp"
android:textStyle="bold" /> android:textStyle="bold"
tools:ignore="HardcodedText" />
<Button <Button
android:id="@+id/open_login" android:id="@+id/open_login"
@ -145,8 +154,9 @@
android:layout_margin="10dp" android:layout_margin="10dp"
android:textColor="@color/white" android:textColor="@color/white"
android:fontFamily="@font/montserrat_medium" android:fontFamily="@font/montserrat_medium"
android:textSize="16dp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold"
tools:ignore="HardcodedText" />
</RelativeLayout> </RelativeLayout>
@ -185,8 +195,9 @@
android:text="Órák a kezdőképernyőd kényelméből." android:text="Órák a kezdőképernyőd kényelméből."
android:textColor="@color/black" android:textColor="@color/black"
android:paddingTop="10dp" android:paddingTop="10dp"
android:textSize="16dp" android:textSize="16sp"
android:textStyle="bold" /> android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -197,7 +208,8 @@
android:textColor="@color/black" android:textColor="@color/black"
android:layout_marginTop="0dp" android:layout_marginTop="0dp"
android:layout_marginHorizontal="15dp" android:layout_marginHorizontal="15dp"
android:textSize="14dp" /> android:textSize="14sp"
tools:ignore="HardcodedText" />
<Button <Button
android:id="@+id/buy_premium" android:id="@+id/buy_premium"
@ -211,8 +223,9 @@
android:layout_margin="10dp" android:layout_margin="10dp"
android:textColor="#ff691A9B" android:textColor="#ff691A9B"
android:fontFamily="@font/montserrat_medium" android:fontFamily="@font/montserrat_medium"
android:textSize="16dp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold"
tools:ignore="HardcodedText" />
</RelativeLayout> </RelativeLayout>

View File

@ -27,7 +27,7 @@
<color name="yellow_light">#ffFFCC00</color> <color name="yellow_light">#ffFFCC00</color>
<color name="light_yellow_light">#40FFD60A</color> <color name="light_yellow_light">#40FFD60A</color>
<color name="green_light">#ff34C759</color> <color name="green_light">#ff34C759</color>
<color name="filc_light">#ff247665</color> <color name="filc_light">#ff3D7BF4</color>
<color name="teal_light">#ff5AC8FA</color> <color name="teal_light">#ff5AC8FA</color>
<color name="blue_light">#ff007AFF</color> <color name="blue_light">#ff007AFF</color>
<color name="indigo_light">#ff5856D6</color> <color name="indigo_light">#ff5856D6</color>
@ -49,7 +49,7 @@
<color name="yellow">#ffFFD60A</color> <color name="yellow">#ffFFD60A</color>
<color name="light_yellow">#40FFD60A</color> <color name="light_yellow">#40FFD60A</color>
<color name="green">#ff32D74B</color> <color name="green">#ff32D74B</color>
<color name="filc">#ff29826F</color> <color name="filc">#ff3D7BF4</color>
<color name="teal">#ff64D2FF</color> <color name="teal">#ff64D2FF</color>
<color name="blue">#ff0A84FF</color> <color name="blue">#ff0A84FF</color>
<color name="indigo">#ff5E5CE6</color> <color name="indigo">#ff5E5CE6</color>

View File

@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <dynamic_color/dynamic_color_plugin.h> #include <dynamic_color/dynamic_color_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <flutter_acrylic/flutter_acrylic_plugin.h> #include <flutter_acrylic/flutter_acrylic_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
@ -14,6 +15,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dynamic_color_registrar = g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar = g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar); flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color dynamic_color
file_selector_linux
flutter_acrylic flutter_acrylic
url_launcher_linux url_launcher_linux
) )

View File

@ -7,6 +7,7 @@ import Foundation
import connectivity_plus import connectivity_plus
import dynamic_color import dynamic_color
import file_selector_macos
import flutter_local_notifications import flutter_local_notifications
import macos_window_utils import macos_window_utils
import package_info_plus import package_info_plus
@ -18,6 +19,7 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))

View File

@ -24,7 +24,10 @@ class TimetableController extends ChangeNotifier {
current(); current();
} }
static int getWeekId(Week week) => (week.start.difference(getSchoolYearStart()).inDays / DateTime.daysPerWeek).ceil(); static int getWeekId(Week week) =>
(week.start.difference(getSchoolYearStart()).inDays /
DateTime.daysPerWeek)
.ceil();
static DateTime getSchoolYearStart() { static DateTime getSchoolYearStart() {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
@ -48,8 +51,10 @@ class TimetableController extends ChangeNotifier {
} }
// Jump shortcuts // Jump shortcuts
Future<void> next(BuildContext context) => jump(Week.fromId(currentWeekId + 1), context: context); Future<void> next(BuildContext context) =>
Future<void> previous(BuildContext context) => jump(Week.fromId(currentWeekId - 1), context: context); jump(Week.fromId(currentWeekId + 1), context: context);
Future<void> previous(BuildContext context) =>
jump(Week.fromId(currentWeekId - 1), context: context);
void current() { void current() {
Week week = Week.current(); Week week = Week.current();
int id = getWeekId(week); int id = getWeekId(week);
@ -60,7 +65,11 @@ class TimetableController extends ChangeNotifier {
_setWeek(Week.fromId(id)); _setWeek(Week.fromId(id));
} }
Future<void> jump(Week week, {required BuildContext context, bool initial = false, bool skip = false, bool loader = true}) async { Future<void> jump(Week week,
{required BuildContext context,
bool initial = false,
bool skip = false,
bool loader = true}) async {
if (_setWeek(week)) return; if (_setWeek(week)) return;
loadType = LoadType.initial; loadType = LoadType.initial;
@ -81,7 +90,9 @@ class TimetableController extends ChangeNotifier {
notifyListeners(); notifyListeners();
try { try {
await _fetchWeek(week, context: context).timeout(const Duration(seconds: 5), onTimeout: (() => throw "timeout")); await _fetchWeek(week, context: context).timeout(
const Duration(seconds: 5),
onTimeout: (() => throw "timeout"));
loadType = LoadType.online; loadType = LoadType.online;
} catch (error, stack) { } catch (error, stack) {
print("ERROR: TimetableController.jump: $error\n$stack"); print("ERROR: TimetableController.jump: $error\n$stack");
@ -95,7 +106,9 @@ class TimetableController extends ChangeNotifier {
if (week != currentWeek) return; if (week != currentWeek) return;
// Jump to next week on weekends // Jump to next week on weekends
if (skip && (days?.length ?? 0) > 0 && days!.last.last.end.isBefore(DateTime.now())) return next(context); if (skip &&
(days?.length ?? 0) > 0 &&
days!.last.last.end.isBefore(DateTime.now())) return next(context);
notifyListeners(); notifyListeners();
} }
@ -106,7 +119,8 @@ class TimetableController extends ChangeNotifier {
if (id < 0) return true; // Min 1. if (id < 0) return true; // Min 1.
// Set week start to Sept. 1 of first week // Set week start to Sept. 1 of first week
if (!_differentDate(week.start, Week.fromId(0).start)) week.start = TimetableController.getSchoolYearStart(); if (!_differentDate(week.start, Week.fromId(0).start))
week.start = TimetableController.getSchoolYearStart();
currentWeek = week; currentWeek = week;
previousWeekId = currentWeekId; previousWeekId = currentWeekId;
@ -124,16 +138,17 @@ class TimetableController extends ChangeNotifier {
List<List<Lesson>> _sortDays(Week week, {required BuildContext context}) { List<List<Lesson>> _sortDays(Week week, {required BuildContext context}) {
List<List<Lesson>> days = []; List<List<Lesson>> days = [];
try {
final timetableProvider = context.read<TimetableProvider>(); final timetableProvider = context.read<TimetableProvider>();
try {
List<Lesson> lessons = timetableProvider.getWeek(week) ?? []; List<Lesson> lessons = timetableProvider.getWeek(week) ?? [];
if (lessons.isNotEmpty) { if (lessons.isNotEmpty) {
days.add([]); days.add([]);
lessons.sort((a, b) => a.date.compareTo(b.date)); lessons.sort((a, b) => a.date.compareTo(b.date));
for (var lesson in lessons) { for (var lesson in lessons) {
if (days.last.isNotEmpty && _differentDate(lesson.date, days.last.last.date)) days.add([]); if (days.last.isNotEmpty &&
_differentDate(lesson.date, days.last.last.date)) days.add([]);
days.last.add(lesson); days.last.add(lesson);
} }
@ -152,7 +167,8 @@ class TimetableController extends ChangeNotifier {
if (lessonIndexes.isNotEmpty) { if (lessonIndexes.isNotEmpty) {
// Fill missing indexes with empty spaces // Fill missing indexes with empty spaces
for (var i in List<int>.generate(maxIndex - minIndex + 1, (int i) => minIndex + i)) { for (var i in List<int>.generate(
maxIndex - minIndex + 1, (int i) => minIndex + i)) {
List<Lesson> indexLessons = _getLessonsByIndex(_day, i); List<Lesson> indexLessons = _getLessonsByIndex(_day, i);
// Empty lesson // Empty lesson
@ -160,8 +176,13 @@ class TimetableController extends ChangeNotifier {
// Get start date by previous lesson // Get start date by previous lesson
List<Lesson> prevLesson = _getLessonsByIndex(day, i - 1); List<Lesson> prevLesson = _getLessonsByIndex(day, i - 1);
try { try {
DateTime? startDate = prevLesson.last.start.add(const Duration(seconds: 1)); DateTime startDate =
indexLessons.add(Lesson.fromJson({'isEmpty': true, 'Oraszam': i, 'KezdetIdopont': startDate.toIso8601String()})); prevLesson.last.start.add(const Duration(seconds: 1));
indexLessons.add(Lesson.fromJson({
'isEmpty': true,
'Oraszam': i,
'KezdetIdopont': startDate.toIso8601String()
}));
// ignore: empty_catches // ignore: empty_catches
} catch (e) {} } catch (e) {}
} }
@ -171,7 +192,8 @@ class TimetableController extends ChangeNotifier {
} }
// Additional lessons // Additional lessons
day.addAll(_day.where((l) => int.tryParse(l.lessonIndex) == null && l.subject.id != '')); day.addAll(_day.where((l) =>
int.tryParse(l.lessonIndex) == null && l.subject.id != ''));
day.sort((a, b) => a.start.compareTo(b.start)); day.sort((a, b) => a.start.compareTo(b.start));
@ -213,5 +235,6 @@ class TimetableController extends ChangeNotifier {
return indexes; return indexes;
} }
bool _differentDate(DateTime a, DateTime b) => !(a.year == b.year && a.month == b.month && a.day == b.day); bool _differentDate(DateTime a, DateTime b) =>
!(a.year == b.year && a.month == b.month && a.day == b.day);
} }