FluoTheme.native constructor

FluoTheme.native({
  1. ThemeData? appTheme,
  2. Color? primaryColor,
  3. Color? inversePrimaryColor,
  4. Color? accentColor,
  5. EdgeInsets? screenPadding,
  6. ButtonStyle? connectButtonStyle,
  7. ButtonStyle? connectButtonStyleGoogle,
  8. ButtonStyle? connectButtonStyleApple,
  9. TextStyle? connectButtonTextStyle,
  10. TextStyle? connectButtonTextStyleGoogle,
  11. TextStyle? connectButtonTextStyleApple,
  12. double? connectButtonIconSize,
  13. Widget? connectButtonIconEmail,
  14. Widget? connectButtonIconMobile,
  15. Widget? connectButtonIconGoogle,
  16. Widget? connectButtonIconApple,
  17. TextStyle? legalTextStyle,
  18. EdgeInsets? legalTextPadding,
  19. TextStyle? modalTitleTextStyle,
  20. TextStyle? titleStyle,
  21. InputDecorationThemeData? inputDecorationTheme,
  22. TextStyle? inputTextStyle,
  23. TextStyle? inputErrorStyle,
  24. TextAlignVertical? inputTextAlignVertical,
  25. ButtonStyle? continueButtonStyle,
  26. Size? continueButtonProgressIndicatorSize,
  27. Color? continueButtonProgressIndicatorColor,
  28. double? continueButtonProgressIndicatorStrokeWidth,
  29. EdgeInsets? countryItemPadding,
  30. Color? countryItemHighlightColor,
  31. TextStyle? countryTextStyle,
  32. PinTheme? codeInputThemeDefault,
  33. PinTheme? codeInputThemeFocused,
  34. PinTheme? codeInputThemeSubmitted,
  35. PinTheme? codeInputThemeFollowing,
  36. PinTheme? codeInputThemeDisabled,
  37. PinTheme? codeInputThemeError,
})

Implementation

factory FluoTheme.native({
  ThemeData? appTheme,
  Color? primaryColor,
  Color? inversePrimaryColor,
  Color? accentColor,
  EdgeInsets? screenPadding,
  ButtonStyle? connectButtonStyle,
  ButtonStyle? connectButtonStyleGoogle,
  ButtonStyle? connectButtonStyleApple,
  TextStyle? connectButtonTextStyle,
  TextStyle? connectButtonTextStyleGoogle,
  TextStyle? connectButtonTextStyleApple,
  double? connectButtonIconSize,
  Widget? connectButtonIconEmail,
  Widget? connectButtonIconMobile,
  Widget? connectButtonIconGoogle,
  Widget? connectButtonIconApple,
  TextStyle? legalTextStyle,
  EdgeInsets? legalTextPadding,
  TextStyle? modalTitleTextStyle,
  TextStyle? titleStyle,
  InputDecorationThemeData? inputDecorationTheme,
  TextStyle? inputTextStyle,
  TextStyle? inputErrorStyle,
  TextAlignVertical? inputTextAlignVertical,
  ButtonStyle? continueButtonStyle,
  Size? continueButtonProgressIndicatorSize,
  Color? continueButtonProgressIndicatorColor,
  double? continueButtonProgressIndicatorStrokeWidth,
  EdgeInsets? countryItemPadding,
  Color? countryItemHighlightColor,
  TextStyle? countryTextStyle,
  PinTheme? codeInputThemeDefault,
  PinTheme? codeInputThemeFocused,
  PinTheme? codeInputThemeSubmitted,
  PinTheme? codeInputThemeFollowing,
  PinTheme? codeInputThemeDisabled,
  PinTheme? codeInputThemeError,
}) {
  primaryColor ??= appTheme?.colorScheme.primary ?? Colors.black;

  inversePrimaryColor ??=
      appTheme?.colorScheme.inversePrimary ?? Colors.white;

  accentColor ??= appTheme?.colorScheme.primary ?? Colors.black;

  screenPadding ??= const EdgeInsets.all(20.0);

  connectButtonStyle ??= appTheme?.filledButtonTheme.style ??
      ButtonStyle(
        splashFactory: NoSplash.splashFactory,
        backgroundColor: WidgetStateProperty.resolveWith((states) {
          return states.contains(WidgetState.pressed)
              ? Colors.grey.shade300
              : Colors.grey.shade200;
        }),
        foregroundColor: WidgetStateProperty.all(Colors.black),
        minimumSize: WidgetStateProperty.all(const Size.fromHeight(54)),
        mouseCursor: WidgetStateProperty.all(SystemMouseCursors.click),
        shape: WidgetStateProperty.all(RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
          side: BorderSide.none,
        )),
      );

  connectButtonStyleGoogle ??= connectButtonStyle;

  connectButtonStyleApple ??= connectButtonStyle.copyWith(
    backgroundColor: WidgetStateProperty.resolveWith((states) {
      return states.contains(WidgetState.pressed)
          ? Colors.black87
          : Colors.black;
    }),
  );

  connectButtonTextStyle ??= appTheme?.textTheme.titleMedium ??
      TextStyle(
        fontSize: 17,
        color: primaryColor,
        fontWeight: FontWeight.w600,
      );

  connectButtonTextStyleGoogle ??= connectButtonTextStyle;

  connectButtonTextStyleApple ??= connectButtonTextStyle.copyWith(
    color: Colors.white,
  );

  connectButtonIconSize ??= 20.0;

  connectButtonIconEmail ??= Icon(
    Icons.mail_outline_rounded,
    color: connectButtonTextStyle.color,
    size: connectButtonIconSize,
  );

  connectButtonIconMobile ??= Icon(
    Icons.phone_iphone_outlined,
    color: connectButtonTextStyle.color,
    size: connectButtonIconSize,
  );

  connectButtonIconGoogle ??= Image.asset(
    'packages/fluo/assets/images/google.png',
    width: connectButtonIconSize,
  );

  connectButtonIconApple ??= Image.asset(
    'packages/fluo/assets/images/apple.png',
    color: connectButtonTextStyleApple.color,
    width: connectButtonIconSize,
  );

  legalTextStyle ??= appTheme?.textTheme.bodySmall ??
      TextStyle(
        fontSize: 14,
        color: primaryColor.withAlpha(
          (255 * 0.6).toInt(),
        ),
      );

  legalTextPadding ??= const EdgeInsets.symmetric(
    vertical: 30.0,
    horizontal: 50.0,
  );

  modalTitleTextStyle ??= appTheme?.textTheme.titleMedium ??
      TextStyle(
        fontSize: 17,
        fontWeight: FontWeight.w600,
        color: primaryColor,
      );

  titleStyle ??= appTheme?.textTheme.headlineSmall ??
      TextStyle(
        fontSize: 20,
        fontWeight: FontWeight.w600,
        color: primaryColor,
      );

  inputTextStyle ??= appTheme?.textTheme.titleLarge ??
      const TextStyle(
        fontSize: 17,
        fontWeight: FontWeight.w600,
      );

  inputDecorationTheme ??= appTheme?.inputDecorationTheme.copyWith(
        hintStyle: appTheme.inputDecorationTheme.hintStyle ??
            inputTextStyle.copyWith(
              color: primaryColor.withAlpha(255 ~/ 3),
            ),
        suffixIconConstraints:
            appTheme.inputDecorationTheme.suffixIconConstraints ??
                const BoxConstraints(
                  maxHeight: 32,
                  maxWidth: 32 + 10 + 15,
                ),
      ) ??
      InputDecorationThemeData(
        fillColor: inversePrimaryColor.withAlpha(255 ~/ 2),
        filled: true,
        isDense: true,
        contentPadding: const EdgeInsets.symmetric(
          vertical: 15.0,
          horizontal: 20.0,
        ),
        hintStyle: inputTextStyle.copyWith(
          color: primaryColor.withAlpha(255 ~/ 3),
        ),
        border: const OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(8)),
        ),
        suffixIconConstraints: const BoxConstraints(
          maxHeight: 32,
          maxWidth: 32 + 10 + 15,
        ),
      );

  inputErrorStyle ??= appTheme?.inputDecorationTheme.errorStyle ??
      TextStyle(
        fontSize: 15,
        color: Colors.red.shade500,
      );

  inputTextAlignVertical ??= TextAlignVertical.center;

  continueButtonStyle ??= appTheme?.filledButtonTheme.style ??
      ButtonStyle(
        splashFactory: NoSplash.splashFactory,
        backgroundColor: WidgetStateProperty.resolveWith((states) {
          return states.contains(WidgetState.pressed)
              ? Colors.grey.shade300
              : Colors.grey.shade200;
        }),
        foregroundColor: WidgetStateProperty.resolveWith((states) {
          return states.contains(WidgetState.disabled)
              ? primaryColor?.withAlpha(255 ~/ 4)
              : primaryColor;
        }),
        textStyle: WidgetStateProperty.all(
          const TextStyle(
            fontSize: 17,
            fontWeight: FontWeight.w600,
          ),
        ),
        minimumSize: WidgetStateProperty.all(const Size.fromHeight(54)),
        mouseCursor: WidgetStateProperty.all(SystemMouseCursors.click),
        shape: WidgetStateProperty.all(RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
          side: BorderSide.none,
        )),
      );

  final focusedState = <WidgetState>{WidgetState.focused};
  final textStyle = continueButtonStyle.textStyle?.resolve(focusedState);
  final fontSize = textStyle?.fontSize ?? 17;
  continueButtonProgressIndicatorSize ??= Size(fontSize, fontSize);

  final textColor =
      continueButtonStyle.foregroundColor?.resolve(focusedState);
  continueButtonProgressIndicatorColor ??= textColor ?? Colors.black;

  continueButtonProgressIndicatorStrokeWidth ??= 2.0;

  countryItemPadding ??= const EdgeInsets.symmetric(
    horizontal: 20.0,
    vertical: 15.0,
  );

  countryItemHighlightColor ??= primaryColor.withAlpha(255 ~/ 16);

  countryTextStyle ??= const TextStyle(
    fontSize: 17,
    fontWeight: FontWeight.w600,
  );

  codeInputThemeDefault ??= PinTheme(
    width: 54.0,
    height: 64.0,
    textStyle: const TextStyle(
      fontSize: 30.0,
      fontWeight: FontWeight.w600,
    ),
    decoration: BoxDecoration(
      border: Border.all(
        width: 1.5,
        color: primaryColor,
      ),
      borderRadius: BorderRadius.circular(10.0),
    ),
  );

  codeInputThemeFocused ??= codeInputThemeDefault.copyDecorationWith(
    border: Border.all(
      width: 2,
      color: primaryColor,
    ),
  );

  codeInputThemeFollowing ??= codeInputThemeDefault.copyDecorationWith(
    border: Border.all(
      width: 1.5,
      color: primaryColor,
    ),
  );

  return FluoTheme._(
    primaryColor,
    inversePrimaryColor,
    accentColor,
    screenPadding,
    connectButtonStyle,
    connectButtonStyleGoogle,
    connectButtonStyleApple,
    connectButtonTextStyle,
    connectButtonTextStyleGoogle,
    connectButtonTextStyleApple,
    connectButtonIconSize,
    connectButtonIconEmail,
    connectButtonIconMobile,
    connectButtonIconGoogle,
    connectButtonIconApple,
    legalTextStyle,
    legalTextPadding,
    modalTitleTextStyle,
    titleStyle,
    inputDecorationTheme,
    inputTextStyle,
    inputErrorStyle,
    inputTextAlignVertical,
    continueButtonStyle,
    continueButtonProgressIndicatorSize,
    continueButtonProgressIndicatorColor,
    continueButtonProgressIndicatorStrokeWidth,
    countryItemPadding,
    countryItemHighlightColor,
    countryTextStyle,
    codeInputThemeDefault,
    codeInputThemeFocused,
    codeInputThemeSubmitted,
    codeInputThemeFollowing,
    codeInputThemeDisabled,
    codeInputThemeError,
  );
}