Set up some base colors for testing.

This commit is contained in:
Dain Nilsson 2023-02-03 10:48:51 +01:00
parent ca133b5c6c
commit 6c842049b6
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
2 changed files with 43 additions and 31 deletions

View File

@ -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();

View File

@ -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,