2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
static TextStyle textStyle({Color? textColor, double? fontSize,FontWeight? fontWeight}) => TextStyle(
|
2023-07-10 17:50:31 +08:00
|
|
|
fontSize: fontSize ?? 18.sp,
|
|
|
|
|
color: textColor ?? AppColors.buttonEnableTextColor,
|
|
|
|
|
fontWeight: fontWeight ?? FontWeight.normal,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
///textButtonStyle
|
|
|
|
|
static ButtonStyle get textButtonStyle => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
///textButtonDeleteStyle
|
|
|
|
|
static ButtonStyle get textButtonDeleteStyle => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.deleteBtnBgColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//textButtonStyle2
|
|
|
|
|
static ButtonStyle get textButtonStyle2 => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize2),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle(fontSize: 11.sp);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
static ButtonStyle get textButtonStyleOthers => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle(textColor: AppColors.buttonEnableColor);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
static ButtonStyle get specialButtonStyle => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize3),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.deleteBtnBgColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle(textColor: AppColors.buttonEnableColor);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
static ButtonStyle clearTextButtonStyle({Color? textColor, Color? bgColor, double? fontSize, FontWeight? fontWeight}) => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
2023-07-10 17:50:31 +08:00
|
|
|
bgColor ??= AppColors.normalTextColor;
|
2024-10-15 14:24:35 +08:00
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return bgColor?.withOpacity(0.6);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return bgColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
2023-07-10 17:50:31 +08:00
|
|
|
textColor ??= AppColors.buttonEnableColor;
|
2024-10-15 14:24:35 +08:00
|
|
|
if(states.contains(MaterialState.pressed)) {
|
|
|
|
|
return textColor?.withOpacity(0.1);
|
|
|
|
|
}
|
2023-07-15 15:11:28 +08:00
|
|
|
return textColor?.withOpacity(0.1);
|
2023-07-10 17:50:31 +08:00
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
2023-07-10 17:50:31 +08:00
|
|
|
textColor ??= AppColors.buttonEnableColor;
|
2024-10-15 14:24:35 +08:00
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textColor?.withOpacity(0.4);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
///elevatedButtonButtonStyle
|
|
|
|
|
static ButtonStyle get elevatedButtonButtonStyle => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
///outlinedButtonButtonStyle
|
|
|
|
|
static ButtonStyle get outlinedButtonButtonStyle => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///outlinedButtonButtonStyle2
|
|
|
|
|
static ButtonStyle get outlinedButtonButtonStyle2_Selected => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
|
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
|
|
|
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableColor;
|
|
|
|
|
}),
|
2024-10-15 14:24:35 +08:00
|
|
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
|
|
|
|
if(states.contains(MaterialState.disabled)) {
|
|
|
|
|
return AppColors.buttonDisableTextColor;
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
return AppColors.buttonEnableTextColor;
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
///outlinedButtonButtonStyle2_Selected
|
|
|
|
|
static ButtonStyle get outlinedButtonButtonStyle2 => ButtonStyle(
|
2024-10-15 14:24:35 +08:00
|
|
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
2023-07-10 17:50:31 +08:00
|
|
|
side: MaterialStateProperty.all(BorderSide(
|
|
|
|
|
width: 1.w,
|
|
|
|
|
color: AppColors.buttonEnableColor.withOpacity(0.5),
|
|
|
|
|
style: BorderStyle.solid,
|
|
|
|
|
)),
|
|
|
|
|
backgroundColor: MaterialStateProperty.all(Colors.transparent),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
static TextStyle appTextStyle({
|
2023-07-15 15:11:28 +08:00
|
|
|
Color? textColor,
|
|
|
|
|
double? fontSize,
|
2023-07-10 17:50:31 +08:00
|
|
|
}) => 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
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|