immich_app_theme.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import 'package:flutter/material.dart';
  2. import 'package:hooks_riverpod/hooks_riverpod.dart';
  3. import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
  4. import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
  5. final immichThemeProvider = StateProvider<ThemeMode>((ref) {
  6. var themeMode = ref
  7. .watch(appSettingsServiceProvider)
  8. .getSetting(AppSettingsEnum.themeMode);
  9. debugPrint("Current themeMode $themeMode");
  10. if (themeMode == "light") {
  11. return ThemeMode.light;
  12. } else if (themeMode == "dark") {
  13. return ThemeMode.dark;
  14. } else {
  15. return ThemeMode.system;
  16. }
  17. });
  18. ColorScheme _lightColorScheme = const ColorScheme(
  19. brightness: Brightness.light,
  20. primary: Color(0xff4755b5),
  21. onPrimary: Color(0xffffffff),
  22. primaryContainer: Color(0xffdfe0ff),
  23. onPrimaryContainer: Color(0xff000d60),
  24. secondary: Color(0xff5b5d72),
  25. onSecondary: Color(0xffffffff),
  26. secondaryContainer: Color(0xFFD6D8FF),
  27. onSecondaryContainer: Color(0xff181a2c),
  28. tertiary: Color(0xff77536c),
  29. onTertiary: Color(0xffffffff),
  30. tertiaryContainer: Color(0xffffd7f0),
  31. onTertiaryContainer: Color(0xff2d1127),
  32. error: Color(0xffba1a1a),
  33. onError: Color(0xffffffff),
  34. errorContainer: Color(0xffffdad6),
  35. onErrorContainer: Color(0xff410002),
  36. background: Color(0xfff9f6fc),
  37. onBackground: Color(0xff1b1b1f),
  38. surface: Color(0xfff9f6fc),
  39. onSurface: Color(0xff1b1b1f),
  40. surfaceVariant: Color(0xffdeddea),
  41. onSurfaceVariant: Color(0xff46464f),
  42. outline: Color(0xff777680),
  43. outlineVariant: Color(0xffc7c5d0),
  44. shadow: Color(0xff000000),
  45. scrim: Color(0xff000000),
  46. inverseSurface: Color(0xff303137),
  47. onInverseSurface: Color(0xfff3f0f4),
  48. inversePrimary: Color(0xffbcc3ff),
  49. surfaceTint: Color(0xff4755b5),
  50. );
  51. ColorScheme _darkColorScheme = const ColorScheme(
  52. brightness: Brightness.dark,
  53. primary: Color(0xffa4c8ff),
  54. onPrimary: Color(0xff00315e),
  55. primaryContainer: Color(0xFF182C40),
  56. onPrimaryContainer: Color(0xffd4e3ff),
  57. secondary: Color(0xffbcc7dc),
  58. onSecondary: Color(0xff37474f),
  59. secondaryContainer: Color(0xff3d4758),
  60. onSecondaryContainer: Color(0xffd8e3f8),
  61. tertiary: Color(0xffdabde2),
  62. onTertiary: Color(0xff3d2946),
  63. tertiaryContainer: Color(0xff543f5e),
  64. onTertiaryContainer: Color(0xfff6d9ff),
  65. error: Color(0xffffb4ab),
  66. onError: Color(0xff690005),
  67. errorContainer: Color(0xff93000a),
  68. onErrorContainer: Color(0xffffb4ab),
  69. background: Color(0xff101214),
  70. onBackground: Color(0xffe2e2e5),
  71. surface: Color(0xff101214),
  72. onSurface: Color(0xffe2e2e5),
  73. surfaceVariant: Color(0xff363c42),
  74. onSurfaceVariant: Color(0xffc1c7ce),
  75. outline: Color(0xff8b9198),
  76. outlineVariant: Color(0xff41474d),
  77. shadow: Color(0xff000000),
  78. scrim: Color(0xff000000),
  79. inverseSurface: Color(0xffeeeef1),
  80. onInverseSurface: Color(0xff2e3133),
  81. inversePrimary: Color(0xff1c5fa5),
  82. surfaceTint: Color(0xff90caf9),
  83. );
  84. ThemeData getThemeForScheme(ColorScheme scheme) {
  85. return ThemeData(
  86. useMaterial3: true,
  87. brightness: scheme.brightness,
  88. colorScheme: scheme,
  89. primaryColor: scheme.primary,
  90. scaffoldBackgroundColor: scheme.background,
  91. fontFamily: 'WorkSans',
  92. appBarTheme: AppBarTheme(
  93. iconTheme: IconThemeData(color: scheme.primary),
  94. titleTextStyle: TextStyle(
  95. fontSize: 18.0,
  96. fontWeight: FontWeight.bold,
  97. color: scheme.primary,
  98. ),
  99. ),
  100. cardTheme: const CardTheme(elevation: 2.0),
  101. elevatedButtonTheme: ElevatedButtonThemeData(
  102. style: ElevatedButton.styleFrom(
  103. visualDensity: VisualDensity.standard,
  104. textStyle: const TextStyle(
  105. fontWeight: FontWeight.bold,
  106. fontSize: 11,
  107. ),
  108. shadowColor: scheme.shadow,
  109. foregroundColor: scheme.onPrimary,
  110. backgroundColor: scheme.primary,
  111. ),
  112. ),
  113. navigationBarTheme: NavigationBarThemeData(
  114. iconTheme: MaterialStateProperty.resolveWith<IconThemeData?>((states) {
  115. if (states.contains(MaterialState.selected)) {
  116. return IconThemeData(color: scheme.primary);
  117. }
  118. return null;
  119. }),
  120. ),
  121. textTheme: TextTheme(
  122. displayLarge: TextStyle(
  123. fontSize: 26,
  124. fontWeight: FontWeight.bold,
  125. color: scheme.primary,
  126. ),
  127. displayMedium: const TextStyle(
  128. fontSize: 14,
  129. fontWeight: FontWeight.bold,
  130. ),
  131. displaySmall: const TextStyle(
  132. fontSize: 12,
  133. fontWeight: FontWeight.bold,
  134. ),
  135. titleSmall: const TextStyle(
  136. fontSize: 16.0,
  137. fontWeight: FontWeight.bold,
  138. ),
  139. titleMedium: const TextStyle(
  140. fontSize: 18.0,
  141. fontWeight: FontWeight.bold,
  142. ),
  143. titleLarge: TextStyle(
  144. fontSize: 26.0,
  145. fontWeight: FontWeight.bold,
  146. color: scheme.primary,
  147. ),
  148. ),
  149. chipTheme: const ChipThemeData(
  150. side: BorderSide.none,
  151. ),
  152. sliderTheme: const SliderThemeData(
  153. thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7),
  154. trackHeight: 2.0,
  155. ),
  156. inputDecorationTheme: InputDecorationTheme(
  157. labelStyle: TextStyle(
  158. color: scheme.primary,
  159. ),
  160. hintStyle: const TextStyle(
  161. fontSize: 14.0,
  162. fontWeight: FontWeight.normal,
  163. ),
  164. ),
  165. );
  166. }
  167. ThemeData immichLightTheme = getThemeForScheme(_lightColorScheme);
  168. ThemeData immichDarkTheme = getThemeForScheme(_darkColorScheme);