Skip to content

Commit de2e0b7

Browse files
committed
Merge branch '2.2.2' into main
2 parents 5725edd + 70766d4 commit de2e0b7

File tree

90 files changed

+1505
-897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1505
-897
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
# CHANGELOG
22
All notable changes to this project will be documented in this file.
33

4-
## 2.2.1 - 2021-11-12
4+
## 2.2.2 - 2021-11-29
5+
### Added
6+
- Docs for services
7+
- Auth
8+
- Storage
9+
- OneSignal
10+
- Translations
11+
### Changed
12+
- State logic from services to controllers
13+
- `PathProvider` for `Hive`
14+
- Deprecated Splash screen implementation
15+
### Fixed
16+
- Questionnaire page update on answer sent
17+
- Missing translations:
18+
- "Saldo actual" on ledger
19+
- ContractType translations on profile
20+
21+
## 2.2.1 - 2021-11-16
522
- Make public the [UMMobile project](https://github.com/UMMobile) 🎉
623
### Added
724
- Employee ledger 🎉

ROADMAP.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,43 @@ _**Changes & release dates in versions further from the next release are more li
99
- How to pay
1010
- Features for employees: 🎉
1111
- Vacations & work permissions
12+
- CFDI 🎉
1213
- Warning if user doesn't exist
1314
### Change
1415
- (**Opt**) Separate theme and global componentes (like form)
1516
- (**Opt**) Save to local the notifications to be able to show them without connection
1617
- Note: If is read without connection a problem can happen
1718
### Fixes
1819
- Notifications are not marked as received on arrival
19-
- Because that code should be written in native code.
20+
- Because that code should be written in native code... F
2021

21-
## 2.2.2 - 2021-12-01?
22+
## 2.2.3 - 2021-12-03 🚧
2223
### Adds
2324
- (**Opt**) Student docs 🎉
24-
- (**Opt**) Employee CFDI 🎉
25+
### Change
26+
- Force only minor and major versions updates
27+
- Deprectad splash screen for new way
28+
### Fixes
29+
- Invert order for movements in the same day for employees ledger at least
30+
31+
## 2.2.2 - 2021-11-29 ✅
32+
### Adds
2533
- Docs for services
2634
- Auth
2735
- Storage
2836
- OneSignal
2937
- Translations
30-
- Http (_Probably will be remove_)
3138
### Change
32-
- Separate state logic from services
33-
- Make minor and major versions mandatory updates
34-
- Deprectad splash screen for new way
39+
- State logic from services to controllers
40+
- `PathProvider` for `Hive`
41+
- Deprecated Splash screen implementation
42+
### Fixes
43+
- Questionnaire page update on answer sent
44+
- Missing translations:
45+
- "Saldo actual" on ledger
46+
- ContractType translations on profile
3547

36-
## 2.2.1 - 2021-11-12 🚧
48+
## 2.2.1 - 2021-11-16 ✅
3749
- Make public the [UMMobile project](https://github.com/UMMobile) 🎉
3850
### Adds
3951
- Employee ledger 🎉

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@
2525
android:name="io.flutter.embedding.android.NormalTheme"
2626
android:resource="@style/NormalTheme"
2727
/>
28-
<!-- Displays an Android View that continues showing the launch screen
29-
Drawable until Flutter paints its first frame, then this splash
30-
screen fades out. A splash screen is useful to avoid any visual
31-
gap between the end of Android's launch screen and the painting of
32-
Flutter's first frame. -->
33-
<meta-data
34-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
35-
android:resource="@drawable/launch_background"
36-
/>
3728
<intent-filter>
3829
<action android:name="android.intent.action.MAIN"/>
3930
<category android:name="android.intent.category.LAUNCHER"/>

assets/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,6 @@
220220
"source": "See source",
221221
"withoutDate": "Without date",
222222
"update_available_title": "Update available",
223-
"update_available_description": "There is a new version available, please update your app"
223+
"update_available_description": "There is a new version available, please update your app",
224+
"currentBalance": "Current balance"
224225
}

assets/translations/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,6 @@
220220
"source":"Ver fuente",
221221
"withoutDate": "Sin fecha",
222222
"update_available_title": "Actualización disponible",
223-
"update_available_description": "Hay una nueva versión de la aplicación disponible, favor de actualizar a la versión más reciente"
223+
"update_available_description": "Hay una nueva versión de la aplicación disponible, favor de actualizar a la versión más reciente",
224+
"currentBalance": "Saldo actual"
224225
}

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@
671671
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
672672
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
673673
CODE_SIGN_STYLE = Automatic;
674-
CURRENT_PROJECT_VERSION = 22;
674+
CURRENT_PROJECT_VERSION = 23;
675675
DEVELOPMENT_TEAM = CA5M4WA2HG;
676676
GCC_C_LANGUAGE_STANDARD = gnu11;
677677
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
@@ -681,7 +681,7 @@
681681
"@executable_path/Frameworks",
682682
"@executable_path/../../Frameworks",
683683
);
684-
MARKETING_VERSION = 2.2.1;
684+
MARKETING_VERSION = 2.2.2;
685685
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
686686
MTL_FAST_MATH = YES;
687687
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
@@ -706,7 +706,7 @@
706706
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
707707
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
708708
CODE_SIGN_STYLE = Automatic;
709-
CURRENT_PROJECT_VERSION = 22;
709+
CURRENT_PROJECT_VERSION = 23;
710710
DEVELOPMENT_TEAM = CA5M4WA2HG;
711711
GCC_C_LANGUAGE_STANDARD = gnu11;
712712
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
@@ -716,7 +716,7 @@
716716
"@executable_path/Frameworks",
717717
"@executable_path/../../Frameworks",
718718
);
719-
MARKETING_VERSION = 2.2.1;
719+
MARKETING_VERSION = 2.2.2;
720720
MTL_FAST_MATH = YES;
721721
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
722722
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -738,7 +738,7 @@
738738
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
739739
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
740740
CODE_SIGN_STYLE = Automatic;
741-
CURRENT_PROJECT_VERSION = 22;
741+
CURRENT_PROJECT_VERSION = 23;
742742
DEVELOPMENT_TEAM = CA5M4WA2HG;
743743
GCC_C_LANGUAGE_STANDARD = gnu11;
744744
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
@@ -748,7 +748,7 @@
748748
"@executable_path/Frameworks",
749749
"@executable_path/../../Frameworks",
750750
);
751-
MARKETING_VERSION = 2.2.1;
751+
MARKETING_VERSION = 2.2.2;
752752
MTL_FAST_MATH = YES;
753753
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
754754
PRODUCT_NAME = "$(TARGET_NAME)";

lib/main.dart

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ import 'package:flutter/foundation.dart';*/
33
import 'package:flutter/material.dart';
44
import 'package:flutter_localizations/flutter_localizations.dart';
55
import 'package:get/get.dart';
6+
import 'package:hive_flutter/hive_flutter.dart';
67
import 'package:intl/intl.dart';
7-
import 'package:path_provider/path_provider.dart';
8-
import 'package:ummobile/services/storage/user_settings.dart';
8+
import 'package:ummobile/modules/app_bar/modules/notifications/controllers/notifications_controller.dart';
9+
import 'package:ummobile/services/storage/app_settings/models/app_settings.dart';
10+
import 'package:ummobile/services/storage/app_settings/settings_box.dart';
11+
import 'package:ummobile/services/storage/storage_registry.dart';
912
import 'package:ummobile/services/translations/get_translations.dart';
1013
import 'package:ummobile/services/translations/translations_initialize.dart';
1114
import 'package:syncfusion_localizations/syncfusion_localizations.dart';
1215

13-
import 'modules/drawer/modules/settings/models/user_settings.dart';
1416
import 'modules/login/views/page_login.dart';
15-
import 'services/onesignal/handle_events.dart';
1617
import 'services/onesignal/operations.dart';
1718
import 'statics/settings/colors.dart';
1819

19-
UserSettings? _userSettings;
20+
AppSettings? _appSettings;
2021

2122
void main() async {
2223
WidgetsFlutterBinding.ensureInitialized();
24+
await Hive.initFlutter();
2325
await FlutterTranslations.initialize();
24-
_userSettings = UserSettings.fromJson(
25-
UserSettingsStorage(await getApplicationDocumentsDirectory())
26-
.contentCopy);
26+
RegisterHiveAdapters();
27+
28+
final appSettingsBox = AppSettingsBox();
29+
await appSettingsBox.initializeBox();
30+
_appSettings = appSettingsBox.appSettings;
2731
runApp(
2832
/*DevicePreview(
2933
enabled: !kReleaseMode,
@@ -39,37 +43,21 @@ class MyApp extends StatefulWidget {
3943
_MyAppState createState() => _MyAppState();
4044
}
4145

42-
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
46+
class _MyAppState extends State<MyApp> {
4347
@override
4448
void initState() {
4549
super.initState();
4650
initializeOneSignal();
47-
handleOneSignalEvents();
48-
49-
WidgetsBinding.instance!.addObserver(this);
50-
}
51-
52-
@override
53-
void didChangeAppLifecycleState(AppLifecycleState state) {
54-
switch (state) {
55-
case AppLifecycleState.resumed:
56-
break;
57-
case AppLifecycleState.inactive:
58-
// app is inactive
59-
break;
60-
case AppLifecycleState.paused:
61-
// user is about quit our app temporally
62-
break;
63-
case AppLifecycleState.detached:
64-
// some code here...
65-
break;
66-
}
67-
}
68-
69-
@override
70-
void dispose() {
71-
WidgetsBinding.instance!.removeObserver(this);
72-
super.dispose();
51+
handleOneSignalEvents(
52+
onReceive: (notification) {
53+
bool notificationsControllerExist =
54+
Get.isRegistered<NotificationsController>();
55+
56+
if (notificationsControllerExist) {
57+
Get.find<NotificationsController>().add(notification.notificationId);
58+
}
59+
},
60+
);
7361
}
7462

7563
@override
@@ -82,13 +70,13 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
8270
/// Theme section
8371
theme: AppColorThemes.brightTeme,
8472
darkTheme: AppColorThemes.darkTheme,
85-
themeMode: _userSettings!.themeMode,
73+
themeMode: _appSettings?.themeMode ?? ThemeMode.system,
8674

8775
/// Internationalization section
8876
translations: Messages(),
8977
supportedLocales: [Locale('en'), Locale('es', 'MX')],
9078
fallbackLocale: Locale('es', 'MX'),
91-
locale: _userSettings!.language ??
79+
locale: _appSettings?.language ??
9280
Get.deviceLocale, //DevicePreview.locale(context),
9381
localizationsDelegates: [
9482
GlobalMaterialLocalizations.delegate,

lib/modules/app_bar/controllers/appbar_controller.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import 'package:get/get.dart';
2-
import 'package:path_provider/path_provider.dart';
32
import 'package:ummobile/modules/app_bar/modules/notifications/controllers/notifications_controller.dart';
4-
import 'package:ummobile/modules/app_bar/modules/questionnaire/models/questionnaire_answer.dart';
53
import 'package:ummobile/modules/tabs/modules/profile/models/user_credentials.dart';
6-
import 'package:ummobile/services/storage/questionnaire.dart';
4+
import 'package:ummobile/services/storage/questionnaire_responses/models/questionnaire_response.dart';
5+
import 'package:ummobile/services/storage/questionnaire_responses/questionnaire_responses_box.dart';
76
import 'package:ummobile_sdk/ummobile_sdk.dart';
87

98
class AppBarController extends GetxController {
10-
var notificationsCounter = 0.obs;
9+
/// The number of unanswered questionnaires
1110
var questionnaireCounter = 0.obs;
11+
12+
/// The number of newly added rules
1213
var rulesCounter = 0.obs;
1314

1415
@override
@@ -21,6 +22,7 @@ class AppBarController extends GetxController {
2122
questionnaireCounter(await searchUnansweredQuestionnaire());
2223
}
2324

25+
/// Returns the amount of unreaded notifications
2426
int searchNewNotifications() {
2527
List<Notification> notifications =
2628
Get.find<NotificationsController>().items;
@@ -33,16 +35,17 @@ class AppBarController extends GetxController {
3335
return counter;
3436
}
3537

38+
/// Returns 1 if the covid Questionnaire is unanswered for the current day
3639
Future<int> searchUnansweredQuestionnaire() async {
37-
Map<String, dynamic>? storedQuestionnaire =
38-
QuestionnaireStorage(await getApplicationDocumentsDirectory())
39-
.contentCopy[userId];
40+
final QuestionnaireResponsesBox storage = QuestionnaireResponsesBox();
41+
storage.initializeBox();
42+
43+
QuestionnaireResponse? storedQuestionnaire =
44+
storage.findResponseByCredential(userId);
4045

4146
bool isFromToday = false;
4247
if (storedQuestionnaire != null) {
43-
QuestionnaireLocalAnswer localQuestionnaire =
44-
QuestionnaireLocalAnswer.fromJson(storedQuestionnaire);
45-
isFromToday = localQuestionnaire.isFromToday;
48+
isFromToday = storedQuestionnaire.isFromToday;
4649
}
4750

4851
return isFromToday ? 0 : 1;

lib/modules/app_bar/modules/notifications/controllers/notifications_controller.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,28 @@ import 'package:ummobile_sdk/ummobile_sdk.dart';
88

99
class NotificationsController extends ControllerTemplate
1010
with StateMixin<List<Notification>> {
11+
/// The notifications api service
1112
Future<UMMobileNotifications> get notificationsApi async {
1213
String accessToken = await Get.find<LoginController>().token;
1314
return UMMobileNotifications(token: accessToken);
1415
}
1516

17+
/// The list of notifications
1618
var _notifications = <Notification>[].obs;
1719

20+
/// The animaed list class actions
1821
final animatedList = NotificationAnimatedList();
1922

23+
/// Returns the user's notification list
2024
UnmodifiableListView<Notification> get items {
2125
List<Notification> sortedNotifications = _notifications.toList();
2226
sortedNotifications.sort((a, b) => b.createAt.compareTo(a.createAt));
2327
return UnmodifiableListView(sortedNotifications);
2428
}
2529

30+
/// Returns the user's notifications list sorted by isRead
31+
///
32+
/// First goes the unreaded notifications
2633
List<Notification> get itemsSorted {
2734
List<Notification> unreadedNotifications = [];
2835
List<Notification> readedNotifications = [];
@@ -45,6 +52,7 @@ class NotificationsController extends ControllerTemplate
4552
super.onInit();
4653
}
4754

55+
/// Retrieves the user notifications from the api
4856
void fetchNotifications() async {
4957
call<List<Notification>>(
5058
httpCall: () async => await (await notificationsApi).getAll(),
@@ -86,6 +94,7 @@ class NotificationsController extends ControllerTemplate
8694
// );
8795
}
8896

97+
/// Removes a notification from the list based by the notification [id]
8998
Future<void> remove(String id) async {
9099
int index =
91100
_notifications.indexWhere((notification) => notification.id == id);
@@ -103,6 +112,7 @@ class NotificationsController extends ControllerTemplate
103112
);
104113
}
105114

115+
/// Removes all the read notification from the list
106116
void removeAll() async {
107117
for (int i = itemsSorted.length - 1; i >= 0; i--) {
108118
if (itemsSorted[i].isSeen) {
@@ -115,6 +125,7 @@ class NotificationsController extends ControllerTemplate
115125
}
116126
}
117127

128+
/// Marks a notification as read where notification.id == [id]
118129
void markAsRead(String id) {
119130
final int index =
120131
_notifications.indexWhere((notification) => notification.id == id);
@@ -133,10 +144,15 @@ class NotificationsController extends ControllerTemplate
133144
);
134145
}
135146

147+
/// Clears all the notifications from the list
148+
///
149+
/// This method does not sync with the api
136150
void reset() {
137151
_notifications.clear();
138152
}
139153

154+
/// Clears all the notifications from the list and makes another
155+
/// api call to retrieve possible changes
140156
Future<void> refresh() async {
141157
await call<List<Notification>>(
142158
httpCall: () async => await (await notificationsApi).getAll(),

0 commit comments

Comments
 (0)