Skip to content

Commit

Permalink
Merge branch '2.2.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangomz committed Nov 29, 2021
2 parents 5725edd + 70766d4 commit de2e0b7
Show file tree
Hide file tree
Showing 90 changed files with 1,505 additions and 897 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# CHANGELOG
All notable changes to this project will be documented in this file.

## 2.2.1 - 2021-11-12
## 2.2.2 - 2021-11-29
### Added
- Docs for services
- Auth
- Storage
- OneSignal
- Translations
### Changed
- State logic from services to controllers
- `PathProvider` for `Hive`
- Deprecated Splash screen implementation
### Fixed
- Questionnaire page update on answer sent
- Missing translations:
- "Saldo actual" on ledger
- ContractType translations on profile

## 2.2.1 - 2021-11-16
- Make public the [UMMobile project](https://github.com/UMMobile) 🎉
### Added
- Employee ledger 🎉
Expand Down
28 changes: 20 additions & 8 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,43 @@ _**Changes & release dates in versions further from the next release are more li
- How to pay
- Features for employees: 🎉
- Vacations & work permissions
- CFDI 🎉
- Warning if user doesn't exist
### Change
- (**Opt**) Separate theme and global componentes (like form)
- (**Opt**) Save to local the notifications to be able to show them without connection
- Note: If is read without connection a problem can happen
### Fixes
- Notifications are not marked as received on arrival
- Because that code should be written in native code.
- Because that code should be written in native code... F

## 2.2.2 - 2021-12-01?
## 2.2.3 - 2021-12-03 🚧
### Adds
- (**Opt**) Student docs 🎉
- (**Opt**) Employee CFDI 🎉
### Change
- Force only minor and major versions updates
- Deprectad splash screen for new way
### Fixes
- Invert order for movements in the same day for employees ledger at least

## 2.2.2 - 2021-11-29 ✅
### Adds
- Docs for services
- Auth
- Storage
- OneSignal
- Translations
- Http (_Probably will be remove_)
### Change
- Separate state logic from services
- Make minor and major versions mandatory updates
- Deprectad splash screen for new way
- State logic from services to controllers
- `PathProvider` for `Hive`
- Deprecated Splash screen implementation
### Fixes
- Questionnaire page update on answer sent
- Missing translations:
- "Saldo actual" on ledger
- ContractType translations on profile

## 2.2.1 - 2021-11-12 🚧
## 2.2.1 - 2021-11-16 ✅
- Make public the [UMMobile project](https://github.com/UMMobile) 🎉
### Adds
- Employee ledger 🎉
Expand Down
9 changes: 0 additions & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,6 @@
"source": "See source",
"withoutDate": "Without date",
"update_available_title": "Update available",
"update_available_description": "There is a new version available, please update your app"
"update_available_description": "There is a new version available, please update your app",
"currentBalance": "Current balance"
}
3 changes: 2 additions & 1 deletion assets/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,6 @@
"source":"Ver fuente",
"withoutDate": "Sin fecha",
"update_available_title": "Actualización disponible",
"update_available_description": "Hay una nueva versión de la aplicación disponible, favor de actualizar a la versión más reciente"
"update_available_description": "Hay una nueva versión de la aplicación disponible, favor de actualizar a la versión más reciente",
"currentBalance": "Saldo actual"
}
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = CA5M4WA2HG;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
Expand All @@ -681,7 +681,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
Expand All @@ -706,7 +706,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = CA5M4WA2HG;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
Expand All @@ -716,7 +716,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -738,7 +738,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = CA5M4WA2HG;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
Expand All @@ -748,7 +748,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = mx.edu.um.students.OneSignalNotificationServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
62 changes: 25 additions & 37 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ import 'package:flutter/foundation.dart';*/
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
import 'package:ummobile/services/storage/user_settings.dart';
import 'package:ummobile/modules/app_bar/modules/notifications/controllers/notifications_controller.dart';
import 'package:ummobile/services/storage/app_settings/models/app_settings.dart';
import 'package:ummobile/services/storage/app_settings/settings_box.dart';
import 'package:ummobile/services/storage/storage_registry.dart';
import 'package:ummobile/services/translations/get_translations.dart';
import 'package:ummobile/services/translations/translations_initialize.dart';
import 'package:syncfusion_localizations/syncfusion_localizations.dart';

import 'modules/drawer/modules/settings/models/user_settings.dart';
import 'modules/login/views/page_login.dart';
import 'services/onesignal/handle_events.dart';
import 'services/onesignal/operations.dart';
import 'statics/settings/colors.dart';

UserSettings? _userSettings;
AppSettings? _appSettings;

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
await FlutterTranslations.initialize();
_userSettings = UserSettings.fromJson(
UserSettingsStorage(await getApplicationDocumentsDirectory())
.contentCopy);
RegisterHiveAdapters();

final appSettingsBox = AppSettingsBox();
await appSettingsBox.initializeBox();
_appSettings = appSettingsBox.appSettings;
runApp(
/*DevicePreview(
enabled: !kReleaseMode,
Expand All @@ -39,37 +43,21 @@ class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initializeOneSignal();
handleOneSignalEvents();

WidgetsBinding.instance!.addObserver(this);
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
break;
case AppLifecycleState.inactive:
// app is inactive
break;
case AppLifecycleState.paused:
// user is about quit our app temporally
break;
case AppLifecycleState.detached:
// some code here...
break;
}
}

@override
void dispose() {
WidgetsBinding.instance!.removeObserver(this);
super.dispose();
handleOneSignalEvents(
onReceive: (notification) {
bool notificationsControllerExist =
Get.isRegistered<NotificationsController>();

if (notificationsControllerExist) {
Get.find<NotificationsController>().add(notification.notificationId);
}
},
);
}

@override
Expand All @@ -82,13 +70,13 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
/// Theme section
theme: AppColorThemes.brightTeme,
darkTheme: AppColorThemes.darkTheme,
themeMode: _userSettings!.themeMode,
themeMode: _appSettings?.themeMode ?? ThemeMode.system,

/// Internationalization section
translations: Messages(),
supportedLocales: [Locale('en'), Locale('es', 'MX')],
fallbackLocale: Locale('es', 'MX'),
locale: _userSettings!.language ??
locale: _appSettings?.language ??
Get.deviceLocale, //DevicePreview.locale(context),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
Expand Down
23 changes: 13 additions & 10 deletions lib/modules/app_bar/controllers/appbar_controller.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
import 'package:ummobile/modules/app_bar/modules/notifications/controllers/notifications_controller.dart';
import 'package:ummobile/modules/app_bar/modules/questionnaire/models/questionnaire_answer.dart';
import 'package:ummobile/modules/tabs/modules/profile/models/user_credentials.dart';
import 'package:ummobile/services/storage/questionnaire.dart';
import 'package:ummobile/services/storage/questionnaire_responses/models/questionnaire_response.dart';
import 'package:ummobile/services/storage/questionnaire_responses/questionnaire_responses_box.dart';
import 'package:ummobile_sdk/ummobile_sdk.dart';

class AppBarController extends GetxController {
var notificationsCounter = 0.obs;
/// The number of unanswered questionnaires
var questionnaireCounter = 0.obs;

/// The number of newly added rules
var rulesCounter = 0.obs;

@override
Expand All @@ -21,6 +22,7 @@ class AppBarController extends GetxController {
questionnaireCounter(await searchUnansweredQuestionnaire());
}

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

/// Returns 1 if the covid Questionnaire is unanswered for the current day
Future<int> searchUnansweredQuestionnaire() async {
Map<String, dynamic>? storedQuestionnaire =
QuestionnaireStorage(await getApplicationDocumentsDirectory())
.contentCopy[userId];
final QuestionnaireResponsesBox storage = QuestionnaireResponsesBox();
storage.initializeBox();

QuestionnaireResponse? storedQuestionnaire =
storage.findResponseByCredential(userId);

bool isFromToday = false;
if (storedQuestionnaire != null) {
QuestionnaireLocalAnswer localQuestionnaire =
QuestionnaireLocalAnswer.fromJson(storedQuestionnaire);
isFromToday = localQuestionnaire.isFromToday;
isFromToday = storedQuestionnaire.isFromToday;
}

return isFromToday ? 0 : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ import 'package:ummobile_sdk/ummobile_sdk.dart';

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

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

/// The animaed list class actions
final animatedList = NotificationAnimatedList();

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

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

/// Retrieves the user notifications from the api
void fetchNotifications() async {
call<List<Notification>>(
httpCall: () async => await (await notificationsApi).getAll(),
Expand Down Expand Up @@ -86,6 +94,7 @@ class NotificationsController extends ControllerTemplate
// );
}

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

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

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

/// Clears all the notifications from the list
///
/// This method does not sync with the api
void reset() {
_notifications.clear();
}

/// Clears all the notifications from the list and makes another
/// api call to retrieve possible changes
Future<void> refresh() async {
await call<List<Notification>>(
httpCall: () async => await (await notificationsApi).getAll(),
Expand Down
Loading

0 comments on commit de2e0b7

Please sign in to comment.