2021-02-09 15:12:13 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-09-12 22:37:07 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2021-02-09 15:12:13 +01:00
|
|
|
|
|
|
|
import 'util/text_color.dart';
|
|
|
|
|
|
|
|
ThemeData _themeFactory({bool dark = false, bool amoled = false}) {
|
|
|
|
assert(dark || !amoled, "Can't have amoled without dark mode");
|
|
|
|
|
|
|
|
final theme = dark ? ThemeData.dark() : ThemeData.light();
|
|
|
|
final maybeAmoledColor = amoled ? Colors.black : null;
|
|
|
|
|
|
|
|
return theme.copyWith(
|
2021-09-30 12:55:23 +02:00
|
|
|
pageTransitionsTheme: const PageTransitionsTheme(
|
|
|
|
builders: {
|
|
|
|
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
|
|
|
|
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
|
|
|
TargetPlatform.fuchsia: CupertinoPageTransitionsBuilder(),
|
|
|
|
},
|
|
|
|
),
|
2021-02-09 15:12:13 +01:00
|
|
|
scaffoldBackgroundColor: maybeAmoledColor,
|
|
|
|
backgroundColor: maybeAmoledColor,
|
|
|
|
canvasColor: maybeAmoledColor,
|
|
|
|
cardColor: maybeAmoledColor,
|
|
|
|
splashColor: maybeAmoledColor,
|
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
|
appBarTheme: AppBarTheme(
|
|
|
|
elevation: 0,
|
2021-09-12 22:37:07 +02:00
|
|
|
systemOverlayStyle: theme.brightness == Brightness.dark
|
|
|
|
? SystemUiOverlayStyle.light
|
|
|
|
: SystemUiOverlayStyle.dark,
|
2021-02-09 15:12:13 +01:00
|
|
|
color: Colors.transparent,
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
centerTitle: true,
|
|
|
|
iconTheme: IconThemeData(color: theme.colorScheme.onSurface),
|
2021-09-12 22:37:07 +02:00
|
|
|
titleTextStyle: theme.textTheme.headline6
|
|
|
|
?.copyWith(fontSize: 20, fontWeight: FontWeight.w500),
|
2021-02-09 15:12:13 +01:00
|
|
|
),
|
|
|
|
tabBarTheme: TabBarTheme(
|
|
|
|
unselectedLabelColor: Colors.grey,
|
|
|
|
labelColor: theme.colorScheme.onSurface,
|
|
|
|
),
|
|
|
|
chipTheme: ChipThemeData(
|
2021-09-12 22:37:07 +02:00
|
|
|
backgroundColor: theme.colorScheme.secondary,
|
2021-02-09 15:12:13 +01:00
|
|
|
disabledColor: Colors.amber,
|
|
|
|
selectedColor: Colors.amber,
|
|
|
|
secondarySelectedColor: Colors.amber,
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
shape: const StadiumBorder(),
|
2021-09-12 22:37:07 +02:00
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: textColorBasedOnBackground(theme.colorScheme.secondary),
|
|
|
|
),
|
2021-02-09 15:12:13 +01:00
|
|
|
secondaryLabelStyle: const TextStyle(color: Colors.amber),
|
|
|
|
brightness: theme.brightness,
|
|
|
|
labelPadding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
),
|
|
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
|
|
contentPadding: const EdgeInsets.all(10),
|
|
|
|
isDense: true,
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
style: ElevatedButton.styleFrom(
|
2021-09-12 22:37:07 +02:00
|
|
|
primary: theme.colorScheme.secondary,
|
|
|
|
onPrimary: textColorBasedOnBackground(theme.colorScheme.secondary),
|
2021-02-09 15:12:13 +01:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
textButtonTheme: TextButtonThemeData(
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
primary: theme.colorScheme.onSurface,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
primary: theme.colorScheme.onSurface,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-10-24 22:48:04 +02:00
|
|
|
dialogTheme: DialogTheme(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
),
|
2021-02-09 15:12:13 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final lightTheme = _themeFactory();
|
|
|
|
final darkTheme = _themeFactory(dark: true);
|
|
|
|
final amoledTheme = _themeFactory(dark: true, amoled: true);
|