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) {
|
List<Widget> _buildActions(BuildContext context, WidgetRef ref) {
|
||||||
final actions = buildActions(context, 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 copy = actions.firstWhere(((e) => e.text.startsWith('Copy')));
|
||||||
final delete = actions.firstWhere(((e) => e.text.startsWith('Delete')));
|
final delete = actions.firstWhere(((e) => e.text.startsWith('Delete')));
|
||||||
final colors = {
|
final colors = {
|
||||||
copy: Pair(theme.primary, theme.onPrimary),
|
copy: Pair(colorScheme.secondary, colorScheme.onSecondary),
|
||||||
delete: Pair(theme.error, theme.onError),
|
delete: Pair(colorScheme.error, colorScheme.onError),
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we can't copy, but can calculate, highlight that button instead
|
// If we can't copy, but can calculate, highlight that button instead
|
||||||
if (copy.action == null) {
|
if (copy.action == null) {
|
||||||
final calculates = actions.where(((e) => e.text.startsWith('Calculate')));
|
final calculates = actions.where(((e) => e.text.startsWith('Calculate')));
|
||||||
if (calculates.isNotEmpty) {
|
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) {
|
return actions.map((e) {
|
||||||
final action = e.action;
|
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;
|
final tooltip = e.trailing != null ? '${e.text}\n${e.trailing}' : e.text;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||||
child: CircleAvatar(
|
child: IconButton(
|
||||||
backgroundColor: action != null ? color.first : theme.secondary,
|
style: IconButton.styleFrom(
|
||||||
foregroundColor: color.second,
|
backgroundColor: color.first,
|
||||||
child: IconButton(
|
disabledBackgroundColor: color.first?.withOpacity(0.4),
|
||||||
style: IconButton.styleFrom(
|
foregroundColor: color.second,
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
|
icon: e.icon,
|
||||||
|
tooltip: tooltip,
|
||||||
|
onPressed: action != null
|
||||||
|
? () {
|
||||||
|
action(context);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
@ -25,8 +25,29 @@ const darkRed = Color(0xffda4d41);
|
|||||||
class AppTheme {
|
class AppTheme {
|
||||||
static ThemeData get lightTheme => ThemeData(
|
static ThemeData get lightTheme => ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
brightness: Brightness.light,
|
colorScheme: ColorScheme.fromSeed(
|
||||||
colorSchemeSeed: primaryBlue,
|
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.
|
/* 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.
|
/* 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(
|
static ThemeData get darkTheme => ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user