// ignore_for_file: overridden_fields, annotate_overrides

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

import 'package:shared_preferences/shared_preferences.dart';

const kThemeModeKey = '__theme_mode__';
SharedPreferences? _prefs;

enum DeviceSize {
  mobile,
  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;

  static Future initialize() async =>
      _prefs = await SharedPreferences.getInstance();
  static ThemeMode get themeMode {
    final darkMode = _prefs?.getBool(kThemeModeKey);
    return darkMode == null
        ? ThemeMode.system
        : darkMode
            ? 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
        ? DarkModeTheme()
        : LightModeTheme();
  }

  @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;
  late Color secondary;
  late Color tertiary;
  late Color alternate;
  late Color alternate2;
  late Color primaryText;
  late Color secondaryText;
  late Color primaryBackground;
  late Color secondaryBackground;
  late Color accent1;
  late Color accent2;
  late Color accent3;
  late Color accent4;
  late Color success;
  late Color warning;
  late Color error;
  late Color info;

  late Color customColor1;
  late Color customColor2;
  late Color customColor3;
  late Color customColor4;
  late Color customColor5;
  late Color customColor6;

  @Deprecated('Use displaySmallFamily instead')
  String get title1Family => displaySmallFamily;
  @Deprecated('Use displaySmall instead')
  TextStyle get title1 => typography.displaySmall;
  @Deprecated('Use headlineMediumFamily instead')
  String get title2Family => typography.headlineMediumFamily;
  @Deprecated('Use headlineMedium instead')
  TextStyle get title2 => typography.headlineMedium;
  @Deprecated('Use headlineSmallFamily instead')
  String get title3Family => typography.headlineSmallFamily;
  @Deprecated('Use headlineSmall instead')
  TextStyle get title3 => typography.headlineSmall;
  @Deprecated('Use titleMediumFamily instead')
  String get subtitle1Family => typography.titleMediumFamily;
  @Deprecated('Use titleMedium instead')
  TextStyle get subtitle1 => typography.titleMedium;
  @Deprecated('Use titleSmallFamily instead')
  String get subtitle2Family => typography.titleSmallFamily;
  @Deprecated('Use titleSmall instead')
  TextStyle get subtitle2 => typography.titleSmall;
  @Deprecated('Use bodyMediumFamily instead')
  String get bodyText1Family => typography.bodyMediumFamily;
  @Deprecated('Use bodyMedium instead')
  TextStyle get bodyText1 => typography.bodyMedium;
  @Deprecated('Use bodySmallFamily instead')
  String get bodyText2Family => typography.bodySmallFamily;
  @Deprecated('Use bodySmall instead')
  TextStyle get bodyText2 => typography.bodySmall;

  String get displayLargeFamily => typography.displayLargeFamily;
  TextStyle get displayLarge => typography.displayLarge;
  String get displayMediumFamily => typography.displayMediumFamily;
  TextStyle get displayMedium => typography.displayMedium;
  String get displaySmallFamily => typography.displaySmallFamily;
  TextStyle get displaySmall => typography.displaySmall;
  String get headlineLargeFamily => typography.headlineLargeFamily;
  TextStyle get headlineLarge => typography.headlineLarge;
  String get headlineMediumFamily => typography.headlineMediumFamily;
  TextStyle get headlineMedium => typography.headlineMedium;
  String get headlineSmallFamily => typography.headlineSmallFamily;
  TextStyle get headlineSmall => typography.headlineSmall;
  String get titleLargeFamily => typography.titleLargeFamily;
  TextStyle get titleLarge => typography.titleLarge;
  String get titleMediumFamily => typography.titleMediumFamily;
  TextStyle get titleMedium => typography.titleMedium;
  String get titleSmallFamily => typography.titleSmallFamily;
  TextStyle get titleSmall => typography.titleSmall;
  String get labelLargeFamily => typography.labelLargeFamily;
  TextStyle get labelLarge => typography.labelLarge;
  String get labelMediumFamily => typography.labelMediumFamily;
  TextStyle get labelMedium => typography.labelMedium;
  String get labelSmallFamily => typography.labelSmallFamily;
  TextStyle get labelSmall => typography.labelSmall;
  String get bodyLargeFamily => typography.bodyLargeFamily;
  TextStyle get bodyLarge => typography.bodyLarge;
  String get bodyMediumFamily => typography.bodyMediumFamily;
  TextStyle get bodyMedium => typography.bodyMedium;
  String get bodySmallFamily => typography.bodySmallFamily;
  TextStyle get bodySmall => typography.bodySmall;

  Typography get typography => {
        DeviceSize.mobile: MobileTypography(this),
        DeviceSize.tablet: TabletTypography(this),
        DeviceSize.desktop: DesktopTypography(this),
      }[deviceSize]!;
}

class LightModeTheme 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(0xFFB59E9E);
  late Color tertiary = const Color(0xFF984BB6);
  late Color alternate = const Color(0xFFF2F2F2);
  late Color alternate2 = const Color(0xFF232323);
  late Color primaryText = const Color(0xFF000000);
  late Color secondaryText = const Color(0xFFFFFFFF);
  late Color primaryBackground = const Color(0xFFFFFFFF);
  late Color secondaryBackground = const Color(0xFFFFFFFF);
  late Color accent1 = const Color(0xFF1AAB5F);
  late Color accent2 = const Color(0x4D000000);
  late Color accent3 = const Color(0xFFFFFFFF);
  late Color accent4 = const Color(0xFF1AAB5F);
  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(0xFF000000);
  late Color customColor2 = const Color(0xFF1AAB5F);
  late Color customColor3 = const Color(0xFFFFFFFF);
  late Color customColor4 = const Color(0xFFCFCFCF);
  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;
  TextStyle get displayLarge;
  String get displayMediumFamily;
  TextStyle get displayMedium;
  String get displaySmallFamily;
  TextStyle get displaySmall;
  String get headlineLargeFamily;
  TextStyle get headlineLarge;
  String get headlineMediumFamily;
  TextStyle get headlineMedium;
  String get headlineSmallFamily;
  TextStyle get headlineSmall;
  String get titleLargeFamily;
  TextStyle get titleLarge;
  String get titleMediumFamily;
  TextStyle get titleMedium;
  String get titleSmallFamily;
  TextStyle get titleSmall;
  String get labelLargeFamily;
  TextStyle get labelLarge;
  String get labelMediumFamily;
  TextStyle get labelMedium;
  String get labelSmallFamily;
  TextStyle get labelSmall;
  String get bodyLargeFamily;
  TextStyle get bodyLarge;
  String get bodyMediumFamily;
  TextStyle get bodyMedium;
  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',
        color: theme.primaryText,
        fontWeight: FontWeight.w300,
        fontSize: 52.0,
      );
  String get displayMediumFamily => 'Nunito Sans';
  TextStyle get displayMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 44.0,
      );
  String get displaySmallFamily => 'Nunito Sans';
  TextStyle get displaySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 36.0,
      );
  String get headlineLargeFamily => 'Nunito Sans';
  TextStyle get headlineLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 32.0,
      );
  String get headlineMediumFamily => 'Nunito Sans';
  TextStyle get headlineMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 28.0,
      );
  String get headlineSmallFamily => 'Nunito Sans';
  TextStyle get headlineSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 24.0,
      );
  String get titleLargeFamily => 'Nunito Sans';
  TextStyle get titleLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 22.0,
      );
  String get titleMediumFamily => 'Nunito Sans';
  TextStyle get titleMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 18.0,
      );
  String get titleSmallFamily => 'Nunito Sans';
  TextStyle get titleSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelLargeFamily => 'Nunito Sans';
  TextStyle get labelLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelMediumFamily => 'Nunito Sans';
  TextStyle get labelMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 14.0,
      );
  String get labelSmallFamily => 'Nunito Sans';
  TextStyle get labelSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 12.0,
      );
  String get bodyLargeFamily => 'Nunito Sans';
  TextStyle get bodyLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontSize: 16.0,
      );
  String get bodyMediumFamily => 'Nunito Sans';
  TextStyle get bodyMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 14.0,
      );
  String get bodySmallFamily => 'Nunito Sans';
  TextStyle get bodySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        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',
        color: theme.primaryText,
        fontWeight: FontWeight.w300,
        fontSize: 52.0,
      );
  String get displayMediumFamily => 'Nunito Sans';
  TextStyle get displayMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 44.0,
      );
  String get displaySmallFamily => 'Nunito Sans';
  TextStyle get displaySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 36.0,
      );
  String get headlineLargeFamily => 'Nunito Sans';
  TextStyle get headlineLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 32.0,
      );
  String get headlineMediumFamily => 'Nunito Sans';
  TextStyle get headlineMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 28.0,
      );
  String get headlineSmallFamily => 'Nunito Sans';
  TextStyle get headlineSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 24.0,
      );
  String get titleLargeFamily => 'Nunito Sans';
  TextStyle get titleLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 22.0,
      );
  String get titleMediumFamily => 'Nunito Sans';
  TextStyle get titleMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 18.0,
      );
  String get titleSmallFamily => 'Nunito Sans';
  TextStyle get titleSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelLargeFamily => 'Nunito Sans';
  TextStyle get labelLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelMediumFamily => 'Nunito Sans';
  TextStyle get labelMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 14.0,
      );
  String get labelSmallFamily => 'Nunito Sans';
  TextStyle get labelSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 12.0,
      );
  String get bodyLargeFamily => 'Nunito Sans';
  TextStyle get bodyLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontSize: 16.0,
      );
  String get bodyMediumFamily => 'Nunito Sans';
  TextStyle get bodyMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 14.0,
      );
  String get bodySmallFamily => 'Nunito Sans';
  TextStyle get bodySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        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',
        color: theme.primaryText,
        fontWeight: FontWeight.w300,
        fontSize: 52.0,
      );
  String get displayMediumFamily => 'Nunito Sans';
  TextStyle get displayMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 44.0,
      );
  String get displaySmallFamily => 'Nunito Sans';
  TextStyle get displaySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 36.0,
      );
  String get headlineLargeFamily => 'Nunito Sans';
  TextStyle get headlineLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 32.0,
      );
  String get headlineMediumFamily => 'Nunito Sans';
  TextStyle get headlineMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 28.0,
      );
  String get headlineSmallFamily => 'Nunito Sans';
  TextStyle get headlineSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 24.0,
      );
  String get titleLargeFamily => 'Nunito Sans';
  TextStyle get titleLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.w500,
        fontSize: 22.0,
      );
  String get titleMediumFamily => 'Nunito Sans';
  TextStyle get titleMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 18.0,
      );
  String get titleSmallFamily => 'Nunito Sans';
  TextStyle get titleSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.info,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelLargeFamily => 'Nunito Sans';
  TextStyle get labelLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 16.0,
      );
  String get labelMediumFamily => 'Nunito Sans';
  TextStyle get labelMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 14.0,
      );
  String get labelSmallFamily => 'Nunito Sans';
  TextStyle get labelSmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.secondaryText,
        fontWeight: FontWeight.w500,
        fontSize: 12.0,
      );
  String get bodyLargeFamily => 'Nunito Sans';
  TextStyle get bodyLarge => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontSize: 16.0,
      );
  String get bodyMediumFamily => 'Nunito Sans';
  TextStyle get bodyMedium => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 14.0,
      );
  String get bodySmallFamily => 'Nunito Sans';
  TextStyle get bodySmall => GoogleFonts.getFont(
        'Nunito Sans',
        color: theme.primaryText,
        fontWeight: FontWeight.normal,
        fontSize: 12.0,
      );
}

extension TextStyleHelper on TextStyle {
  TextStyle override({
    String? fontFamily,
    Color? color,
    double? fontSize,
    FontWeight? fontWeight,
    double? letterSpacing,
    FontStyle? fontStyle,
    bool useGoogleFonts = true,
    TextDecoration? decoration,
    double? lineHeight,
    List<Shadow>? shadows,
  }) =>
      useGoogleFonts
          ? GoogleFonts.getFont(
              fontFamily!,
              color: color ?? this.color,
              fontSize: fontSize ?? this.fontSize,
              letterSpacing: letterSpacing ?? this.letterSpacing,
              fontWeight: fontWeight ?? this.fontWeight,
              fontStyle: fontStyle ?? this.fontStyle,
              decoration: decoration,
              height: lineHeight,
              shadows: shadows,
            )
          : copyWith(
              fontFamily: fontFamily,
              color: color,
              fontSize: fontSize,
              letterSpacing: letterSpacing,
              fontWeight: fontWeight,
              fontStyle: fontStyle,
              decoration: decoration,
              height: lineHeight,
              shadows: shadows,
            );
}
