From ca133b5c6c1128d4e4c67b939e2e0fee84799d19 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 3 Feb 2023 09:56:23 +0100 Subject: [PATCH] Fix incorrect theme usages. --- lib/app/views/device_avatar.dart | 11 +++++++---- lib/app/views/device_picker_dialog.dart | 11 ++++++----- lib/fido/views/key_actions.dart | 3 +-- lib/oath/views/account_dialog.dart | 5 ++--- lib/oath/views/account_mixin.dart | 4 ++++ lib/oath/views/account_view.dart | 6 +++--- lib/oath/views/key_actions.dart | 3 +-- lib/widgets/choice_filter_chip.dart | 5 +++-- lib/widgets/circle_timer.dart | 3 +-- 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/app/views/device_avatar.dart b/lib/app/views/device_avatar.dart index d07c60b6..da84a29c 100755 --- a/lib/app/views/device_avatar.dart +++ b/lib/app/views/device_avatar.dart @@ -16,12 +16,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:yubico_authenticator/management/models.dart'; -import 'package:yubico_authenticator/widgets/product_image.dart'; import '../../core/models.dart'; import '../../core/state.dart'; +import '../../management/models.dart'; import '../../widgets/custom_icons.dart'; +import '../../widgets/product_image.dart'; import '../models.dart'; import '../state.dart'; import 'keys.dart'; @@ -55,7 +55,10 @@ class DeviceAvatar extends StatelessWidget { return DeviceAvatar( radius: radius, child: const ProductImage( - name: '', formFactor: FormFactor.unknown, isNfc: false), + name: '', + formFactor: FormFactor.unknown, + isNfc: false, + ), ); }, nfcReader: (_) => DeviceAvatar( @@ -94,7 +97,7 @@ class DeviceAvatar extends StatelessWidget { children: [ CircleAvatar( radius: radius, - backgroundColor: Theme.of(context).colorScheme.background, + //backgroundColor: Theme.of(context).colorScheme.surfaceVariant, child: IconTheme( data: IconTheme.of(context).copyWith( size: radius, diff --git a/lib/app/views/device_picker_dialog.dart b/lib/app/views/device_picker_dialog.dart index 8048f708..275fc473 100755 --- a/lib/app/views/device_picker_dialog.dart +++ b/lib/app/views/device_picker_dialog.dart @@ -246,9 +246,10 @@ class _HeroAvatar extends StatelessWidget { shape: BoxShape.circle, gradient: RadialGradient( colors: [ - theme.colorScheme.background, - theme.colorScheme.background.withOpacity(0.4), - (theme.dialogTheme.backgroundColor ?? theme.dialogBackgroundColor) + theme.colorScheme.inverseSurface.withOpacity(0.6), + theme.colorScheme.inverseSurface.withOpacity(0.25), + (DialogTheme.of(context).backgroundColor ?? + theme.dialogBackgroundColor) .withOpacity(0), ], ), @@ -257,8 +258,8 @@ class _HeroAvatar extends StatelessWidget { child: Theme( // Give the avatar a transparent background data: theme.copyWith( - colorScheme: - theme.colorScheme.copyWith(background: Colors.transparent)), + colorScheme: theme.colorScheme + .copyWith(primaryContainer: Colors.transparent)), child: child, ), ); diff --git a/lib/fido/views/key_actions.dart b/lib/fido/views/key_actions.dart index f7a675fc..62440fd7 100755 --- a/lib/fido/views/key_actions.dart +++ b/lib/fido/views/key_actions.dart @@ -27,8 +27,7 @@ import 'reset_dialog.dart'; Widget fidoBuildActions( BuildContext context, DeviceNode node, FidoState state, int fingerprints) { - final theme = - ButtonTheme.of(context).colorScheme ?? Theme.of(context).colorScheme; + final theme = Theme.of(context).colorScheme; return SimpleDialog( children: [ if (state.bioEnroll != null) ...[ diff --git a/lib/oath/views/account_dialog.dart b/lib/oath/views/account_dialog.dart index 81c5e778..bf36de76 100755 --- a/lib/oath/views/account_dialog.dart +++ b/lib/oath/views/account_dialog.dart @@ -66,8 +66,7 @@ class AccountDialog extends ConsumerWidget with AccountMixin { List _buildActions(BuildContext context, WidgetRef ref) { final actions = buildActions(context, ref); - final theme = - ButtonTheme.of(context).colorScheme ?? Theme.of(context).colorScheme; + final theme = Theme.of(context).colorScheme; final copy = actions.firstWhere(((e) => e.text.startsWith('Copy'))); final delete = actions.firstWhere(((e) => e.text.startsWith('Delete'))); @@ -177,7 +176,7 @@ class AccountDialog extends ConsumerWidget with AccountMixin { DecoratedBox( decoration: BoxDecoration( shape: BoxShape.rectangle, - color: CardTheme.of(context).color, + color: Theme.of(context).colorScheme.surfaceVariant, borderRadius: const BorderRadius.all(Radius.circular(30.0)), ), child: Center( diff --git a/lib/oath/views/account_mixin.dart b/lib/oath/views/account_mixin.dart index 149b955a..f08dea02 100755 --- a/lib/oath/views/account_mixin.dart +++ b/lib/oath/views/account_mixin.dart @@ -246,6 +246,10 @@ mixin AccountMixin { fontFeatures: [FontFeature.tabularFigures()], //fontWeight: FontWeight.w400, ), + textHeightBehavior: const TextHeightBehavior( + // This helps with vertical centering + applyHeightToFirstAscent: false, + ), ), ), ], diff --git a/lib/oath/views/account_view.dart b/lib/oath/views/account_view.dart index b3eeafc4..efd9c487 100755 --- a/lib/oath/views/account_view.dart +++ b/lib/oath/views/account_view.dart @@ -176,12 +176,12 @@ class AccountView extends ConsumerWidget with AccountMixin { child: DecoratedBox( decoration: BoxDecoration( shape: BoxShape.rectangle, - color: CardTheme.of(context).color, - borderRadius: const BorderRadius.all(Radius.circular(30.0)), + color: Theme.of(context).colorScheme.surfaceVariant, + borderRadius: const BorderRadius.all(Radius.circular(64.0)), ), child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 10.0, vertical: 2.0), + horizontal: 8.0, vertical: 4.0), child: DefaultTextStyle.merge( style: Theme.of(context).textTheme.bodyLarge, child: buildCodeView(ref), diff --git a/lib/oath/views/key_actions.dart b/lib/oath/views/key_actions.dart index c3e72365..d550ccba 100755 --- a/lib/oath/views/key_actions.dart +++ b/lib/oath/views/key_actions.dart @@ -40,8 +40,7 @@ Widget oathBuildActions( int? used, }) { final capacity = oathState.version.isAtLeast(4) ? 32 : null; - final theme = - ButtonTheme.of(context).colorScheme ?? Theme.of(context).colorScheme; + final theme = Theme.of(context).colorScheme; return SimpleDialog( children: [ ListTitle(AppLocalizations.of(context)!.general_setup, diff --git a/lib/widgets/choice_filter_chip.dart b/lib/widgets/choice_filter_chip.dart index add387e8..0b8c14d5 100755 --- a/lib/widgets/choice_filter_chip.dart +++ b/lib/widgets/choice_filter_chip.dart @@ -69,7 +69,7 @@ class _ChoiceFilterChipState extends State> { .map((e) => PopupMenuItem( value: e, height: chipBox.size.height, - textStyle: Theme.of(context).chipTheme.labelStyle, + textStyle: ChipTheme.of(context).labelStyle, child: widget.itemBuilder(e), )) .toList(), @@ -89,7 +89,8 @@ class _ChoiceFilterChipState extends State> { padding: const EdgeInsets.only(left: 6), child: Icon( _showing ? Icons.arrow_drop_up : Icons.arrow_drop_down, - color: Theme.of(context).chipTheme.checkmarkColor, + color: ChipTheme.of(context).checkmarkColor, + size: 18, ), ), ], diff --git a/lib/widgets/circle_timer.dart b/lib/widgets/circle_timer.dart index 7556b30b..578316b0 100755 --- a/lib/widgets/circle_timer.dart +++ b/lib/widgets/circle_timer.dart @@ -76,7 +76,6 @@ class _CircleTimerState extends State @override Widget build(BuildContext context) { return ProgressCircle( - Theme.of(context).iconTheme.color ?? Colors.grey.shade600, - _progress.value); + IconTheme.of(context).color ?? Colors.grey.shade600, _progress.value); } }