-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add observers for errors and analytics
- Loading branch information
Showing
15 changed files
with
340 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
# mmcalendar | ||
# Myanmar Calendar | ||
|
||
A new Flutter project. | ||
The Myanmar Calendar app is a beautifully designed tool that brings the traditional Myanmar calendar to your fingertips. Built with Flutter, this app offers a seamless experience across devices, ensuring you stay connected with Myanmar’s rich cultural heritage. | ||
|
||
## Getting Started | ||
## Libraries | ||
|
||
This project is a starting point for a Flutter application. | ||
- [flutter_mmcalendar](https://pub.dev/packages/flutter_mmcalendar) | ||
- [table_calendar](https://pub.dev/packages/table_calendar) | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
## Project Setup | ||
|
||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) | ||
To clone the repo for the first time | ||
|
||
For help getting started with Flutter development, view the | ||
[online documentation](https://docs.flutter.dev/), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
```bash | ||
git clone https://github.com/mixin27/mmcalendar.git | ||
cd mmcalendar/ | ||
flutter packages get | ||
``` | ||
|
||
Generate `build_runner` and `easy_localization` | ||
|
||
```bash | ||
# build_runner | ||
dart run build_runner build | ||
|
||
# easy_localization | ||
dart run easy_localization:generate -S assets/translations -O lib/src/l10n -o locale_keys.g.dart -f keys | ||
``` | ||
|
||
You will need to create firebase project to configure firebase | ||
|
||
```bash | ||
flutterfire configure | ||
``` | ||
|
||
Go to onesignal, login or create an account and create an app. Then copy onesignalAppId and paste to `.env` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +0,0 @@ | ||
#Flutter Wrapper | ||
-keep class io.flutter.app.** { *; } | ||
-keep class io.flutter.plugin.** { *; } | ||
-keep class io.flutter.util.** { *; } | ||
-keep class io.flutter.view.** { *; } | ||
-keep class io.flutter.** { *; } | ||
-keep class io.flutter.plugins.** { *; } | ||
-keep class io.flutter.plugin.editing.** { *; } | ||
|
||
#Firebase | ||
-keep class com.google.firebase.** { *; } | ||
-keep class com.firebase.** { *; } | ||
-keep class org.apache.** { *; } | ||
-keepnames class com.fasterxml.jackson.** { *; } | ||
-keepnames class javax.servlet.** { *; } | ||
-keepnames class org.ietf.jgss.** { *; } | ||
-dontwarn org.w3c.dom.** | ||
-dontwarn org.joda.time.** | ||
-dontwarn org.shaded.apache.** | ||
-dontwarn org.ietf.jgss.** | ||
-keepattributes Signature | ||
-keepattributes *Annotation* | ||
-keepattributes EnclosingMethod | ||
-keepattributes InnerClasses | ||
-keep class androidx.lifecycle.DefaultLifecycleObserver | ||
|
||
#Crashlytics | ||
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers. | ||
-keep public class * extends java.lang.Exception | ||
-keep class com.ito_technologies.soudan.** { *; } | ||
|
||
#twilio_programmable_video | ||
-keep class tvi.webrtc.** { *; } | ||
-keep class com.twilio.video.** { *; } | ||
-keep class com.twilio.common.** { *; } | ||
-keepattributes InnerClasses | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_mmcalendar/flutter_mmcalendar.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:mmcalendar/firebase_options.dart'; | ||
import 'package:mmcalendar/src/utils/onesignal/onesignal.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'app_start_up.g.dart'; | ||
|
||
@Riverpod(keepAlive: true) | ||
FutureOr<void> appStartup(AppStartupRef ref) async { | ||
ref.onDispose(() { | ||
// ensure dependent providers are disposed as well | ||
// ref.invalidate(onboardingRepositoryProvider); | ||
}); | ||
|
||
MmCalendarConfig.initDefault( | ||
const MmCalendarOptions( | ||
language: Language.myanmar, | ||
), | ||
); | ||
|
||
// await for all initialization code to be complete before returning | ||
// we can use `Future.wait` for independent long run tasks. | ||
await Future.wait([ | ||
// Firebase init | ||
Firebase.initializeApp( | ||
options: DefaultFirebaseOptions.currentPlatform, | ||
), | ||
initOnesignal(), | ||
|
||
// list of providers to be warmed up | ||
// ref.watch(onboardingRepositoryProvider.future), | ||
// Future.delayed(const Duration(seconds: 5)), | ||
]); | ||
} | ||
|
||
/// Widget class to manage asynchronous app initialization | ||
class AppStartUpWidget extends ConsumerWidget { | ||
const AppStartUpWidget({ | ||
super.key, | ||
required this.onLoaded, | ||
}); | ||
|
||
final WidgetBuilder onLoaded; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final appStartupState = ref.watch(appStartupProvider); | ||
|
||
return appStartupState.when( | ||
data: (_) => onLoaded(context), | ||
loading: () => const AppStartupLoadingWidget(), | ||
error: (e, st) => AppStartupErrorWidget( | ||
message: e.toString(), | ||
onRetry: () => ref.invalidate(appStartupProvider), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class AppStartupLoadingWidget extends StatelessWidget { | ||
const AppStartupLoadingWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Container( | ||
width: 100, | ||
height: 100, | ||
decoration: const BoxDecoration( | ||
image: DecorationImage( | ||
image: AssetImage('assets/images/logo.png'), | ||
), | ||
), | ||
), | ||
const SizedBox(height: 20), | ||
const CircularProgressIndicator.adaptive(), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class AppStartupErrorWidget extends StatelessWidget { | ||
const AppStartupErrorWidget( | ||
{super.key, required this.message, required this.onRetry}); | ||
final String message; | ||
final VoidCallback onRetry; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text(message, style: Theme.of(context).textTheme.headlineSmall), | ||
const SizedBox(height: 16), | ||
ElevatedButton( | ||
onPressed: onRetry, | ||
child: const Text('Retry'), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import 'package:auto_route/auto_route.dart'; | ||
|
||
class AppRouteObserver extends AutoRouteObserver { | ||
@override | ||
void didPush(Route route, Route? previousRoute) async { | ||
debugPrint('New route pushed: ${route.settings.name}'); | ||
// await FirebaseAnalytics.instance.logEvent( | ||
// name: 'screen_view', | ||
// parameters: { | ||
// 'screen_name': route.settings.name?.replaceAll('Route', 'Page') ?? '', | ||
// 'screen_class': route.settings.name ?? '', | ||
// }, | ||
// ); | ||
} | ||
|
||
@override | ||
void didPop(Route route, Route? previousRoute) { | ||
debugPrint('Route popped: ${route.settings.name}'); | ||
} | ||
|
||
@override | ||
void didReplace({Route? newRoute, Route? oldRoute}) { | ||
debugPrint( | ||
'Route replaced: ${oldRoute?.settings.name} -> ${newRoute?.settings.name}', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'app_router.dart'; | ||
export 'app_router.gr.dart'; | ||
export 'app_route_observer.dart'; |
Oops, something went wrong.