|
| 1 | +import 'package:catalog/theme/app_text_styles.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:catalog/theme/app_colors.dart'; |
| 5 | + |
| 6 | +typedef StrokeButton = OutlinedButton; |
| 7 | +typedef GhostButton = TextButton; |
| 8 | + |
| 9 | +class AppButtonsStyle { |
| 10 | + final ButtonStyle filledButton = _appFilledButton; |
| 11 | + final ButtonStyle outlineButton = _appOutlineButton; |
| 12 | + final ButtonStyle textButton = _appTextButton; |
| 13 | + final ButtonStyle secondaryFilledButton = _appSecondaryFilledButton; |
| 14 | + final ButtonStyle secondaryOutlineButton = _appSecondaryOutlineButton; |
| 15 | + final ButtonStyle secondaryTextButton = _appSecondaryTextButton; |
| 16 | + |
| 17 | + AppButtonsStyle(); |
| 18 | + |
| 19 | + static AppButtonsStyle getButtonTheme() => AppButtonsStyle(); |
| 20 | +} |
| 21 | + |
| 22 | +final _appFilledButton = FilledButton.styleFrom( |
| 23 | + minimumSize: Size(double.infinity, 50.h), |
| 24 | + shape: RoundedRectangleBorder( |
| 25 | + borderRadius: BorderRadius.circular(16.r), |
| 26 | + ), |
| 27 | + textStyle: AppTextStyles.getAppStyles().buttonLarge, |
| 28 | + elevation: 0.0, |
| 29 | + foregroundColor: AppColors.getColorScheme().textColor.shade100, |
| 30 | +); |
| 31 | + |
| 32 | +final _appOutlineButton = OutlinedButton.styleFrom( |
| 33 | + minimumSize: Size(double.infinity, 50.h), |
| 34 | + shape: RoundedRectangleBorder( |
| 35 | + borderRadius: BorderRadius.circular(16.r), |
| 36 | + ), |
| 37 | + side: BorderSide( |
| 38 | + width: 2, |
| 39 | + color: AppColors.getColorScheme().primary, |
| 40 | + ), |
| 41 | + textStyle: AppTextStyles.getAppStyles().buttonLarge, |
| 42 | + elevation: 0.0, |
| 43 | +); |
| 44 | + |
| 45 | +final _appTextButton = TextButton.styleFrom( |
| 46 | + minimumSize: Size(double.infinity, 50.h), |
| 47 | + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.r)), |
| 48 | + textStyle: AppTextStyles.getAppStyles().buttonLarge, |
| 49 | + elevation: 0.0, |
| 50 | +); |
| 51 | + |
| 52 | +final _appSecondaryFilledButton = _appFilledButton.copyWith( |
| 53 | + backgroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 54 | + (Set<MaterialState> states) { |
| 55 | + if (states.contains(MaterialState.pressed)) { |
| 56 | + return AppColors.getColorScheme().textColor.shade500; |
| 57 | + } |
| 58 | + if (states.contains(MaterialState.disabled)) { |
| 59 | + return AppColors.getColorScheme().surface.shade500; |
| 60 | + } |
| 61 | + if (states.contains(MaterialState.hovered)) { |
| 62 | + return AppColors.getColorScheme().onSurface.shade400; |
| 63 | + } |
| 64 | + if (states.contains(MaterialState.focused)) { |
| 65 | + return AppColors.getColorScheme().textColor.shade400; |
| 66 | + } |
| 67 | + return AppColors.getColorScheme().textColor.shade300; |
| 68 | + }, |
| 69 | + ), |
| 70 | + foregroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 71 | + (Set<MaterialState> states) => |
| 72 | + AppColors.getColorScheme().textColor.shade100, |
| 73 | + ), |
| 74 | +); |
| 75 | + |
| 76 | +final _appSecondaryOutlineButton = _appOutlineButton.copyWith( |
| 77 | + backgroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 78 | + (Set<MaterialState> states) { |
| 79 | + if (states.contains(MaterialState.pressed)) { |
| 80 | + return AppColors.getColorScheme().surface.shade400; |
| 81 | + } |
| 82 | + if (states.contains(MaterialState.disabled)) { |
| 83 | + return AppColors.getColorScheme().surface.shade500; |
| 84 | + } |
| 85 | + if (states.contains(MaterialState.hovered)) { |
| 86 | + return AppColors.getColorScheme().surface.shade300; |
| 87 | + } |
| 88 | + if (states.contains(MaterialState.focused)) { |
| 89 | + return AppColors.getColorScheme().surface.shade300; |
| 90 | + } |
| 91 | + return Colors.transparent; |
| 92 | + }, |
| 93 | + ), |
| 94 | + foregroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 95 | + (Set<MaterialState> states) { |
| 96 | + if (states.contains(MaterialState.pressed)) { |
| 97 | + return AppColors.getColorScheme().textColor.shade500; |
| 98 | + } |
| 99 | + return AppColors.getColorScheme().textColor.shade300; |
| 100 | + }, |
| 101 | + ), |
| 102 | + side: MaterialStateProperty.resolveWith<BorderSide?>( |
| 103 | + (Set<MaterialState> states) => BorderSide( |
| 104 | + color: AppColors.getColorScheme().textColor.shade300, |
| 105 | + ), |
| 106 | + ), |
| 107 | +); |
| 108 | + |
| 109 | +final _appSecondaryTextButton = _appTextButton.copyWith( |
| 110 | + backgroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 111 | + (Set<MaterialState> states) { |
| 112 | + if (states.contains(MaterialState.pressed)) { |
| 113 | + return AppColors.getColorScheme().surface.shade300; |
| 114 | + } |
| 115 | + if (states.contains(MaterialState.disabled)) { |
| 116 | + return AppColors.getColorScheme().surface.shade500; |
| 117 | + } |
| 118 | + if (states.contains(MaterialState.hovered)) { |
| 119 | + return AppColors.getColorScheme().surface.shade200; |
| 120 | + } |
| 121 | + if (states.contains(MaterialState.focused)) { |
| 122 | + return AppColors.getColorScheme().surface.shade200; |
| 123 | + } |
| 124 | + return Colors.transparent; |
| 125 | + }, |
| 126 | + ), |
| 127 | + foregroundColor: MaterialStateProperty.resolveWith<Color?>( |
| 128 | + (Set<MaterialState> states) { |
| 129 | + if (states.contains(MaterialState.pressed)) { |
| 130 | + return AppColors.getColorScheme().textColor.shade500; |
| 131 | + } |
| 132 | + return AppColors.getColorScheme().textColor.shade300; |
| 133 | + }, |
| 134 | + ), |
| 135 | +); |
0 commit comments