Source Code added
This commit is contained in:
parent
800376eafd
commit
9efa9bc6dd
3912 changed files with 754770 additions and 2 deletions
66
mobile/lib/theme/color_scheme.dart
Normal file
66
mobile/lib/theme/color_scheme.dart
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/constants/colors.dart';
|
||||
import 'package:immich_mobile/theme/theme_data.dart';
|
||||
|
||||
final Map<ImmichColorPreset, ImmichTheme> _themePresets = {
|
||||
ImmichColorPreset.indigo: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(
|
||||
seedColor: immichBrandColorLight,
|
||||
).copyWith(primary: immichBrandColorLight, onSurface: const Color.fromARGB(255, 34, 31, 32)),
|
||||
dark: ColorScheme.fromSeed(
|
||||
seedColor: immichBrandColorDark,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(primary: immichBrandColorDark),
|
||||
),
|
||||
ImmichColorPreset.deepPurple: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFF6F43C0)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFFD3BBFF), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.pink: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFFED79B5)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFFED79B5), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.red: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFFC51C16)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFFD3302F), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.orange: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xffff5b01),
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.fidelity,
|
||||
),
|
||||
dark: ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xFFCC6D08),
|
||||
brightness: Brightness.dark,
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.fidelity,
|
||||
),
|
||||
),
|
||||
ImmichColorPreset.yellow: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFFFFB400)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFFFFB400), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.lime: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFFCDDC39)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFFCDDC39), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.green: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFF18C249)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFF18C249), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.cyan: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFF00BCD4)),
|
||||
dark: ColorScheme.fromSeed(seedColor: const Color(0xFF00BCD4), brightness: Brightness.dark),
|
||||
),
|
||||
ImmichColorPreset.slateGray: ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: const Color(0xFF696969), dynamicSchemeVariant: DynamicSchemeVariant.neutral),
|
||||
dark: ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xff696969),
|
||||
brightness: Brightness.dark,
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.neutral,
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
extension ImmichColorModeExtension on ImmichColorPreset {
|
||||
ImmichTheme get themeOfPreset => _themePresets[this]!;
|
||||
}
|
||||
33
mobile/lib/theme/dynamic_theme.dart
Normal file
33
mobile/lib/theme/dynamic_theme.dart
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
|
||||
import 'package:immich_mobile/theme/theme_data.dart';
|
||||
import 'package:immich_mobile/utils/debug_print.dart';
|
||||
|
||||
abstract final class DynamicTheme {
|
||||
const DynamicTheme._();
|
||||
|
||||
static ImmichTheme? _theme;
|
||||
// Method to fetch dynamic system colors
|
||||
static Future<void> fetchSystemPalette() async {
|
||||
try {
|
||||
final corePalette = await DynamicColorPlugin.getCorePalette();
|
||||
if (corePalette != null) {
|
||||
final primaryColor = corePalette.toColorScheme().primary;
|
||||
dPrint(() => 'dynamic_color: Core palette detected.');
|
||||
|
||||
// Some palettes do not generate surface container colors accurately,
|
||||
// so we regenerate all colors using the primary color
|
||||
_theme = ImmichTheme(
|
||||
light: ColorScheme.fromSeed(seedColor: primaryColor, brightness: Brightness.light),
|
||||
dark: ColorScheme.fromSeed(seedColor: primaryColor, brightness: Brightness.dark),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
dPrint(() => 'dynamic_color: Failed to obtain core palette: $error');
|
||||
}
|
||||
}
|
||||
|
||||
static ImmichTheme? get theme => _theme;
|
||||
static bool get isAvailable => _theme != null;
|
||||
}
|
||||
160
mobile/lib/theme/theme_data.dart
Normal file
160
mobile/lib/theme/theme_data.dart
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:immich_mobile/constants/locales.dart';
|
||||
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
||||
|
||||
class ImmichTheme {
|
||||
final ColorScheme light;
|
||||
final ColorScheme dark;
|
||||
|
||||
const ImmichTheme({required this.light, required this.dark});
|
||||
}
|
||||
|
||||
ThemeData getThemeData({required ColorScheme colorScheme, required Locale locale}) {
|
||||
final isDark = colorScheme.brightness == Brightness.dark;
|
||||
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: colorScheme.brightness,
|
||||
colorScheme: colorScheme,
|
||||
primaryColor: colorScheme.primary,
|
||||
hintColor: colorScheme.onSurfaceSecondary,
|
||||
focusColor: colorScheme.primary,
|
||||
scaffoldBackgroundColor: colorScheme.surface,
|
||||
splashColor: colorScheme.primary.withValues(alpha: 0.1),
|
||||
highlightColor: colorScheme.primary.withValues(alpha: 0.1),
|
||||
bottomSheetTheme: BottomSheetThemeData(backgroundColor: colorScheme.surfaceContainer),
|
||||
fontFamily: _getFontFamilyFromLocale(locale),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
contentTextStyle: TextStyle(
|
||||
fontFamily: _getFontFamilyFromLocale(locale),
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
titleTextStyle: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontFamily: _getFontFamilyFromLocale(locale),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 18,
|
||||
),
|
||||
backgroundColor: colorScheme.surface,
|
||||
foregroundColor: colorScheme.primary,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
centerTitle: true,
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
displayLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
displayMedium: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
|
||||
displaySmall: TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
|
||||
titleSmall: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600),
|
||||
titleMedium: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600),
|
||||
titleLarge: TextStyle(fontSize: 26.0, fontWeight: FontWeight.w600),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colorScheme.primary,
|
||||
foregroundColor: isDark ? Colors.black87 : Colors.white,
|
||||
),
|
||||
),
|
||||
chipTheme: const ChipThemeData(side: BorderSide.none),
|
||||
sliderTheme: const SliderThemeData(
|
||||
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7),
|
||||
trackHeight: 2.0,
|
||||
// ignore: deprecated_member_use
|
||||
year2023: false,
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed),
|
||||
popupMenuTheme: const PopupMenuThemeData(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: isDark ? colorScheme.surfaceContainer : colorScheme.surface,
|
||||
labelTextStyle: const WidgetStatePropertyAll(TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: colorScheme.primary),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
),
|
||||
labelStyle: TextStyle(color: colorScheme.primary),
|
||||
hintStyle: const TextStyle(fontSize: 14.0, fontWeight: FontWeight.normal),
|
||||
),
|
||||
textSelectionTheme: TextSelectionThemeData(cursorColor: colorScheme.primary),
|
||||
dropdownMenuTheme: DropdownMenuThemeData(
|
||||
menuStyle: const MenuStyle(
|
||||
shape: WidgetStatePropertyAll<OutlinedBorder>(
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15))),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: colorScheme.primary)),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
),
|
||||
labelStyle: TextStyle(color: colorScheme.primary),
|
||||
hintStyle: const TextStyle(fontSize: 14.0, fontWeight: FontWeight.normal),
|
||||
),
|
||||
),
|
||||
dialogTheme: DialogThemeData(backgroundColor: colorScheme.surfaceContainer),
|
||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||
// ignore: deprecated_member_use
|
||||
year2023: false,
|
||||
// TODO: Uncommented after upgrade to version later than 3.29.2
|
||||
// circularTrackColor: Colors.black12,
|
||||
trackGap: 3,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 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 (localesNotSupportedByAppFont.contains(locale)) {
|
||||
// Let Flutter use the default font
|
||||
return null;
|
||||
}
|
||||
return 'GoogleSans';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue