yubioath-flutter/lib/theme.dart

263 lines
9.9 KiB
Dart
Raw Normal View History

2022-10-04 13:12:54 +03:00
/*
* Copyright (C) 2022 Yubico.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'package:flutter/material.dart';
const primaryGreen = Color(0xffaed581);
2022-02-22 12:56:52 +03:00
const accentGreen = Color(0xff9aca3c);
const primaryBlue = Color(0xff325f74);
2022-05-20 15:10:17 +03:00
const primaryRed = Color(0xffea4335);
2022-09-07 10:19:30 +03:00
const darkRed = Color(0xffda4d41);
2023-06-16 18:27:10 +03:00
const amber = Color(0xffffca28);
2022-02-21 19:07:52 +03:00
class AppTheme {
static ThemeData get lightTheme => ThemeData(
useMaterial3: true,
2023-02-03 12:48:51 +03:00
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.light,
2023-02-07 16:01:17 +03:00
seedColor: const Color(0xff2196f3),
//seedColor: primaryBlue,
2023-02-03 12:48:51 +03:00
).copyWith(
primary: primaryBlue,
2023-02-07 16:01:17 +03:00
//secondary: accentGreen,
2023-06-16 18:27:10 +03:00
tertiary: amber.withOpacity(0.7),
2023-02-07 16:01:17 +03:00
),
textTheme: TextTheme(
bodySmall: TextStyle(color: Colors.grey.shade900),
),
dialogTheme: const DialogTheme(
surfaceTintColor: Colors.white70,
2023-02-03 12:48:51 +03:00
),
);
static ThemeData get darkTheme => ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
2023-02-07 16:01:17 +03:00
seedColor: const Color(0xff2196f3),
//seedColor: const Color(0xff3f51b5),
2023-02-03 12:48:51 +03:00
).copyWith(
primary: primaryGreen,
2023-02-07 16:01:17 +03:00
//onPrimary: Colors.grey.shade900,
//secondary: accentGreen,
//secondary: const Color(0xff5d7d90),
//onSecondary: Colors.grey.shade900,
//primaryContainer: Colors.grey.shade800,
//onPrimaryContainer: Colors.grey.shade100,
2023-02-03 12:48:51 +03:00
error: darkRed,
onError: Colors.white.withOpacity(0.9),
2023-06-16 18:27:10 +03:00
tertiary: amber.withOpacity(0.7),
2023-02-03 12:48:51 +03:00
),
2023-02-07 16:01:17 +03:00
textTheme: TextTheme(
bodySmall: TextStyle(color: Colors.grey.shade500),
),
dialogTheme: DialogTheme(
surfaceTintColor: Colors.grey.shade700,
),
);
/* TODO: Remove this. It is left here as a reference as we adjust styles to work with Flutter 3.7.
static ThemeData get lightTheme => ThemeData(
2022-03-28 15:59:07 +03:00
useMaterial3: true,
brightness: Brightness.light,
2022-02-22 12:56:52 +03:00
colorScheme:
ColorScheme.fromSwatch(brightness: Brightness.light).copyWith(
primary: primaryBlue,
secondary: accentGreen,
background: Colors.grey.shade200,
),
2022-05-20 12:10:49 +03:00
iconTheme: IconThemeData(
color: Colors.grey.shade400,
size: 18.0,
),
//backgroundColor: Colors.white,
2022-02-22 12:56:52 +03:00
toggleableActiveColor: accentGreen,
appBarTheme: AppBarTheme(
2022-09-23 11:12:54 +03:00
elevation: 0,
toolbarHeight: 48,
//shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
backgroundColor: Colors.transparent,
foregroundColor: Colors.grey.shade800,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
systemNavigationBarIconBrightness: Brightness.dark)),
// Mainly used for the OATH dialog view at the moment
buttonTheme: ButtonThemeData(
colorScheme: ColorScheme.light(
2022-05-19 14:53:48 +03:00
secondary: Colors.grey.shade300,
2022-05-20 15:10:17 +03:00
onSecondary: Colors.grey.shade900,
primary: primaryGreen,
2022-05-20 15:10:17 +03:00
onPrimary: Colors.grey.shade900,
error: primaryRed,
onError: Colors.grey.shade100,
),
),
2022-06-08 17:11:32 +03:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
2022-09-23 11:12:54 +03:00
foregroundColor: Colors.white,
backgroundColor: primaryBlue,
2022-06-08 17:11:32 +03:00
)),
2022-05-20 12:10:49 +03:00
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
side: BorderSide(width: 1, color: Colors.grey.shade400),
)),
cardTheme: CardTheme(
color: Colors.grey.shade300,
),
2022-05-20 12:10:49 +03:00
chipTheme: ChipThemeData(
2022-05-20 15:10:17 +03:00
selectedColor: const Color(0xffd2dbdf),
2022-09-23 11:12:54 +03:00
side: _chipBorder(Colors.grey.shade400),
2022-09-01 11:14:59 +03:00
checkmarkColor: Colors.black,
2022-05-20 12:10:49 +03:00
),
2022-04-05 17:36:03 +03:00
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: primaryBlue,
),
listTileTheme: const ListTileThemeData(
// For alignment under menu button
contentPadding: EdgeInsets.symmetric(horizontal: 18.0),
visualDensity: VisualDensity.compact,
),
2022-05-18 11:30:50 +03:00
fontFamily: 'Roboto',
textTheme: const TextTheme(
//bodySmall: TextStyle(color: Colors.grey.shade500),
//bodyLarge: const TextStyle(color: Colors.white70),
//bodyMedium: TextStyle(color: Colors.grey.shade200),
//labelSmall: TextStyle(color: Colors.grey.shade500),
//labelMedium: TextStyle(color: Colors.cyan.shade200),
//labelLarge: TextStyle(color: Colors.cyan.shade500),
//titleSmall: TextStyle(color: Colors.grey.shade600),
//titleMedium: const TextStyle(),
2022-09-23 11:12:54 +03:00
titleMedium: TextStyle(fontWeight: FontWeight.w300, fontSize: 16),
titleLarge: TextStyle(
//color: Colors.grey.shade500,
fontWeight: FontWeight.w400,
fontSize: 18),
headlineSmall: TextStyle(
//color: Colors.grey.shade200,
fontWeight: FontWeight.w300,
fontSize: 16),
2022-02-22 12:56:52 +03:00
),
);
*/
/* TODO: Remove this. It is left here as a reference as we adjust styles to work with Flutter 3.7.
static ThemeData get darkTheme => ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorScheme:
ColorScheme.fromSwatch(brightness: Brightness.dark).copyWith(
primary: primaryGreen,
2022-05-20 15:10:17 +03:00
onPrimary: Colors.black,
secondary: const Color(0xff5d7d90),
),
// Default for CircleAvatar background if foreground is light
primaryColorDark: Colors.white38,
2022-09-07 10:19:30 +03:00
errorColor: darkRed,
2022-05-20 12:10:49 +03:00
iconTheme: const IconThemeData(
color: Colors.white70,
size: 18.0,
),
toggleableActiveColor: primaryGreen,
appBarTheme: AppBarTheme(
2022-09-23 11:12:54 +03:00
elevation: 0,
toolbarHeight: 48,
//shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
backgroundColor: Colors.transparent,
foregroundColor: Colors.grey.shade400,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light)),
2022-05-19 14:53:48 +03:00
// Mainly used for the OATH dialog view at the moment
buttonTheme: ButtonThemeData(
colorScheme: ColorScheme.dark(
2022-05-19 14:53:48 +03:00
secondary: Colors.grey.shade800,
2022-06-02 18:01:40 +03:00
onSecondary: Colors.white,
primary: primaryGreen,
2022-05-20 15:10:17 +03:00
onPrimary: Colors.grey.shade900,
2022-09-07 10:19:30 +03:00
error: darkRed,
2022-05-20 15:10:17 +03:00
onError: Colors.grey.shade100,
),
),
2022-06-08 17:11:32 +03:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
2022-09-23 11:12:54 +03:00
foregroundColor: Colors.black,
backgroundColor: primaryGreen,
2022-06-08 17:11:32 +03:00
)),
2022-05-20 12:10:49 +03:00
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
2022-09-06 15:52:14 +03:00
side: BorderSide(width: 1, color: Colors.grey.shade400),
2022-05-20 12:10:49 +03:00
)),
cardTheme: CardTheme(
color: Colors.grey.shade800,
),
2022-05-20 12:10:49 +03:00
chipTheme: ChipThemeData(
selectedColor: Colors.white12,
2022-09-23 11:12:54 +03:00
side: _chipBorder(Colors.white12),
labelStyle: TextStyle(
2022-09-01 11:14:59 +03:00
color: Colors.grey.shade200,
),
checkmarkColor: Colors.grey.shade200,
2022-05-20 12:10:49 +03:00
),
dialogTheme: const DialogTheme(
backgroundColor: Color(0xff323232),
),
floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.grey.shade900,
backgroundColor: primaryGreen,
),
listTileTheme: const ListTileThemeData(
// For alignment under menu button
contentPadding: EdgeInsets.symmetric(horizontal: 18.0),
visualDensity: VisualDensity.compact,
),
fontFamily: 'Roboto',
textTheme: TextTheme(
bodySmall: TextStyle(color: Colors.grey.shade500),
bodyLarge: const TextStyle(color: Colors.white70),
bodyMedium: TextStyle(color: Colors.grey.shade200),
labelSmall: TextStyle(color: Colors.grey.shade500),
labelMedium: TextStyle(color: Colors.cyan.shade200),
2022-09-07 10:46:28 +03:00
labelLarge: TextStyle(color: Colors.grey.shade400),
titleSmall: TextStyle(color: Colors.grey.shade600),
titleMedium: TextStyle(
color: Colors.grey.shade200,
fontWeight: FontWeight.w300,
fontSize: 16),
titleLarge: TextStyle(
2022-05-18 11:30:50 +03:00
color: Colors.grey.shade500,
fontWeight: FontWeight.w400,
fontSize: 18),
headlineSmall: TextStyle(
color: Colors.grey.shade200,
fontWeight: FontWeight.w300,
fontSize: 16),
),
);
*/
}
2022-09-01 11:14:59 +03:00
/* TODO: Remove this. It is left here as a reference as we adjust styles to work with Flutter 3.7.
2022-09-01 11:14:59 +03:00
/// This fixes the issue with FilterChip resizing vertically on toggle.
2022-09-23 11:12:54 +03:00
BorderSide? _chipBorder(Color color) =>
MaterialStateBorderSide.resolveWith((states) => BorderSide(
width: 1,
color: states.contains(MaterialState.selected)
? Colors.transparent
: color));
*/