flutter_flow_theme.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. // ignore_for_file: overridden_fields, annotate_overrides
  2. import 'package:flutter/material.dart';
  3. import 'package:google_fonts/google_fonts.dart';
  4. import 'package:shared_preferences/shared_preferences.dart';
  5. const kThemeModeKey = '__theme_mode__';
  6. SharedPreferences? _prefs;
  7. abstract class FlutterFlowTheme {
  8. static Future initialize() async =>
  9. _prefs = await SharedPreferences.getInstance();
  10. static ThemeMode get themeMode {
  11. final darkMode = _prefs?.getBool(kThemeModeKey);
  12. return darkMode == null
  13. ? ThemeMode.system
  14. : darkMode
  15. ? ThemeMode.dark
  16. : ThemeMode.light;
  17. }
  18. static void saveThemeMode(ThemeMode mode) => mode == ThemeMode.system
  19. ? _prefs?.remove(kThemeModeKey)
  20. : _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark);
  21. static FlutterFlowTheme of(BuildContext context) {
  22. return Theme.of(context).brightness == Brightness.dark
  23. ? DarkModeTheme()
  24. : LightModeTheme();
  25. }
  26. @Deprecated('Use primary instead')
  27. Color get primaryColor => primary;
  28. @Deprecated('Use secondary instead')
  29. Color get secondaryColor => secondary;
  30. @Deprecated('Use tertiary instead')
  31. Color get tertiaryColor => tertiary;
  32. late Color primary;
  33. late Color secondary;
  34. late Color tertiary;
  35. late Color alternate;
  36. late Color primaryText;
  37. late Color secondaryText;
  38. late Color primaryBackground;
  39. late Color secondaryBackground;
  40. late Color accent1;
  41. late Color accent2;
  42. late Color accent3;
  43. late Color accent4;
  44. late Color success;
  45. late Color warning;
  46. late Color error;
  47. late Color info;
  48. FFDesignTokens get designToken => FFDesignTokens(this);
  49. @Deprecated('Use displaySmallFamily instead')
  50. String get title1Family => displaySmallFamily;
  51. @Deprecated('Use displaySmall instead')
  52. TextStyle get title1 => typography.displaySmall;
  53. @Deprecated('Use headlineMediumFamily instead')
  54. String get title2Family => typography.headlineMediumFamily;
  55. @Deprecated('Use headlineMedium instead')
  56. TextStyle get title2 => typography.headlineMedium;
  57. @Deprecated('Use headlineSmallFamily instead')
  58. String get title3Family => typography.headlineSmallFamily;
  59. @Deprecated('Use headlineSmall instead')
  60. TextStyle get title3 => typography.headlineSmall;
  61. @Deprecated('Use titleMediumFamily instead')
  62. String get subtitle1Family => typography.titleMediumFamily;
  63. @Deprecated('Use titleMedium instead')
  64. TextStyle get subtitle1 => typography.titleMedium;
  65. @Deprecated('Use titleSmallFamily instead')
  66. String get subtitle2Family => typography.titleSmallFamily;
  67. @Deprecated('Use titleSmall instead')
  68. TextStyle get subtitle2 => typography.titleSmall;
  69. @Deprecated('Use bodyMediumFamily instead')
  70. String get bodyText1Family => typography.bodyMediumFamily;
  71. @Deprecated('Use bodyMedium instead')
  72. TextStyle get bodyText1 => typography.bodyMedium;
  73. @Deprecated('Use bodySmallFamily instead')
  74. String get bodyText2Family => typography.bodySmallFamily;
  75. @Deprecated('Use bodySmall instead')
  76. TextStyle get bodyText2 => typography.bodySmall;
  77. String get displayLargeFamily => typography.displayLargeFamily;
  78. bool get displayLargeIsCustom => typography.displayLargeIsCustom;
  79. TextStyle get displayLarge => typography.displayLarge;
  80. String get displayMediumFamily => typography.displayMediumFamily;
  81. bool get displayMediumIsCustom => typography.displayMediumIsCustom;
  82. TextStyle get displayMedium => typography.displayMedium;
  83. String get displaySmallFamily => typography.displaySmallFamily;
  84. bool get displaySmallIsCustom => typography.displaySmallIsCustom;
  85. TextStyle get displaySmall => typography.displaySmall;
  86. String get headlineLargeFamily => typography.headlineLargeFamily;
  87. bool get headlineLargeIsCustom => typography.headlineLargeIsCustom;
  88. TextStyle get headlineLarge => typography.headlineLarge;
  89. String get headlineMediumFamily => typography.headlineMediumFamily;
  90. bool get headlineMediumIsCustom => typography.headlineMediumIsCustom;
  91. TextStyle get headlineMedium => typography.headlineMedium;
  92. String get headlineSmallFamily => typography.headlineSmallFamily;
  93. bool get headlineSmallIsCustom => typography.headlineSmallIsCustom;
  94. TextStyle get headlineSmall => typography.headlineSmall;
  95. String get titleLargeFamily => typography.titleLargeFamily;
  96. bool get titleLargeIsCustom => typography.titleLargeIsCustom;
  97. TextStyle get titleLarge => typography.titleLarge;
  98. String get titleMediumFamily => typography.titleMediumFamily;
  99. bool get titleMediumIsCustom => typography.titleMediumIsCustom;
  100. TextStyle get titleMedium => typography.titleMedium;
  101. String get titleSmallFamily => typography.titleSmallFamily;
  102. bool get titleSmallIsCustom => typography.titleSmallIsCustom;
  103. TextStyle get titleSmall => typography.titleSmall;
  104. String get labelLargeFamily => typography.labelLargeFamily;
  105. bool get labelLargeIsCustom => typography.labelLargeIsCustom;
  106. TextStyle get labelLarge => typography.labelLarge;
  107. String get labelMediumFamily => typography.labelMediumFamily;
  108. bool get labelMediumIsCustom => typography.labelMediumIsCustom;
  109. TextStyle get labelMedium => typography.labelMedium;
  110. String get labelSmallFamily => typography.labelSmallFamily;
  111. bool get labelSmallIsCustom => typography.labelSmallIsCustom;
  112. TextStyle get labelSmall => typography.labelSmall;
  113. String get bodyLargeFamily => typography.bodyLargeFamily;
  114. bool get bodyLargeIsCustom => typography.bodyLargeIsCustom;
  115. TextStyle get bodyLarge => typography.bodyLarge;
  116. String get bodyMediumFamily => typography.bodyMediumFamily;
  117. bool get bodyMediumIsCustom => typography.bodyMediumIsCustom;
  118. TextStyle get bodyMedium => typography.bodyMedium;
  119. String get bodySmallFamily => typography.bodySmallFamily;
  120. bool get bodySmallIsCustom => typography.bodySmallIsCustom;
  121. TextStyle get bodySmall => typography.bodySmall;
  122. Typography get typography => ThemeTypography(this);
  123. }
  124. class LightModeTheme extends FlutterFlowTheme {
  125. @Deprecated('Use primary instead')
  126. Color get primaryColor => primary;
  127. @Deprecated('Use secondary instead')
  128. Color get secondaryColor => secondary;
  129. @Deprecated('Use tertiary instead')
  130. Color get tertiaryColor => tertiary;
  131. late Color primary = const Color(0xFF4B39EF);
  132. late Color secondary = const Color(0xFF39D2C0);
  133. late Color tertiary = const Color(0xFFEE8B60);
  134. late Color alternate = const Color(0xFFE0E3E7);
  135. late Color primaryText = const Color(0xFF14181B);
  136. late Color secondaryText = const Color(0xFF57636C);
  137. late Color primaryBackground = const Color(0xFFF1F4F8);
  138. late Color secondaryBackground = const Color(0xFFFFFFFF);
  139. late Color accent1 = const Color(0x4C4B39EF);
  140. late Color accent2 = const Color(0x4D39D2C0);
  141. late Color accent3 = const Color(0x4DEE8B60);
  142. late Color accent4 = const Color(0xCCFFFFFF);
  143. late Color success = const Color(0xFF249689);
  144. late Color warning = const Color(0xFFF9CF58);
  145. late Color error = const Color(0xFFFF5963);
  146. late Color info = const Color(0xFFFFFFFF);
  147. }
  148. abstract class Typography {
  149. String get displayLargeFamily;
  150. bool get displayLargeIsCustom;
  151. TextStyle get displayLarge;
  152. String get displayMediumFamily;
  153. bool get displayMediumIsCustom;
  154. TextStyle get displayMedium;
  155. String get displaySmallFamily;
  156. bool get displaySmallIsCustom;
  157. TextStyle get displaySmall;
  158. String get headlineLargeFamily;
  159. bool get headlineLargeIsCustom;
  160. TextStyle get headlineLarge;
  161. String get headlineMediumFamily;
  162. bool get headlineMediumIsCustom;
  163. TextStyle get headlineMedium;
  164. String get headlineSmallFamily;
  165. bool get headlineSmallIsCustom;
  166. TextStyle get headlineSmall;
  167. String get titleLargeFamily;
  168. bool get titleLargeIsCustom;
  169. TextStyle get titleLarge;
  170. String get titleMediumFamily;
  171. bool get titleMediumIsCustom;
  172. TextStyle get titleMedium;
  173. String get titleSmallFamily;
  174. bool get titleSmallIsCustom;
  175. TextStyle get titleSmall;
  176. String get labelLargeFamily;
  177. bool get labelLargeIsCustom;
  178. TextStyle get labelLarge;
  179. String get labelMediumFamily;
  180. bool get labelMediumIsCustom;
  181. TextStyle get labelMedium;
  182. String get labelSmallFamily;
  183. bool get labelSmallIsCustom;
  184. TextStyle get labelSmall;
  185. String get bodyLargeFamily;
  186. bool get bodyLargeIsCustom;
  187. TextStyle get bodyLarge;
  188. String get bodyMediumFamily;
  189. bool get bodyMediumIsCustom;
  190. TextStyle get bodyMedium;
  191. String get bodySmallFamily;
  192. bool get bodySmallIsCustom;
  193. TextStyle get bodySmall;
  194. }
  195. class ThemeTypography extends Typography {
  196. ThemeTypography(this.theme);
  197. final FlutterFlowTheme theme;
  198. String get displayLargeFamily => 'Inter Tight';
  199. bool get displayLargeIsCustom => false;
  200. TextStyle get displayLarge => GoogleFonts.interTight(
  201. color: theme.primaryText,
  202. fontWeight: FontWeight.w600,
  203. fontSize: 64.0,
  204. );
  205. String get displayMediumFamily => 'Inter Tight';
  206. bool get displayMediumIsCustom => false;
  207. TextStyle get displayMedium => GoogleFonts.interTight(
  208. color: theme.primaryText,
  209. fontWeight: FontWeight.w600,
  210. fontSize: 44.0,
  211. );
  212. String get displaySmallFamily => 'Inter Tight';
  213. bool get displaySmallIsCustom => false;
  214. TextStyle get displaySmall => GoogleFonts.interTight(
  215. color: theme.primaryText,
  216. fontWeight: FontWeight.w600,
  217. fontSize: 36.0,
  218. );
  219. String get headlineLargeFamily => 'Inter Tight';
  220. bool get headlineLargeIsCustom => false;
  221. TextStyle get headlineLarge => GoogleFonts.interTight(
  222. color: theme.primaryText,
  223. fontWeight: FontWeight.w600,
  224. fontSize: 32.0,
  225. );
  226. String get headlineMediumFamily => 'Inter Tight';
  227. bool get headlineMediumIsCustom => false;
  228. TextStyle get headlineMedium => GoogleFonts.interTight(
  229. color: theme.primaryText,
  230. fontWeight: FontWeight.w600,
  231. fontSize: 28.0,
  232. );
  233. String get headlineSmallFamily => 'Inter Tight';
  234. bool get headlineSmallIsCustom => false;
  235. TextStyle get headlineSmall => GoogleFonts.interTight(
  236. color: theme.primaryText,
  237. fontWeight: FontWeight.w600,
  238. fontSize: 24.0,
  239. );
  240. String get titleLargeFamily => 'Inter Tight';
  241. bool get titleLargeIsCustom => false;
  242. TextStyle get titleLarge => GoogleFonts.interTight(
  243. color: theme.primaryText,
  244. fontWeight: FontWeight.w600,
  245. fontSize: 20.0,
  246. );
  247. String get titleMediumFamily => 'Inter Tight';
  248. bool get titleMediumIsCustom => false;
  249. TextStyle get titleMedium => GoogleFonts.interTight(
  250. color: theme.primaryText,
  251. fontWeight: FontWeight.w600,
  252. fontSize: 18.0,
  253. );
  254. String get titleSmallFamily => 'Inter Tight';
  255. bool get titleSmallIsCustom => false;
  256. TextStyle get titleSmall => GoogleFonts.interTight(
  257. color: theme.primaryText,
  258. fontWeight: FontWeight.w600,
  259. fontSize: 16.0,
  260. );
  261. String get labelLargeFamily => 'Inter';
  262. bool get labelLargeIsCustom => false;
  263. TextStyle get labelLarge => GoogleFonts.inter(
  264. color: theme.secondaryText,
  265. fontWeight: FontWeight.normal,
  266. fontSize: 16.0,
  267. );
  268. String get labelMediumFamily => 'Inter';
  269. bool get labelMediumIsCustom => false;
  270. TextStyle get labelMedium => GoogleFonts.inter(
  271. color: theme.secondaryText,
  272. fontWeight: FontWeight.normal,
  273. fontSize: 14.0,
  274. );
  275. String get labelSmallFamily => 'Inter';
  276. bool get labelSmallIsCustom => false;
  277. TextStyle get labelSmall => GoogleFonts.inter(
  278. color: theme.secondaryText,
  279. fontWeight: FontWeight.normal,
  280. fontSize: 12.0,
  281. );
  282. String get bodyLargeFamily => 'Inter';
  283. bool get bodyLargeIsCustom => false;
  284. TextStyle get bodyLarge => GoogleFonts.inter(
  285. color: theme.primaryText,
  286. fontWeight: FontWeight.normal,
  287. fontSize: 16.0,
  288. );
  289. String get bodyMediumFamily => 'Inter';
  290. bool get bodyMediumIsCustom => false;
  291. TextStyle get bodyMedium => GoogleFonts.inter(
  292. color: theme.primaryText,
  293. fontWeight: FontWeight.normal,
  294. fontSize: 14.0,
  295. );
  296. String get bodySmallFamily => 'Inter';
  297. bool get bodySmallIsCustom => false;
  298. TextStyle get bodySmall => GoogleFonts.inter(
  299. color: theme.primaryText,
  300. fontWeight: FontWeight.normal,
  301. fontSize: 12.0,
  302. );
  303. }
  304. class DarkModeTheme extends FlutterFlowTheme {
  305. @Deprecated('Use primary instead')
  306. Color get primaryColor => primary;
  307. @Deprecated('Use secondary instead')
  308. Color get secondaryColor => secondary;
  309. @Deprecated('Use tertiary instead')
  310. Color get tertiaryColor => tertiary;
  311. late Color primary = const Color(0xFF4B39EF);
  312. late Color secondary = const Color(0xFF39D2C0);
  313. late Color tertiary = const Color(0xFFEE8B60);
  314. late Color alternate = const Color(0xFF262D34);
  315. late Color primaryText = const Color(0xFFFFFFFF);
  316. late Color secondaryText = const Color(0xFF95A1AC);
  317. late Color primaryBackground = const Color(0xFF1D2428);
  318. late Color secondaryBackground = const Color(0xFF14181B);
  319. late Color accent1 = const Color(0xFF9A141D);
  320. late Color accent2 = const Color(0x4D39D2C0);
  321. late Color accent3 = const Color(0x4DEE8B60);
  322. late Color accent4 = const Color(0xB2262D34);
  323. late Color success = const Color(0xFF249689);
  324. late Color warning = const Color(0xFFF9CF58);
  325. late Color error = const Color(0xFFFF5963);
  326. late Color info = const Color(0xFFFFFFFF);
  327. }
  328. class FFDesignTokens {
  329. const FFDesignTokens(this.theme);
  330. final FlutterFlowTheme theme;
  331. FFSpacing get spacing => const FFSpacing();
  332. FFRadius get radius => const FFRadius();
  333. FFShadows get shadow => FFShadows(theme);
  334. }
  335. class FFSpacing {
  336. const FFSpacing();
  337. double get xs => 4.0;
  338. double get sm => 8.0;
  339. double get md => 16.0;
  340. double get lg => 24.0;
  341. double get xl => 32.0;
  342. }
  343. class FFRadius {
  344. const FFRadius();
  345. double get sm => 8.0;
  346. double get md => 16.0;
  347. double get lg => 24.0;
  348. double get full => 9999.0;
  349. }
  350. class FFShadows {
  351. const FFShadows(this.theme);
  352. final FlutterFlowTheme theme;
  353. BoxShadow get sm => const BoxShadow(
  354. blurRadius: 3.0,
  355. color: const Color(0x1A000000),
  356. offset: const Offset(0.0, 1.0),
  357. spreadRadius: 0.0);
  358. BoxShadow get md => const BoxShadow(
  359. blurRadius: 6.0,
  360. color: const Color(0x1A000000),
  361. offset: const Offset(0.0, 3.0),
  362. spreadRadius: 0.0);
  363. BoxShadow get lg => const BoxShadow(
  364. blurRadius: 15.0,
  365. color: const Color(0x1A000000),
  366. offset: const Offset(0.0, 8.0),
  367. spreadRadius: 0.0);
  368. BoxShadow get xl => const BoxShadow(
  369. blurRadius: 25.0,
  370. color: const Color(0x1A000000),
  371. offset: const Offset(0.0, 16.0),
  372. spreadRadius: 0.0);
  373. }
  374. extension TextStyleHelper on TextStyle {
  375. TextStyle override({
  376. TextStyle? font,
  377. String? fontFamily,
  378. Color? color,
  379. double? fontSize,
  380. FontWeight? fontWeight,
  381. double? letterSpacing,
  382. FontStyle? fontStyle,
  383. bool useGoogleFonts = false,
  384. TextDecoration? decoration,
  385. double? lineHeight,
  386. List<Shadow>? shadows,
  387. String? package,
  388. }) {
  389. if (useGoogleFonts && fontFamily != null && fontFamily.isNotEmpty) {
  390. font = GoogleFonts.getFont(fontFamily,
  391. fontWeight: fontWeight ?? this.fontWeight,
  392. fontStyle: fontStyle ?? this.fontStyle);
  393. }
  394. return font != null
  395. ? font.copyWith(
  396. color: color ?? this.color,
  397. fontSize: fontSize ?? this.fontSize,
  398. letterSpacing: letterSpacing ?? this.letterSpacing,
  399. fontWeight: fontWeight ?? this.fontWeight,
  400. fontStyle: fontStyle ?? this.fontStyle,
  401. decoration: decoration,
  402. height: lineHeight,
  403. shadows: shadows,
  404. )
  405. : copyWith(
  406. fontFamily: fontFamily,
  407. package: package,
  408. color: color,
  409. fontSize: fontSize,
  410. letterSpacing: letterSpacing,
  411. fontWeight: fontWeight,
  412. fontStyle: fontStyle,
  413. decoration: decoration,
  414. height: lineHeight,
  415. shadows: shadows,
  416. );
  417. }
  418. }