import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'app_colors.dart'; class AppStyle { static RoundedRectangleBorder get buttonShape_16 => RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0.h), ); static RoundedRectangleBorder get buttonShape_11 => RoundedRectangleBorder( borderRadius: BorderRadius.circular(11.0.h), ); static Size get btnMinSize => Size(100.w, 60.h); static Size get btnMinSize2 => Size(60.w, 44.h); static Size get btnMinSize3 => Size(60.w, 53.h); static TextStyle textStyle({Color? textColor, double? fontSize,FontWeight? fontWeight}) => TextStyle( fontSize: fontSize ?? 18.sp, color: textColor ?? AppColors.buttonEnableTextColor, fontWeight: fontWeight ?? FontWeight.normal, ); ///textButtonStyle static ButtonStyle get textButtonStyle => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(textColor: AppColors.buttonDisableColor); } return textStyle(); }) ); ///textButtonDeleteStyle static ButtonStyle get textButtonDeleteStyle => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.deleteBtnBgColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(textColor: AppColors.buttonDisableColor); } return textStyle(); }) ); //textButtonStyle2 static ButtonStyle get textButtonStyle2 => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize2), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp); } return textStyle(fontSize: 11.sp); }) ); static ButtonStyle get textButtonStyleOthers => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(textColor: AppColors.buttonDisableColor); } return textStyle(textColor: AppColors.buttonEnableColor); }) ); static ButtonStyle get specialButtonStyle => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize3), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.deleteBtnBgColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableTextColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(textColor: AppColors.buttonDisableColor); } return textStyle(textColor: AppColors.buttonEnableColor); }) ); static ButtonStyle clearTextButtonStyle({Color? textColor, Color? bgColor, double? fontSize, FontWeight? fontWeight}) => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ bgColor ??= AppColors.normalTextColor; if(states.contains(MaterialState.disabled)) { return bgColor?.withOpacity(0.6); } return bgColor; }), overlayColor: MaterialStateProperty.resolveWith((Set states){ textColor ??= AppColors.buttonEnableColor; if(states.contains(MaterialState.pressed)) { return textColor?.withOpacity(0.1); } return textColor?.withOpacity(0.1); }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ textColor ??= AppColors.buttonEnableColor; if(states.contains(MaterialState.disabled)) { return textColor?.withOpacity(0.4); } return textColor; }), textStyle: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return textStyle(fontSize: fontSize,fontWeight: fontWeight); } return textStyle(fontSize: fontSize,fontWeight: fontWeight); }), ); ///elevatedButtonButtonStyle static ButtonStyle get elevatedButtonButtonStyle => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), ); ///outlinedButtonButtonStyle static ButtonStyle get outlinedButtonButtonStyle => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), ); ///outlinedButtonButtonStyle2 static ButtonStyle get outlinedButtonButtonStyle2_Selected => ButtonStyle( minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), backgroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableColor; } return AppColors.buttonEnableColor; }), foregroundColor: MaterialStateProperty.resolveWith((Set states){ if(states.contains(MaterialState.disabled)) { return AppColors.buttonDisableTextColor; } return AppColors.buttonEnableTextColor; }), ); ///outlinedButtonButtonStyle2_Selected static ButtonStyle get outlinedButtonButtonStyle2 => ButtonStyle( shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), side: MaterialStateProperty.all(BorderSide( width: 1.w, color: AppColors.buttonEnableColor.withOpacity(0.5), style: BorderStyle.solid, )), backgroundColor: MaterialStateProperty.all(Colors.transparent), ); static TextStyle appTextStyle({ Color? textColor, double? fontSize, }) => AppStyle.textStyle( textColor: textColor, fontSize: fontSize, ); static InputBorder get textFieldEnableBorder => UnderlineInputBorder( borderSide: BorderSide( color: AppColors.textFieldEnableBorderColor, width: 1.w, style: BorderStyle.solid ), ); static TextStyle get textFieldTextStyle => appTextStyle( textColor: AppColors.textFieldTextColor, fontSize: 16.sp, ); static TextStyle get textFieldHintTextStyle => appTextStyle( textColor: AppColors.textFieldHintTextColor, fontSize: 12.sp, ); static InputBorder get textFieldFocusBorder => UnderlineInputBorder( borderSide: BorderSide( color: AppColors.textFieldFocusBorderColor, width: 1.w, style: BorderStyle.solid ), ); }