diff --git a/filcnaplo/android/app/src/main/AndroidManifest.xml b/filcnaplo/android/app/src/main/AndroidManifest.xml
index 0795b31..948ca87 100644
--- a/filcnaplo/android/app/src/main/AndroidManifest.xml
+++ b/filcnaplo/android/app/src/main/AndroidManifest.xml
@@ -27,6 +27,7 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml b/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
index 84794a2..0babbc8 100644
--- a/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
+++ b/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
@@ -5,16 +5,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_margin="@dimen/widget_margin">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/filcnaplo/lib/api/providers/sync.dart b/filcnaplo/lib/api/providers/sync.dart
index 0636e0e..eb608a0 100644
--- a/filcnaplo/lib/api/providers/sync.dart
+++ b/filcnaplo/lib/api/providers/sync.dart
@@ -71,6 +71,7 @@ Future syncAll(BuildContext context) {
Future updateWidget() async {
try {
+ print("FILC | Widget updated from sync");
return HomeWidget.updateWidget(name: 'widget_timetable.WidgetTimetable');
} on PlatformException catch (exception) {
debugPrint('Error Updating Widget. $exception');
diff --git a/filcnaplo/lib/api/providers/user_provider.dart b/filcnaplo/lib/api/providers/user_provider.dart
index b077554..54ea4d8 100644
--- a/filcnaplo/lib/api/providers/user_provider.dart
+++ b/filcnaplo/lib/api/providers/user_provider.dart
@@ -2,6 +2,8 @@ import 'package:filcnaplo/models/settings.dart';
import 'package:filcnaplo/models/user.dart';
import 'package:filcnaplo_kreta_api/models/student.dart';
import 'package:flutter/foundation.dart';
+import 'package:home_widget/home_widget.dart';
+import 'package:flutter/services.dart';
class UserProvider with ChangeNotifier {
final Map _users = {};
@@ -26,9 +28,20 @@ class UserProvider with ChangeNotifier {
void setUser(String userId) {
_selectedUserId = userId;
_settings.update(lastAccountId: userId);
+ updateWidget();
notifyListeners();
}
+ Future updateWidget() async {
+ try {
+ print("FILC | Widget updated from users");
+ return HomeWidget.updateWidget(name: 'widget_timetable.WidgetTimetable');
+ } on PlatformException catch (exception) {
+ print('Error Updating Widget After setUser. $exception');
+ }
+ return false;
+ }
+
void addUser(User user) {
_users[user.id] = user;
if (kDebugMode) {
@@ -36,11 +49,17 @@ class UserProvider with ChangeNotifier {
}
}
- void removeUser(String userId) {
+ void removeUser(String userId) async {
_users.removeWhere((key, value) => key == userId);
- if (_users.isNotEmpty) _selectedUserId = _users.keys.first;
+ if (_users.isNotEmpty) {
+ setUser(_users.keys.first);
+ } else {
+ print("FILC | Setting last account id to null");
+ await _settings.update(lastAccountId: "");
+ }
+ updateWidget();
notifyListeners();
- }
+}
User getUser(String userId) {
return _users[userId]!;