ix_styles.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'dark_theme_colors.dart';
  4. import 'ix_fonts.dart';
  5. import 'light_theme_colors.dart';
  6. class IXStyles {
  7. ///icons theme
  8. static IconThemeData getIconTheme({required bool isLightTheme}) =>
  9. IconThemeData(
  10. color: isLightTheme
  11. ? LightThemeColors.iconColor
  12. : DarkThemeColors.iconColor,
  13. );
  14. ///app bar theme
  15. static AppBarTheme getAppBarTheme({required bool isLightTheme}) =>
  16. AppBarTheme(
  17. elevation: 0,
  18. titleTextStyle: getTextTheme(isLightTheme: isLightTheme).bodyMedium!
  19. .copyWith(color: Colors.white, fontSize: MyFonts.appBarTittleSize),
  20. iconTheme: IconThemeData(
  21. color: isLightTheme
  22. ? LightThemeColors.appBarIconsColor
  23. : DarkThemeColors.appBarIconsColor,
  24. ),
  25. backgroundColor: isLightTheme
  26. ? LightThemeColors.backgroundColor
  27. : DarkThemeColors.backgroundColor,
  28. );
  29. ///text theme
  30. static TextTheme getTextTheme({required bool isLightTheme}) => TextTheme(
  31. labelLarge: MyFonts.buttonTextStyle.copyWith(
  32. fontSize: MyFonts.buttonTextSize,
  33. ),
  34. bodyLarge: (MyFonts.bodyTextStyle).copyWith(
  35. fontWeight: FontWeight.bold,
  36. fontSize: MyFonts.bodyLargeSize,
  37. color: isLightTheme
  38. ? LightThemeColors.bodyTextColor
  39. : DarkThemeColors.bodyTextColor,
  40. ),
  41. bodyMedium: (MyFonts.bodyTextStyle).copyWith(
  42. fontSize: MyFonts.bodyMediumSize,
  43. color: isLightTheme
  44. ? LightThemeColors.bodyTextColor
  45. : DarkThemeColors.bodyTextColor,
  46. ),
  47. displayLarge: (MyFonts.displayTextStyle).copyWith(
  48. fontSize: MyFonts.displayLargeSize,
  49. fontWeight: FontWeight.bold,
  50. color: isLightTheme
  51. ? LightThemeColors.displayTextColor
  52. : DarkThemeColors.displayTextColor,
  53. ),
  54. bodySmall: TextStyle(
  55. color: isLightTheme
  56. ? LightThemeColors.bodySmallTextColor
  57. : DarkThemeColors.bodySmallTextColor,
  58. fontSize: MyFonts.bodySmallTextSize,
  59. ),
  60. displayMedium: (MyFonts.displayTextStyle).copyWith(
  61. fontSize: MyFonts.displayMediumSize,
  62. fontWeight: FontWeight.bold,
  63. color: isLightTheme
  64. ? LightThemeColors.displayTextColor
  65. : DarkThemeColors.displayTextColor,
  66. ),
  67. displaySmall: (MyFonts.displayTextStyle).copyWith(
  68. fontSize: MyFonts.displaySmallSize,
  69. fontWeight: FontWeight.bold,
  70. color: isLightTheme
  71. ? LightThemeColors.displayTextColor
  72. : DarkThemeColors.displayTextColor,
  73. ),
  74. );
  75. static ChipThemeData getChipTheme({required bool isLightTheme}) {
  76. return ChipThemeData(
  77. backgroundColor: isLightTheme
  78. ? LightThemeColors.chipBackground
  79. : DarkThemeColors.chipBackground,
  80. brightness: Brightness.light,
  81. labelStyle: getChipTextStyle(isLightTheme: isLightTheme),
  82. secondaryLabelStyle: getChipTextStyle(isLightTheme: isLightTheme),
  83. selectedColor: Colors.black,
  84. disabledColor: Colors.green,
  85. padding: const EdgeInsets.all(5),
  86. secondarySelectedColor: Colors.purple,
  87. );
  88. }
  89. ///Chips text style
  90. static TextStyle getChipTextStyle({required bool isLightTheme}) {
  91. return MyFonts.chipTextStyle.copyWith(
  92. fontSize: MyFonts.chipTextSize,
  93. color: isLightTheme
  94. ? LightThemeColors.chipTextColor
  95. : DarkThemeColors.chipTextColor,
  96. );
  97. }
  98. // elevated button text style
  99. static WidgetStateProperty<TextStyle?>? getElevatedButtonTextStyle(
  100. bool isLightTheme, {
  101. bool isBold = true,
  102. double? fontSize,
  103. }) {
  104. return WidgetStateProperty.resolveWith<TextStyle>((
  105. Set<WidgetState> states,
  106. ) {
  107. if (states.contains(WidgetState.pressed)) {
  108. return MyFonts.buttonTextStyle.copyWith(
  109. fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
  110. fontSize: fontSize ?? MyFonts.buttonTextSize,
  111. color: isLightTheme
  112. ? LightThemeColors.buttonTextColor
  113. : DarkThemeColors.buttonTextColor,
  114. );
  115. } else if (states.contains(WidgetState.disabled)) {
  116. return MyFonts.buttonTextStyle.copyWith(
  117. fontSize: fontSize ?? MyFonts.buttonTextSize,
  118. fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
  119. color: isLightTheme
  120. ? LightThemeColors.buttonDisabledTextColor
  121. : DarkThemeColors.buttonDisabledTextColor,
  122. );
  123. }
  124. return MyFonts.buttonTextStyle.copyWith(
  125. fontSize: fontSize ?? MyFonts.buttonTextSize,
  126. fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
  127. color: isLightTheme
  128. ? LightThemeColors.buttonTextColor
  129. : DarkThemeColors.buttonTextColor,
  130. ); // Use the component's default.
  131. });
  132. }
  133. //elevated button theme data
  134. static ElevatedButtonThemeData getElevatedButtonTheme({
  135. required bool isLightTheme,
  136. }) => ElevatedButtonThemeData(
  137. style: ButtonStyle(
  138. shape: WidgetStateProperty.all<RoundedRectangleBorder>(
  139. RoundedRectangleBorder(
  140. borderRadius: BorderRadius.circular(6.r),
  141. //side: BorderSide(color: Colors.teal, width: 2.0),
  142. ),
  143. ),
  144. elevation: WidgetStateProperty.all(0),
  145. padding: WidgetStateProperty.all<EdgeInsetsGeometry>(
  146. EdgeInsets.symmetric(vertical: 8.w),
  147. ),
  148. textStyle: getElevatedButtonTextStyle(isLightTheme),
  149. backgroundColor: WidgetStateProperty.resolveWith<Color>((
  150. Set<WidgetState> states,
  151. ) {
  152. if (states.contains(WidgetState.pressed)) {
  153. return isLightTheme
  154. ? LightThemeColors.buttonColor.withValues(alpha: 0.5)
  155. : DarkThemeColors.buttonColor.withValues(alpha: 0.5);
  156. } else if (states.contains(WidgetState.disabled)) {
  157. return isLightTheme
  158. ? LightThemeColors.buttonDisabledColor
  159. : DarkThemeColors.buttonDisabledColor;
  160. }
  161. return isLightTheme
  162. ? LightThemeColors.buttonColor
  163. : DarkThemeColors.buttonColor; // Use the component's default.
  164. }),
  165. ),
  166. );
  167. /// list tile theme data
  168. static ListTileThemeData getListTileThemeData({required bool isLightTheme}) {
  169. return ListTileThemeData(
  170. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
  171. iconColor: isLightTheme
  172. ? LightThemeColors.listTileIconColor
  173. : DarkThemeColors.listTileIconColor,
  174. tileColor: isLightTheme
  175. ? LightThemeColors.listTileBackgroundColor
  176. : DarkThemeColors.listTileBackgroundColor,
  177. titleTextStyle: TextStyle(
  178. fontSize: MyFonts.listTileTitleSize,
  179. color: isLightTheme
  180. ? LightThemeColors.listTileTitleColor
  181. : DarkThemeColors.listTileTitleColor,
  182. ),
  183. subtitleTextStyle: TextStyle(
  184. fontSize: MyFonts.listTileSubtitleSize,
  185. color: isLightTheme
  186. ? LightThemeColors.listTileSubtitleColor
  187. : DarkThemeColors.listTileSubtitleColor,
  188. ),
  189. );
  190. }
  191. }