mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Set up some base colors for testing.
This commit is contained in:
parent
ca133b5c6c
commit
6c842049b6
@ -66,48 +66,45 @@ class AccountDialog extends ConsumerWidget with AccountMixin {
|
||||
List<Widget> _buildActions(BuildContext context, WidgetRef ref) {
|
||||
final actions = buildActions(context, ref);
|
||||
|
||||
final theme = Theme.of(context).colorScheme;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
final copy = actions.firstWhere(((e) => e.text.startsWith('Copy')));
|
||||
final delete = actions.firstWhere(((e) => e.text.startsWith('Delete')));
|
||||
final colors = {
|
||||
copy: Pair(theme.primary, theme.onPrimary),
|
||||
delete: Pair(theme.error, theme.onError),
|
||||
copy: Pair(colorScheme.secondary, colorScheme.onSecondary),
|
||||
delete: Pair(colorScheme.error, colorScheme.onError),
|
||||
};
|
||||
|
||||
// If we can't copy, but can calculate, highlight that button instead
|
||||
if (copy.action == null) {
|
||||
final calculates = actions.where(((e) => e.text.startsWith('Calculate')));
|
||||
if (calculates.isNotEmpty) {
|
||||
colors[calculates.first] = Pair(theme.primary, theme.onPrimary);
|
||||
colors[calculates.first] =
|
||||
Pair(colorScheme.secondary, colorScheme.onSecondary);
|
||||
colors.remove(copy);
|
||||
}
|
||||
}
|
||||
|
||||
return actions.map((e) {
|
||||
final action = e.action;
|
||||
final color = colors[e] ?? Pair(theme.secondary, theme.onSecondary);
|
||||
final Pair<Color?, Color?> color = colors[e] ??
|
||||
Pair(colorScheme.surfaceVariant, colorScheme.onSurfaceVariant);
|
||||
final tooltip = e.trailing != null ? '${e.text}\n${e.trailing}' : e.text;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: action != null ? color.first : theme.secondary,
|
||||
foregroundColor: color.second,
|
||||
child: IconButton(
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: action != null ? color.first : theme.secondary,
|
||||
foregroundColor: color.second,
|
||||
disabledBackgroundColor: theme.onSecondary.withOpacity(0.2),
|
||||
fixedSize: const Size.square(38),
|
||||
),
|
||||
icon: e.icon,
|
||||
iconSize: 22,
|
||||
tooltip: tooltip,
|
||||
onPressed: action != null
|
||||
? () {
|
||||
action(context);
|
||||
}
|
||||
: null,
|
||||
child: IconButton(
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: color.first,
|
||||
disabledBackgroundColor: color.first?.withOpacity(0.4),
|
||||
foregroundColor: color.second,
|
||||
),
|
||||
icon: e.icon,
|
||||
tooltip: tooltip,
|
||||
onPressed: action != null
|
||||
? () {
|
||||
action(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
|
@ -25,8 +25,29 @@ const darkRed = Color(0xffda4d41);
|
||||
class AppTheme {
|
||||
static ThemeData get lightTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
colorSchemeSeed: primaryBlue,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
brightness: Brightness.light,
|
||||
seedColor: primaryBlue,
|
||||
).copyWith(
|
||||
primary: primaryBlue,
|
||||
secondary: accentGreen,
|
||||
),
|
||||
);
|
||||
|
||||
static ThemeData get darkTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
brightness: Brightness.dark,
|
||||
seedColor: primaryBlue,
|
||||
).copyWith(
|
||||
primary: primaryGreen,
|
||||
onPrimary: Colors.grey.shade900,
|
||||
secondary: accentGreen,
|
||||
primaryContainer: Colors.grey.shade800,
|
||||
onPrimaryContainer: Colors.grey.shade100,
|
||||
error: darkRed,
|
||||
onError: Colors.white.withOpacity(0.9),
|
||||
),
|
||||
);
|
||||
|
||||
/* TODO: Remove this. It is left here as a reference as we adjust styles to work with Flutter 3.7.
|
||||
@ -114,12 +135,6 @@ class AppTheme {
|
||||
);
|
||||
*/
|
||||
|
||||
static ThemeData get darkTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: primaryGreen,
|
||||
);
|
||||
|
||||
/* 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,
|
||||
|
Loading…
Reference in New Issue
Block a user