lemmur-app-android/lib/theme.dart

99 lines
3.3 KiB
Dart
Raw Normal View History

2021-02-09 15:12:13 +01:00
import 'package:flutter/material.dart';
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(
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,
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),
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(
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(),
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(
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),
),
),
),
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);