Rain/lib/theme/theme.dart

154 lines
5.3 KiB
Dart
Raw Normal View History

2023-06-17 20:57:57 +03:00
import 'package:flutter/material.dart';
2024-07-09 23:03:40 +03:00
import 'package:flutter/services.dart';
2023-07-12 20:52:25 +03:00
import 'package:google_fonts/google_fonts.dart';
2024-05-18 21:58:53 +03:00
import 'package:dynamic_color/dynamic_color.dart';
2023-06-17 20:57:57 +03:00
2023-07-12 20:52:25 +03:00
final ThemeData baseLigth = ThemeData.light(useMaterial3: true);
final ThemeData baseDark = ThemeData.dark(useMaterial3: true);
2023-06-17 20:57:57 +03:00
2023-07-14 20:19:43 +03:00
const Color lightColor = Colors.white;
const Color darkColor = Color.fromRGBO(30, 30, 30, 1);
const Color oledColor = Colors.black;
2023-07-19 18:59:53 +03:00
ColorScheme colorSchemeLight = ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.light,
);
ColorScheme colorSchemeDark = ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.dark,
);
2023-06-17 20:57:57 +03:00
2024-07-09 23:03:40 +03:00
ThemeData lightTheme(
Color? color, ColorScheme? colorScheme, bool edgeToEdgeAvailable) {
2023-07-19 18:59:53 +03:00
return baseLigth.copyWith(
brightness: Brightness.light,
colorScheme: colorScheme
?.copyWith(
brightness: Brightness.light,
2024-05-18 21:58:53 +03:00
surface: baseLigth.colorScheme.surface,
2023-07-19 18:59:53 +03:00
)
.harmonized(),
textTheme: GoogleFonts.ubuntuTextTheme(baseLigth.textTheme),
appBarTheme: AppBarTheme(
backgroundColor: color,
foregroundColor: baseLigth.colorScheme.onSurface,
shadowColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
elevation: 0,
2024-07-09 23:03:40 +03:00
systemOverlayStyle: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark,
statusBarColor: Colors.transparent,
systemStatusBarContrastEnforced: false,
systemNavigationBarContrastEnforced: false,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
systemNavigationBarColor:
edgeToEdgeAvailable ? Colors.transparent : colorScheme?.surface,
),
2023-07-19 18:59:53 +03:00
),
primaryColor: color,
canvasColor: color,
scaffoldBackgroundColor: color,
cardTheme: baseLigth.cardTheme.copyWith(
color: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadowColor: Colors.transparent,
),
bottomSheetTheme: baseLigth.bottomSheetTheme.copyWith(
backgroundColor: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
),
navigationRailTheme: baseLigth.navigationRailTheme.copyWith(
backgroundColor: color,
),
navigationBarTheme: baseLigth.navigationBarTheme.copyWith(
backgroundColor: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
),
inputDecorationTheme: baseLigth.inputDecorationTheme.copyWith(
2024-05-18 21:58:53 +03:00
labelStyle: WidgetStateTextStyle.resolveWith(
(Set<WidgetState> states) {
2023-07-19 18:59:53 +03:00
return const TextStyle(fontSize: 14);
},
),
2023-08-03 21:11:58 +03:00
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
2023-07-19 18:59:53 +03:00
),
2023-10-12 12:17:51 +05:30
indicatorColor: Colors.black,
2023-07-19 18:59:53 +03:00
);
}
2023-06-17 20:57:57 +03:00
2024-07-09 23:03:40 +03:00
ThemeData darkTheme(
Color? color, ColorScheme? colorScheme, bool edgeToEdgeAvailable) {
2023-07-19 18:59:53 +03:00
return baseDark.copyWith(
brightness: Brightness.dark,
colorScheme: colorScheme
?.copyWith(
brightness: Brightness.dark,
2024-05-18 21:58:53 +03:00
surface: baseDark.colorScheme.surface,
2023-07-19 18:59:53 +03:00
)
.harmonized(),
textTheme: GoogleFonts.ubuntuTextTheme(baseDark.textTheme),
appBarTheme: AppBarTheme(
backgroundColor: color,
foregroundColor: baseDark.colorScheme.onSurface,
shadowColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
elevation: 0,
2024-07-09 23:03:40 +03:00
systemOverlayStyle: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
statusBarColor: Colors.transparent,
systemStatusBarContrastEnforced: false,
systemNavigationBarContrastEnforced: false,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.light,
systemNavigationBarColor:
edgeToEdgeAvailable ? Colors.transparent : colorScheme?.surface,
),
2023-07-19 18:59:53 +03:00
),
primaryColor: color,
canvasColor: color,
scaffoldBackgroundColor: color,
cardTheme: baseDark.cardTheme.copyWith(
color: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadowColor: Colors.transparent,
),
bottomSheetTheme: baseDark.bottomSheetTheme.copyWith(
backgroundColor: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
),
navigationRailTheme: baseDark.navigationRailTheme.copyWith(
backgroundColor: color,
),
navigationBarTheme: baseDark.navigationBarTheme.copyWith(
backgroundColor: color,
2024-05-18 21:58:53 +03:00
surfaceTintColor:
color == oledColor ? Colors.transparent : colorScheme?.surfaceTint,
2023-07-19 18:59:53 +03:00
),
inputDecorationTheme: baseDark.inputDecorationTheme.copyWith(
2024-05-18 21:58:53 +03:00
labelStyle: WidgetStateTextStyle.resolveWith(
(Set<WidgetState> states) {
2023-07-19 18:59:53 +03:00
return const TextStyle(fontSize: 14);
},
),
2023-08-03 21:11:58 +03:00
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
2023-07-19 18:59:53 +03:00
),
);
2023-06-17 20:57:57 +03:00
}