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,
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,

View File

@ -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<String, String?> {
.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<String, dynamic> get extraMap =>
extra != null ? extra as Map<String, dynamic> : {};
@ -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();
}
}

View File

@ -41,28 +41,22 @@ Future<void> initializeApp() async {
_initializeSystemSettings();
await _initializeFlutterFlow();
}
Future<void> _initializeStorageHelpers() async {
await StorageUtil().ensureInitialization();
// StorageUtil().isLogged = false;
}
Future<void> _initializeTracking() async {
await AppTrackingTransparency.requestTrackingAuthorization();
}
Future<void> _initializeFirebase() async {
await Firebase.initializeApp();
}
Future<void> _initializeNotificationService() async {
await NotificationService.initialize();
}
void _initializeUrlStrategy() {
setUrlStrategy(PathUrlStrategy());
}
void _initializeSystemSettings() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
if (kDebugMode) {
@ -74,7 +68,6 @@ void _initializeSystemSettings() {
}
}
}
Future<void> _initializeFlutterFlow() async {
await FlutterFlowTheme.initialize();
await FFLocalizations.initialize();
@ -94,7 +87,6 @@ Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
payload: Map<String, String>.from(message.data));
}
}
Future<void> _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<App> {
Locale? _locale = FFLocalizations.getStoredLocale();
@ -138,6 +129,7 @@ class _AppState extends State<App> {
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<App> {
return const Color(0xff1aab5f);
}),
),
bottomSheetTheme: BottomSheetThemeData(
dragHandleColor: const Color(0xFFFFFFFF)),
);
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates = const [
FFLocalizationsDelegate(),
@ -182,7 +176,6 @@ class _AppState extends State<App> {
);
};
Future<void> initDeepLinks() async {
_appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
@ -195,14 +188,9 @@ class _AppState extends State<App> {
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<App> {
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<App> {
});
}
@override void initState() {
super.initState();