theme_config.dart 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ftrecruiter/comm/constants/color_constants.dart';
  4. class ThemeConfig {
  5. static ThemeData createTheme({
  6. required Brightness brightness,
  7. required Color background,
  8. required Color primaryText,
  9. Color? secondaryText,
  10. required Color accentColor,
  11. Color? divider,
  12. Color? buttonBackground,
  13. required Color buttonText,
  14. Color? cardBackground,
  15. Color? disabled,
  16. required Color error,
  17. }) {
  18. final baseTextTheme = brightness == Brightness.dark
  19. ? Typography.blackMountainView
  20. : Typography.whiteMountainView;
  21. return ThemeData(
  22. brightness: brightness,
  23. buttonColor: buttonBackground,
  24. canvasColor: background,
  25. cardColor: background,
  26. dividerColor: divider,
  27. dividerTheme: DividerThemeData(
  28. color: divider,
  29. space: 1,
  30. thickness: 1,
  31. ),
  32. cardTheme: CardTheme(
  33. color: cardBackground,
  34. margin: EdgeInsets.zero,
  35. clipBehavior: Clip.antiAliasWithSaveLayer,
  36. ),
  37. backgroundColor: background,
  38. primaryColor: accentColor,
  39. accentColor: accentColor,
  40. // textSelectionColor: accentColor,
  41. // textSelectionHandleColor: accentColor,
  42. // cursorColor: accentColor,
  43. textSelectionTheme: TextSelectionThemeData(
  44. selectionColor: accentColor,
  45. selectionHandleColor: accentColor,
  46. cursorColor: accentColor,
  47. ),
  48. toggleableActiveColor: accentColor,
  49. appBarTheme: AppBarTheme(
  50. brightness: brightness,
  51. color: cardBackground,
  52. textTheme: TextTheme(
  53. bodyText1: baseTextTheme.bodyText1!.copyWith(
  54. color: secondaryText,
  55. fontSize: 18,
  56. ),
  57. ),
  58. titleTextStyle: TextStyle(
  59. color: secondaryText,
  60. fontSize: 18,
  61. ),
  62. iconTheme: IconThemeData(
  63. color: secondaryText,
  64. ),
  65. ),
  66. iconTheme: IconThemeData(
  67. color: secondaryText,
  68. size: 16.0,
  69. ),
  70. errorColor: error,
  71. buttonTheme: ButtonThemeData(
  72. textTheme: ButtonTextTheme.primary,
  73. colorScheme: ColorScheme(
  74. brightness: brightness,
  75. primary: accentColor,
  76. primaryVariant: accentColor,
  77. secondary: accentColor,
  78. secondaryVariant: accentColor,
  79. surface: background,
  80. background: background,
  81. error: error,
  82. onPrimary: buttonText,
  83. onSecondary: buttonText,
  84. onSurface: buttonText,
  85. onBackground: buttonText,
  86. onError: buttonText,
  87. ),
  88. padding: const EdgeInsets.all(16.0),
  89. ),
  90. cupertinoOverrideTheme: CupertinoThemeData(
  91. brightness: brightness,
  92. primaryColor: accentColor,
  93. ),
  94. inputDecorationTheme: InputDecorationTheme(
  95. errorStyle: TextStyle(color: error),
  96. labelStyle: TextStyle(
  97. fontFamily: 'Rubik',
  98. fontWeight: FontWeight.w600,
  99. fontSize: 16.0,
  100. color: primaryText.withOpacity(0.5),
  101. ),
  102. hintStyle: TextStyle(
  103. color: secondaryText,
  104. fontSize: 13.0,
  105. fontWeight: FontWeight.w300,
  106. ),
  107. ),
  108. unselectedWidgetColor: hexToColor('#DADCDD'),
  109. textTheme: TextTheme(
  110. headline1: baseTextTheme.headline1!.copyWith(
  111. color: primaryText,
  112. fontSize: 34.0,
  113. fontWeight: FontWeight.bold,
  114. ),
  115. headline2: baseTextTheme.headline2!.copyWith(
  116. color: primaryText,
  117. fontSize: 22,
  118. fontWeight: FontWeight.bold,
  119. ),
  120. headline3: baseTextTheme.headline3!.copyWith(
  121. color: secondaryText,
  122. fontSize: 20,
  123. fontWeight: FontWeight.w600,
  124. ),
  125. headline4: baseTextTheme.headline4!.copyWith(
  126. color: primaryText,
  127. fontSize: 18,
  128. fontWeight: FontWeight.w600,
  129. ),
  130. headline5: baseTextTheme.headline5!.copyWith(
  131. color: primaryText,
  132. fontSize: 16,
  133. fontWeight: FontWeight.w700,
  134. ),
  135. headline6: baseTextTheme.headline6!.copyWith(
  136. color: primaryText,
  137. fontSize: 14,
  138. fontWeight: FontWeight.w700,
  139. ),
  140. bodyText1: baseTextTheme.bodyText1!.copyWith(
  141. color: secondaryText,
  142. fontSize: 15,
  143. ),
  144. bodyText2: baseTextTheme.bodyText2!.copyWith(
  145. color: primaryText,
  146. fontSize: 12,
  147. fontWeight: FontWeight.w400,
  148. ),
  149. button: baseTextTheme.button!.copyWith(
  150. color: primaryText,
  151. fontSize: 12.0,
  152. fontWeight: FontWeight.w700,
  153. ),
  154. caption: baseTextTheme.caption!.copyWith(
  155. color: primaryText,
  156. fontSize: 11.0,
  157. fontWeight: FontWeight.w300,
  158. ),
  159. overline: baseTextTheme.overline!.copyWith(
  160. color: secondaryText,
  161. fontSize: 11.0,
  162. fontWeight: FontWeight.w500,
  163. ),
  164. subtitle1: baseTextTheme.subtitle1!.copyWith(
  165. color: primaryText,
  166. fontSize: 16.0,
  167. fontWeight: FontWeight.w700,
  168. ),
  169. subtitle2: baseTextTheme.subtitle2!.copyWith(
  170. color: secondaryText,
  171. fontSize: 11.0,
  172. fontWeight: FontWeight.w500,
  173. ),
  174. ),
  175. );
  176. }
  177. static ThemeData get lightTheme => createTheme(
  178. brightness: Brightness.light,
  179. background: ColorConstants.lightScaffoldBackgroundColor,
  180. cardBackground: ColorConstants.secondaryAppColor,
  181. primaryText: Colors.black,
  182. secondaryText: Colors.black,
  183. accentColor: ColorConstants.secondaryAppColor,
  184. divider: ColorConstants.secondaryAppColor,
  185. buttonBackground: Colors.black38,
  186. buttonText: ColorConstants.secondaryAppColor,
  187. disabled: ColorConstants.secondaryAppColor,
  188. error: Colors.red,
  189. );
  190. static ThemeData get darkTheme => createTheme(
  191. brightness: Brightness.dark,
  192. background: ColorConstants.darkScaffoldBackgroundColor,
  193. cardBackground: ColorConstants.secondaryDarkAppColor,
  194. primaryText: Colors.white,
  195. secondaryText: Colors.white,
  196. accentColor: ColorConstants.secondaryDarkAppColor,
  197. divider: Colors.black45,
  198. buttonBackground: Colors.white,
  199. buttonText: ColorConstants.secondaryDarkAppColor,
  200. disabled: ColorConstants.secondaryDarkAppColor,
  201. error: Colors.red,
  202. );
  203. }