This commit is contained in:
J. A. Messias 2024-10-10 09:09:35 -03:00
parent 939a6291e6
commit 8c5f6aed40
3 changed files with 60 additions and 88 deletions

View File

@ -13,6 +13,16 @@ enum DeviceSize {
tablet, tablet,
desktop, 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 { abstract class FlutterFlowTheme {
static DeviceSize deviceSize = DeviceSize.mobile; static DeviceSize deviceSize = DeviceSize.mobile;
@ -27,11 +37,9 @@ abstract class FlutterFlowTheme {
? ThemeMode.dark ? ThemeMode.dark
: ThemeMode.light; : ThemeMode.light;
} }
static void saveThemeMode(ThemeMode mode) => mode == ThemeMode.system static void saveThemeMode(ThemeMode mode) => mode == ThemeMode.system
? _prefs?.remove(kThemeModeKey) ? _prefs?.remove(kThemeModeKey)
: _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark); : _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark);
static FlutterFlowTheme of(BuildContext context) { static FlutterFlowTheme of(BuildContext context) {
deviceSize = getDeviceSize(context); deviceSize = getDeviceSize(context);
return Theme.of(context).brightness == Brightness.dark return Theme.of(context).brightness == Brightness.dark
@ -137,18 +145,6 @@ abstract class FlutterFlowTheme {
DeviceSize.desktop: DesktopTypography(this), DeviceSize.desktop: DesktopTypography(this),
}[deviceSize]!; }[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 { class LightModeTheme extends FlutterFlowTheme {
@Deprecated('Use primary instead') @Deprecated('Use primary instead')
Color get primaryColor => primary; Color get primaryColor => primary;
@ -182,6 +178,39 @@ class LightModeTheme extends FlutterFlowTheme {
late Color customColor5 = const Color(0xFF979595); late Color customColor5 = const Color(0xFF979595);
late Color customColor6 = const Color(0xFF525252); 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 { abstract class Typography {
String get displayLargeFamily; String get displayLargeFamily;
@ -215,12 +244,10 @@ abstract class Typography {
String get bodySmallFamily; String get bodySmallFamily;
TextStyle get bodySmall; TextStyle get bodySmall;
} }
class MobileTypography extends Typography { class MobileTypography extends Typography {
MobileTypography(this.theme); MobileTypography(this.theme);
final FlutterFlowTheme theme; final FlutterFlowTheme theme;
String get displayLargeFamily => 'Nunito Sans'; String get displayLargeFamily => 'Nunito Sans';
TextStyle get displayLarge => GoogleFonts.getFont( TextStyle get displayLarge => GoogleFonts.getFont(
'Nunito Sans', 'Nunito Sans',
@ -325,13 +352,11 @@ class MobileTypography extends Typography {
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
fontSize: 12.0, fontSize: 12.0,
); );
}
}
class TabletTypography extends Typography { class TabletTypography extends Typography {
TabletTypography(this.theme); TabletTypography(this.theme);
final FlutterFlowTheme theme; final FlutterFlowTheme theme;
String get displayLargeFamily => 'Nunito Sans'; String get displayLargeFamily => 'Nunito Sans';
TextStyle get displayLarge => GoogleFonts.getFont( TextStyle get displayLarge => GoogleFonts.getFont(
'Nunito Sans', 'Nunito Sans',
@ -437,12 +462,10 @@ class TabletTypography extends Typography {
fontSize: 12.0, fontSize: 12.0,
); );
} }
class DesktopTypography extends Typography { class DesktopTypography extends Typography {
DesktopTypography(this.theme); DesktopTypography(this.theme);
final FlutterFlowTheme theme; final FlutterFlowTheme theme;
String get displayLargeFamily => 'Nunito Sans'; String get displayLargeFamily => 'Nunito Sans';
TextStyle get displayLarge => GoogleFonts.getFont( TextStyle get displayLarge => GoogleFonts.getFont(
'Nunito Sans', '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 { extension TextStyleHelper on TextStyle {
TextStyle override({ TextStyle override({
String? fontFamily, String? fontFamily,

View File

@ -25,7 +25,6 @@ export 'serialization_util.dart';
const kTransitionInfoKey = '__transition_info__'; const kTransitionInfoKey = '__transition_info__';
///
class AppStateNotifier extends ChangeNotifier { class AppStateNotifier extends ChangeNotifier {
AppStateNotifier._(); AppStateNotifier._();
@ -233,7 +232,6 @@ extension NavParamExtensions on Map<String, String?> {
.map((e) => MapEntry(e.key, e.value!)), .map((e) => MapEntry(e.key, e.value!)),
); );
} }
extension NavigationExtensions on BuildContext { extension NavigationExtensions on BuildContext {
void safePop() { void safePop() {
// If there is only one route on the stack, navigate to the initial // 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 { extension _GoRouterStateExtensions on GoRouterState {
Map<String, dynamic> get extraMap => Map<String, dynamic> get extraMap =>
extra != null ? extra as Map<String, dynamic> : {}; extra != null ? extra as Map<String, dynamic> : {};
@ -257,6 +254,15 @@ extension _GoRouterStateExtensions on GoRouterState {
? extraMap[kTransitionInfoKey] as TransitionInfo ? extraMap[kTransitionInfoKey] as TransitionInfo
: TransitionInfo.appDefault(); : 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 { class FFParameters {
FFParameters(this.state, [this.asyncParams = const {}]); FFParameters(this.state, [this.asyncParams = const {}]);
@ -315,7 +321,6 @@ class FFParameters {
); );
} }
} }
class FFRoute { class FFRoute {
const FFRoute({ const FFRoute({
required this.name, required this.name,
@ -373,7 +378,6 @@ class FFRoute {
routes: routes, routes: routes,
); );
} }
class TransitionInfo { class TransitionInfo {
const TransitionInfo({ const TransitionInfo({
required this.hasTransition, required this.hasTransition,
@ -390,7 +394,6 @@ class TransitionInfo {
static TransitionInfo appDefault() => static TransitionInfo appDefault() =>
const TransitionInfo(hasTransition: false); const TransitionInfo(hasTransition: false);
} }
class RootPageContext { class RootPageContext {
const RootPageContext(this.isRootPage, [this.errorRoute]); const RootPageContext(this.isRootPage, [this.errorRoute]);
final bool isRootPage; final bool isRootPage;
@ -404,19 +407,9 @@ class RootPageContext {
location != '/' && location != '/' &&
location != rootPageContext?.errorRoute; location != rootPageContext?.errorRoute;
} }
static Widget wrap(Widget child, {String? errorRoute}) => Provider.value( static Widget wrap(Widget child, {String? errorRoute}) => Provider.value(
value: RootPageContext(true, errorRoute), value: RootPageContext(true, errorRoute),
child: child, 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();
}
}

View File

@ -41,28 +41,22 @@ Future<void> initializeApp() async {
_initializeSystemSettings(); _initializeSystemSettings();
await _initializeFlutterFlow(); await _initializeFlutterFlow();
} }
Future<void> _initializeStorageHelpers() async { Future<void> _initializeStorageHelpers() async {
await StorageUtil().ensureInitialization(); await StorageUtil().ensureInitialization();
// StorageUtil().isLogged = false; // StorageUtil().isLogged = false;
} }
Future<void> _initializeTracking() async { Future<void> _initializeTracking() async {
await AppTrackingTransparency.requestTrackingAuthorization(); await AppTrackingTransparency.requestTrackingAuthorization();
} }
Future<void> _initializeFirebase() async { Future<void> _initializeFirebase() async {
await Firebase.initializeApp(); await Firebase.initializeApp();
} }
Future<void> _initializeNotificationService() async { Future<void> _initializeNotificationService() async {
await NotificationService.initialize(); await NotificationService.initialize();
} }
void _initializeUrlStrategy() { void _initializeUrlStrategy() {
setUrlStrategy(PathUrlStrategy()); setUrlStrategy(PathUrlStrategy());
} }
void _initializeSystemSettings() { void _initializeSystemSettings() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
if (kDebugMode) { if (kDebugMode) {
@ -74,7 +68,6 @@ void _initializeSystemSettings() {
} }
} }
} }
Future<void> _initializeFlutterFlow() async { Future<void> _initializeFlutterFlow() async {
await FlutterFlowTheme.initialize(); await FlutterFlowTheme.initialize();
await FFLocalizations.initialize(); await FFLocalizations.initialize();
@ -94,7 +87,6 @@ Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
payload: Map<String, String>.from(message.data)); payload: Map<String, String>.from(message.data));
} }
} }
Future<void> _backgroundHandlerMessage(RemoteMessage message) async { Future<void> _backgroundHandlerMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') { if (message.data['click_action'] == 'enroll_cond') {
log('backgroundHandlerMessage'); log('backgroundHandlerMessage');
@ -112,7 +104,6 @@ class App extends StatefulWidget {
static _AppState of(BuildContext context) => static _AppState of(BuildContext context) =>
context.findAncestorStateOfType<_AppState>()!; context.findAncestorStateOfType<_AppState>()!;
} }
class _AppState extends State<App> { class _AppState extends State<App> {
Locale? _locale = FFLocalizations.getStoredLocale(); Locale? _locale = FFLocalizations.getStoredLocale();
@ -138,6 +129,7 @@ class _AppState extends State<App> {
return const Color(0xff1aab5f); return const Color(0xff1aab5f);
}), }),
), ),
bottomSheetTheme: BottomSheetThemeData(dragHandleColor: const Color(0xFF171717)),
); );
final ThemeData _theme = ThemeData( final ThemeData _theme = ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
@ -154,6 +146,8 @@ class _AppState extends State<App> {
return const Color(0xff1aab5f); return const Color(0xff1aab5f);
}), }),
), ),
bottomSheetTheme: BottomSheetThemeData(
dragHandleColor: const Color(0xFFFFFFFF)),
); );
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates = const [ final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates = const [
FFLocalizationsDelegate(), FFLocalizationsDelegate(),
@ -182,7 +176,6 @@ class _AppState extends State<App> {
); );
}; };
Future<void> initDeepLinks() async { Future<void> initDeepLinks() async {
_appLinks = AppLinks(); _appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) { _linkSubscription = _appLinks.uriLinkStream.listen((uri) {
@ -195,14 +188,9 @@ class _AppState extends State<App> {
log('isRecovered: $isRecovered'); log('isRecovered: $isRecovered');
if (isRecovered) return; if (isRecovered) return;
StorageUtil().isRecovered = true; StorageUtil().isRecovered = true;
final String email = uri.queryParameters['email'] ?? ''; final String email = uri.queryParameters['email'] ?? '';
final String token = uri.queryParameters['token'] ?? ''; final String token = uri.queryParameters['token'] ?? '';
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty; final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
if (isNotEmpty ) { if (isNotEmpty ) {
final BuildContext context = StorageUtil().context!; final BuildContext context = StorageUtil().context!;
final MediaQueryData mediaQuery = MediaQuery.of(context); final MediaQueryData mediaQuery = MediaQuery.of(context);
@ -219,10 +207,13 @@ class _AppState extends State<App> {
backgroundColor: theme.primaryBackground, backgroundColor: theme.primaryBackground,
useSafeArea: true, useSafeArea: true,
enableDrag: true, enableDrag: true,
isDismissible: true, isDismissible: true,
).then((_) => StorageUtil().isRecovered = false); ).then((_) => StorageUtil().isRecovered = false);
} }
} }
void _setupFirebaseMessaging() async { void _setupFirebaseMessaging() async {
FirebaseMessaging messaging = FirebaseMessaging.instance; FirebaseMessaging messaging = FirebaseMessaging.instance;
RemoteMessage? initialMessage = await messaging.getInitialMessage(); RemoteMessage? initialMessage = await messaging.getInitialMessage();
@ -261,7 +252,6 @@ class _AppState extends State<App> {
}); });
} }
@override void initState() { @override void initState() {
super.initState(); super.initState();