2022-08-16 01:53:30 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-12-11 17:30:56 +01:00
|
|
|
|
2024-11-19 16:36:46 +01:00
|
|
|
import 'package:immich_mobile/constants/locales.dart';
|
2024-08-06 16:20:27 +02:00
|
|
|
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
2022-08-16 01:53:30 +02:00
|
|
|
|
2024-08-06 16:20:27 +02:00
|
|
|
class ImmichTheme {
|
2024-11-13 07:13:21 +01:00
|
|
|
final ColorScheme light;
|
|
|
|
final ColorScheme dark;
|
2024-08-06 16:20:27 +02:00
|
|
|
|
2024-11-13 07:13:21 +01:00
|
|
|
const ImmichTheme({required this.light, required this.dark});
|
2024-08-06 16:20:27 +02:00
|
|
|
}
|
|
|
|
|
2024-11-19 16:36:46 +01:00
|
|
|
ThemeData getThemeData({
|
|
|
|
required ColorScheme colorScheme,
|
|
|
|
required Locale locale,
|
|
|
|
}) {
|
2024-12-11 17:30:56 +01:00
|
|
|
final isDark = colorScheme.brightness == Brightness.dark;
|
2024-08-06 16:20:27 +02:00
|
|
|
|
|
|
|
return ThemeData(
|
|
|
|
useMaterial3: true,
|
2024-11-13 07:13:21 +01:00
|
|
|
brightness: colorScheme.brightness,
|
2024-08-06 16:20:27 +02:00
|
|
|
colorScheme: colorScheme,
|
2024-12-11 17:30:56 +01:00
|
|
|
primaryColor: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
hintColor: colorScheme.onSurfaceSecondary,
|
2024-12-11 17:30:56 +01:00
|
|
|
focusColor: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
scaffoldBackgroundColor: colorScheme.surface,
|
2024-12-11 17:30:56 +01:00
|
|
|
splashColor: colorScheme.primary.withOpacity(0.1),
|
|
|
|
highlightColor: colorScheme.primary.withOpacity(0.1),
|
2024-08-06 16:20:27 +02:00
|
|
|
dialogBackgroundColor: colorScheme.surfaceContainer,
|
|
|
|
bottomSheetTheme: BottomSheetThemeData(
|
|
|
|
backgroundColor: colorScheme.surfaceContainer,
|
2023-02-13 06:05:31 +01:00
|
|
|
),
|
2024-12-11 17:30:56 +01:00
|
|
|
fontFamily: _getFontFamilyFromLocale(locale),
|
2024-08-06 16:20:27 +02:00
|
|
|
snackBarTheme: SnackBarThemeData(
|
|
|
|
contentTextStyle: TextStyle(
|
2024-12-11 17:30:56 +01:00
|
|
|
fontFamily: _getFontFamilyFromLocale(locale),
|
|
|
|
color: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
2023-02-13 06:05:31 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
backgroundColor: colorScheme.surfaceContainerHighest,
|
2023-02-13 06:05:31 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
appBarTheme: AppBarTheme(
|
|
|
|
titleTextStyle: TextStyle(
|
2024-12-11 17:30:56 +01:00
|
|
|
color: colorScheme.primary,
|
|
|
|
fontFamily: _getFontFamilyFromLocale(locale),
|
2024-08-06 16:20:27 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 18,
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
backgroundColor:
|
|
|
|
isDark ? colorScheme.surfaceContainer : colorScheme.surface,
|
2024-12-11 17:30:56 +01:00
|
|
|
foregroundColor: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
elevation: 0,
|
|
|
|
scrolledUnderElevation: 0,
|
|
|
|
centerTitle: true,
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-12-02 16:33:44 +01:00
|
|
|
textTheme: const TextTheme(
|
2024-08-06 16:20:27 +02:00
|
|
|
displayLarge: TextStyle(
|
|
|
|
fontSize: 26,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
displayMedium: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
displaySmall: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2024-12-02 16:33:44 +01:00
|
|
|
titleSmall: TextStyle(
|
2024-08-06 16:20:27 +02:00
|
|
|
fontSize: 16.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2024-12-02 16:33:44 +01:00
|
|
|
titleMedium: TextStyle(
|
2024-08-06 16:20:27 +02:00
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2024-12-02 16:33:44 +01:00
|
|
|
titleLarge: TextStyle(
|
2024-08-06 16:20:27 +02:00
|
|
|
fontSize: 26.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2023-03-25 04:44:53 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
style: ElevatedButton.styleFrom(
|
2024-12-11 17:30:56 +01:00
|
|
|
backgroundColor: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
foregroundColor: isDark ? Colors.black87 : Colors.white,
|
|
|
|
),
|
2023-03-25 04:44:53 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
chipTheme: const ChipThemeData(
|
|
|
|
side: BorderSide.none,
|
2023-02-11 21:23:32 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
sliderTheme: const SliderThemeData(
|
|
|
|
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7),
|
|
|
|
trackHeight: 2.0,
|
2023-02-11 21:23:32 +01:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
|
|
|
type: BottomNavigationBarType.fixed,
|
2022-08-16 01:53:30 +02:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
popupMenuTheme: const PopupMenuThemeData(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
2023-02-13 06:05:31 +01:00
|
|
|
),
|
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
navigationBarTheme: NavigationBarThemeData(
|
|
|
|
backgroundColor:
|
|
|
|
isDark ? colorScheme.surfaceContainer : colorScheme.surface,
|
|
|
|
labelTextStyle: const WidgetStatePropertyAll(
|
|
|
|
TextStyle(
|
2024-10-10 10:44:14 +02:00
|
|
|
fontSize: 14,
|
2024-08-06 16:20:27 +02:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
2024-12-11 17:30:56 +01:00
|
|
|
color: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
),
|
2024-08-09 15:43:47 +02:00
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
2024-08-06 16:20:27 +02:00
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: colorScheme.outlineVariant,
|
|
|
|
),
|
2024-08-09 15:43:47 +02:00
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
2024-08-06 16:20:27 +02:00
|
|
|
),
|
|
|
|
labelStyle: TextStyle(
|
2024-12-11 17:30:56 +01:00
|
|
|
color: colorScheme.primary,
|
2024-08-06 16:20:27 +02:00
|
|
|
),
|
|
|
|
hintStyle: const TextStyle(
|
|
|
|
fontSize: 14.0,
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
textSelectionTheme: TextSelectionThemeData(
|
2024-12-11 17:30:56 +01:00
|
|
|
cursorColor: colorScheme.primary,
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-08-09 15:43:47 +02:00
|
|
|
dropdownMenuTheme: DropdownMenuThemeData(
|
2024-12-11 17:30:56 +01:00
|
|
|
menuStyle: const MenuStyle(
|
2024-08-09 15:43:47 +02:00
|
|
|
shape: WidgetStatePropertyAll<OutlinedBorder>(
|
|
|
|
RoundedRectangleBorder(
|
2024-12-11 17:30:56 +01:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(15)),
|
2024-08-09 15:43:47 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
2024-12-11 17:30:56 +01:00
|
|
|
color: colorScheme.primary,
|
2024-08-09 15:43:47 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: colorScheme.outlineVariant,
|
|
|
|
),
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
|
|
|
),
|
|
|
|
labelStyle: TextStyle(
|
2024-12-11 17:30:56 +01:00
|
|
|
color: colorScheme.primary,
|
2024-08-09 15:43:47 +02:00
|
|
|
),
|
|
|
|
hintStyle: const TextStyle(
|
|
|
|
fontSize: 14.0,
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-08-06 16:20:27 +02:00
|
|
|
);
|
|
|
|
}
|
2024-12-11 17:30:56 +01:00
|
|
|
|
|
|
|
// This method replaces all surface shades in ImmichTheme to a static ones
|
|
|
|
// as we are creating the colorscheme through seedColor the default surfaces are
|
|
|
|
// tinted with primary color
|
|
|
|
ImmichTheme decolorizeSurfaces({
|
|
|
|
required ImmichTheme theme,
|
|
|
|
}) {
|
|
|
|
return ImmichTheme(
|
|
|
|
light: theme.light.copyWith(
|
|
|
|
surface: const Color(0xFFf9f9f9),
|
|
|
|
onSurface: const Color(0xFF1b1b1b),
|
|
|
|
surfaceContainerLowest: const Color(0xFFffffff),
|
|
|
|
surfaceContainerLow: const Color(0xFFf3f3f3),
|
|
|
|
surfaceContainer: const Color(0xFFeeeeee),
|
|
|
|
surfaceContainerHigh: const Color(0xFFe8e8e8),
|
|
|
|
surfaceContainerHighest: const Color(0xFFe2e2e2),
|
|
|
|
surfaceDim: const Color(0xFFdadada),
|
|
|
|
surfaceBright: const Color(0xFFf9f9f9),
|
|
|
|
onSurfaceVariant: const Color(0xFF4c4546),
|
|
|
|
inverseSurface: const Color(0xFF303030),
|
|
|
|
onInverseSurface: const Color(0xFFf1f1f1),
|
|
|
|
),
|
|
|
|
dark: theme.dark.copyWith(
|
|
|
|
surface: const Color(0xFF131313),
|
|
|
|
onSurface: const Color(0xFFE2E2E2),
|
|
|
|
surfaceContainerLowest: const Color(0xFF0E0E0E),
|
|
|
|
surfaceContainerLow: const Color(0xFF1B1B1B),
|
|
|
|
surfaceContainer: const Color(0xFF1F1F1F),
|
|
|
|
surfaceContainerHigh: const Color(0xFF242424),
|
|
|
|
surfaceContainerHighest: const Color(0xFF2E2E2E),
|
|
|
|
surfaceDim: const Color(0xFF131313),
|
|
|
|
surfaceBright: const Color(0xFF353535),
|
|
|
|
onSurfaceVariant: const Color(0xFFCfC4C5),
|
|
|
|
inverseSurface: const Color(0xFFE2E2E2),
|
|
|
|
onInverseSurface: const Color(0xFF303030),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
String? _getFontFamilyFromLocale(Locale locale) {
|
|
|
|
if (localesNotSupportedByOverpass.contains(locale)) {
|
|
|
|
// Let Flutter use the default font
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return 'Overpass';
|
|
|
|
}
|