From 8c5f6aed40a7475ed2fef1e5f2d86dc747ab72b6 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Thu, 10 Oct 2024 09:09:35 -0300 Subject: [PATCH] WIP --- lib/flutter_flow/flutter_flow_theme.dart | 101 ++++++++++------------- lib/flutter_flow/nav/nav.dart | 25 ++---- lib/main.dart | 22 ++--- 3 files changed, 60 insertions(+), 88 deletions(-) diff --git a/lib/flutter_flow/flutter_flow_theme.dart b/lib/flutter_flow/flutter_flow_theme.dart index 9bc83617..0832ea68 100644 --- a/lib/flutter_flow/flutter_flow_theme.dart +++ b/lib/flutter_flow/flutter_flow_theme.dart @@ -13,6 +13,16 @@ enum DeviceSize { tablet, desktop, } +DeviceSize getDeviceSize(BuildContext context) { + final width = MediaQuery.sizeOf(context).width; + if (width < 479) { + return DeviceSize.mobile; + } else if (width < 991) { + return DeviceSize.tablet; + } else { + return DeviceSize.desktop; + } +} abstract class FlutterFlowTheme { static DeviceSize deviceSize = DeviceSize.mobile; @@ -27,11 +37,9 @@ abstract class FlutterFlowTheme { ? ThemeMode.dark : ThemeMode.light; } - static void saveThemeMode(ThemeMode mode) => mode == ThemeMode.system ? _prefs?.remove(kThemeModeKey) : _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark); - static FlutterFlowTheme of(BuildContext context) { deviceSize = getDeviceSize(context); return Theme.of(context).brightness == Brightness.dark @@ -137,18 +145,6 @@ abstract class FlutterFlowTheme { DeviceSize.desktop: DesktopTypography(this), }[deviceSize]!; } - -DeviceSize getDeviceSize(BuildContext context) { - final width = MediaQuery.sizeOf(context).width; - if (width < 479) { - return DeviceSize.mobile; - } else if (width < 991) { - return DeviceSize.tablet; - } else { - return DeviceSize.desktop; - } -} - class LightModeTheme extends FlutterFlowTheme { @Deprecated('Use primary instead') Color get primaryColor => primary; @@ -182,6 +178,39 @@ class LightModeTheme extends FlutterFlowTheme { late Color customColor5 = const Color(0xFF979595); late Color customColor6 = const Color(0xFF525252); } +class DarkModeTheme extends FlutterFlowTheme { + @Deprecated('Use primary instead') + Color get primaryColor => primary; + @Deprecated('Use secondary instead') + Color get secondaryColor => secondary; + @Deprecated('Use tertiary instead') + Color get tertiaryColor => tertiary; + + late Color primary = const Color(0xFF1AAB5F); + late Color secondary = const Color(0xFF18AA99); + late Color tertiary = const Color(0xFF984BB6); + late Color alternate = const Color(0xFF232323); + late Color alternate2 = const Color(0xFF171717); + late Color primaryText = const Color(0xFFFFFFFF); + late Color secondaryText = const Color(0xFF000000); + late Color primaryBackground = const Color(0xFF171717); + late Color secondaryBackground = const Color(0xFF101818); + late Color accent1 = const Color(0xFFFFFFFF); + late Color accent2 = const Color(0x4D000000); + late Color accent3 = const Color(0xFFFFFFFF); + late Color accent4 = const Color(0xFF4A4A4A); + late Color success = const Color(0xFF1AAB5F); + late Color warning = const Color(0xFFF3C344); + late Color error = const Color(0xFFD70000); + late Color info = const Color(0xFFFFFFFF); + + late Color customColor1 = const Color(0xFFFFFFFF); + late Color customColor2 = const Color(0xFFFFFFFF); + late Color customColor3 = const Color(0xFF1AAB5F); + late Color customColor4 = const Color(0xFF232323); + late Color customColor5 = const Color(0xFF232323); + late Color customColor6 = const Color(0xFF827F82); +} abstract class Typography { String get displayLargeFamily; @@ -215,12 +244,10 @@ abstract class Typography { String get bodySmallFamily; TextStyle get bodySmall; } - class MobileTypography extends Typography { MobileTypography(this.theme); final FlutterFlowTheme theme; - String get displayLargeFamily => 'Nunito Sans'; TextStyle get displayLarge => GoogleFonts.getFont( 'Nunito Sans', @@ -325,13 +352,11 @@ class MobileTypography extends Typography { fontWeight: FontWeight.normal, fontSize: 12.0, ); -} +} class TabletTypography extends Typography { TabletTypography(this.theme); - final FlutterFlowTheme theme; - String get displayLargeFamily => 'Nunito Sans'; TextStyle get displayLarge => GoogleFonts.getFont( 'Nunito Sans', @@ -437,12 +462,10 @@ class TabletTypography extends Typography { fontSize: 12.0, ); } - class DesktopTypography extends Typography { + DesktopTypography(this.theme); - final FlutterFlowTheme theme; - String get displayLargeFamily => 'Nunito Sans'; TextStyle get displayLarge => GoogleFonts.getFont( 'Nunito Sans', @@ -549,40 +572,6 @@ class DesktopTypography extends Typography { ); } -class DarkModeTheme extends FlutterFlowTheme { - @Deprecated('Use primary instead') - Color get primaryColor => primary; - @Deprecated('Use secondary instead') - Color get secondaryColor => secondary; - @Deprecated('Use tertiary instead') - Color get tertiaryColor => tertiary; - - late Color primary = const Color(0xFF1AAB5F); - late Color secondary = const Color(0xFF18AA99); - late Color tertiary = const Color(0xFF984BB6); - late Color alternate = const Color(0xFF232323); - late Color alternate2 = const Color(0xFF171717); - late Color primaryText = const Color(0xFFFFFFFF); - late Color secondaryText = const Color(0xFF000000); - late Color primaryBackground = const Color(0xFF171717); - late Color secondaryBackground = const Color(0xFF101818); - late Color accent1 = const Color(0xFFFFFFFF); - late Color accent2 = const Color(0x4D000000); - late Color accent3 = const Color(0xFFFFFFFF); - late Color accent4 = const Color(0xFF4A4A4A); - late Color success = const Color(0xFF1AAB5F); - late Color warning = const Color(0xFFF3C344); - late Color error = const Color(0xFFD70000); - late Color info = const Color(0xFFFFFFFF); - - late Color customColor1 = const Color(0xFFFFFFFF); - late Color customColor2 = const Color(0xFFFFFFFF); - late Color customColor3 = const Color(0xFF1AAB5F); - late Color customColor4 = const Color(0xFF232323); - late Color customColor5 = const Color(0xFF232323); - late Color customColor6 = const Color(0xFF827F82); -} - extension TextStyleHelper on TextStyle { TextStyle override({ String? fontFamily, diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index e20f2f11..630e199e 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -25,7 +25,6 @@ export 'serialization_util.dart'; const kTransitionInfoKey = '__transition_info__'; -/// class AppStateNotifier extends ChangeNotifier { AppStateNotifier._(); @@ -233,7 +232,6 @@ extension NavParamExtensions on Map { .map((e) => MapEntry(e.key, e.value!)), ); } - extension NavigationExtensions on BuildContext { void safePop() { // If there is only one route on the stack, navigate to the initial @@ -245,7 +243,6 @@ extension NavigationExtensions on BuildContext { } } } - extension _GoRouterStateExtensions on GoRouterState { Map get extraMap => extra != null ? extra as Map : {}; @@ -257,6 +254,15 @@ extension _GoRouterStateExtensions on GoRouterState { ? extraMap[kTransitionInfoKey] as TransitionInfo : TransitionInfo.appDefault(); } +extension GoRouterLocationExtension on GoRouter { + String getCurrentLocation() { + final RouteMatch lastMatch = routerDelegate.currentConfiguration.last; + final RouteMatchList matchList = lastMatch is ImperativeRouteMatch + ? lastMatch.matches + : routerDelegate.currentConfiguration; + return matchList.uri.toString(); + } +} class FFParameters { FFParameters(this.state, [this.asyncParams = const {}]); @@ -315,7 +321,6 @@ class FFParameters { ); } } - class FFRoute { const FFRoute({ required this.name, @@ -373,7 +378,6 @@ class FFRoute { routes: routes, ); } - class TransitionInfo { const TransitionInfo({ required this.hasTransition, @@ -390,7 +394,6 @@ class TransitionInfo { static TransitionInfo appDefault() => const TransitionInfo(hasTransition: false); } - class RootPageContext { const RootPageContext(this.isRootPage, [this.errorRoute]); final bool isRootPage; @@ -404,19 +407,9 @@ class RootPageContext { location != '/' && location != rootPageContext?.errorRoute; } - static Widget wrap(Widget child, {String? errorRoute}) => Provider.value( value: RootPageContext(true, errorRoute), child: child, ); } -extension GoRouterLocationExtension on GoRouter { - String getCurrentLocation() { - final RouteMatch lastMatch = routerDelegate.currentConfiguration.last; - final RouteMatchList matchList = lastMatch is ImperativeRouteMatch - ? lastMatch.matches - : routerDelegate.currentConfiguration; - return matchList.uri.toString(); - } -} diff --git a/lib/main.dart b/lib/main.dart index bec595b2..9c128dcf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -41,28 +41,22 @@ Future initializeApp() async { _initializeSystemSettings(); await _initializeFlutterFlow(); } - Future _initializeStorageHelpers() async { await StorageUtil().ensureInitialization(); // StorageUtil().isLogged = false; } - Future _initializeTracking() async { await AppTrackingTransparency.requestTrackingAuthorization(); } - Future _initializeFirebase() async { await Firebase.initializeApp(); } - Future _initializeNotificationService() async { await NotificationService.initialize(); } - void _initializeUrlStrategy() { setUrlStrategy(PathUrlStrategy()); } - void _initializeSystemSettings() { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); if (kDebugMode) { @@ -74,7 +68,6 @@ void _initializeSystemSettings() { } } } - Future _initializeFlutterFlow() async { await FlutterFlowTheme.initialize(); await FFLocalizations.initialize(); @@ -94,7 +87,6 @@ Future _foregroundHandlerMessage(RemoteMessage message) async { payload: Map.from(message.data)); } } - Future _backgroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { log('backgroundHandlerMessage'); @@ -112,7 +104,6 @@ class App extends StatefulWidget { static _AppState of(BuildContext context) => context.findAncestorStateOfType<_AppState>()!; } - class _AppState extends State { Locale? _locale = FFLocalizations.getStoredLocale(); @@ -138,6 +129,7 @@ class _AppState extends State { return const Color(0xff1aab5f); }), ), + bottomSheetTheme: BottomSheetThemeData(dragHandleColor: const Color(0xFF171717)), ); final ThemeData _theme = ThemeData( brightness: Brightness.light, @@ -154,6 +146,8 @@ class _AppState extends State { return const Color(0xff1aab5f); }), ), + bottomSheetTheme: BottomSheetThemeData( + dragHandleColor: const Color(0xFFFFFFFF)), ); final Iterable>? localizationsDelegates = const [ FFLocalizationsDelegate(), @@ -182,7 +176,6 @@ class _AppState extends State { ); }; - Future initDeepLinks() async { _appLinks = AppLinks(); _linkSubscription = _appLinks.uriLinkStream.listen((uri) { @@ -195,14 +188,9 @@ class _AppState extends State { log('isRecovered: $isRecovered'); if (isRecovered) return; StorageUtil().isRecovered = true; - final String email = uri.queryParameters['email'] ?? ''; final String token = uri.queryParameters['token'] ?? ''; final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty; - - - - if (isNotEmpty ) { final BuildContext context = StorageUtil().context!; final MediaQueryData mediaQuery = MediaQuery.of(context); @@ -219,10 +207,13 @@ class _AppState extends State { backgroundColor: theme.primaryBackground, useSafeArea: true, enableDrag: true, + isDismissible: true, ).then((_) => StorageUtil().isRecovered = false); } } + + void _setupFirebaseMessaging() async { FirebaseMessaging messaging = FirebaseMessaging.instance; RemoteMessage? initialMessage = await messaging.getInitialMessage(); @@ -261,7 +252,6 @@ class _AppState extends State { }); } - @override void initState() { super.initState();