Fix deprecation notices and reset styles.

This commit is contained in:
Dain Nilsson 2023-01-26 11:52:01 +01:00
parent 8d4e13fe81
commit b263f82293
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
14 changed files with 54 additions and 32 deletions

View File

@ -23,6 +23,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../desktop/models.dart';
import '../../desktop/state.dart';
import '../message.dart';
import '../state.dart';
import 'graphics.dart';
import 'message_page.dart';
@ -74,7 +75,11 @@ class AppFailurePage extends ConsumerWidget {
if (await ref.read(rpcProvider).requireValue.elevate()) {
ref.invalidate(rpcProvider);
} else {
showMessage(context, 'Permission denied');
await ref.read(withContextProvider)(
(context) async {
showMessage(context, 'Permission denied');
},
);
}
} finally {
closeMessage();

View File

@ -23,6 +23,7 @@ import '../../core/models.dart';
import '../../desktop/state.dart';
import '../message.dart';
import '../models.dart';
import '../state.dart';
import 'device_avatar.dart';
import 'graphics.dart';
import 'message_page.dart';
@ -51,7 +52,8 @@ class DeviceErrorScreen extends ConsumerWidget {
if (await ref.read(rpcProvider).requireValue.elevate()) {
ref.invalidate(rpcProvider);
} else {
showMessage(context, 'Permission denied');
await ref.read(withContextProvider)((context) async =>
showMessage(context, 'Permission denied'));
}
} finally {
closeMessage();

View File

@ -87,18 +87,20 @@ class MainPage extends ConsumerWidget {
return;
}
}
await showBlurDialog(
context: context,
routeSettings: const RouteSettings(name: 'oath_add_account'),
builder: (context) {
return OathAddAccountPage(
null,
null,
credentials: null,
credentialData: otpauth,
);
},
);
await ref.read(withContextProvider)((context) => showBlurDialog(
context: context,
routeSettings:
const RouteSettings(name: 'oath_add_account'),
builder: (context) {
return OathAddAccountPage(
null,
null,
credentials: null,
credentialData: otpauth,
);
},
));
},
),
);
@ -118,7 +120,8 @@ class MainPage extends ConsumerWidget {
return const MessagePage(
header: 'Device not recognized',
);
} else if (app.getAvailability(data) == Availability.unsupported) {
} else if (app.getAvailability(data) ==
Availability.unsupported) {
return MessagePage(
header: 'Application not supported',
message:

View File

@ -92,7 +92,7 @@ class _UserInteractionDialogState extends State<_UserInteractionDialog> {
),
Text(
widget.controller.title,
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
widget.controller.description,

View File

@ -55,11 +55,6 @@ class _LockKeyNotifier extends StateNotifier<String?> {
unsetKey() {
state = null;
}
@override
void dispose() {
super.dispose();
}
}
final desktopOathState = StateNotifierProvider.autoDispose

View File

@ -33,7 +33,7 @@ class ErrorPage extends StatelessWidget {
children: [
Text(
error,
style: Theme.of(context).textTheme.headline4,
style: Theme.of(context).textTheme.headlineMedium,
),
],
),

View File

@ -115,7 +115,7 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
.fido_warning_will_delete_accounts),
Text(
AppLocalizations.of(context)!.fido_warning_disable_these_creds,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
Center(
child: Text(_getMessage(),

View File

@ -170,7 +170,7 @@ class AccountDialog extends ConsumerWidget with AccountMixin {
textAlign: TextAlign.center,
// This is what ListTile uses for subtitle
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).textTheme.caption!.color,
color: Theme.of(context).textTheme.bodySmall!.color,
),
),
const SizedBox(height: 12.0),

View File

@ -73,7 +73,7 @@ class DeleteAccountDialog extends ConsumerWidget {
.oath_warning_this_will_delete_account_from_key),
Text(
AppLocalizations.of(context)!.oath_warning_disable_this_cred,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
Text('${AppLocalizations.of(context)!.oath_account} $label'),
]

View File

@ -149,7 +149,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
controller: searchController,
focusNode: searchFocus,
// Use the default style, but with a smaller font size:
style: textTheme.subtitle1
style: textTheme.titleMedium
?.copyWith(fontSize: textTheme.titleSmall?.fontSize),
decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.oath_search_accounts,

View File

@ -53,7 +53,7 @@ class ResetDialog extends ConsumerWidget {
.oath_warning_will_delete_accounts),
Text(
AppLocalizations.of(context)!.oath_warning_disable_these_creds,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
]
.map((e) => Padding(

View File

@ -15,7 +15,6 @@
*/
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
const primaryGreen = Color(0xffaed581);
const accentGreen = Color(0xff9aca3c);
@ -24,6 +23,13 @@ const primaryRed = Color(0xffea4335);
const darkRed = Color(0xffda4d41);
class AppTheme {
static ThemeData get lightTheme => ThemeData(
useMaterial3: true,
brightness: Brightness.light,
colorSchemeSeed: primaryBlue,
);
/* 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(
useMaterial3: true,
brightness: Brightness.light,
@ -106,7 +112,15 @@ class AppTheme {
fontSize: 16),
),
);
*/
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,
brightness: Brightness.dark,
@ -200,8 +214,10 @@ class AppTheme {
fontSize: 16),
),
);
*/
}
/* TODO: Remove this. It is left here as a reference as we adjust styles to work with Flutter 3.7.
/// This fixes the issue with FilterChip resizing vertically on toggle.
BorderSide? _chipBorder(Color color) =>
MaterialStateBorderSide.resolveWith((states) => BorderSide(
@ -209,3 +225,4 @@ BorderSide? _chipBorder(Color color) =>
color: states.contains(MaterialState.selected)
? Colors.transparent
: color));
*/

View File

@ -112,7 +112,7 @@ void Function() showToast(
final textStyle =
ThemeData(brightness: isThemeDark ? Brightness.light : Brightness.dark)
.textTheme
.subtitle1;
.titleMedium;
OverlayEntry? entry;
void close() {
@ -146,7 +146,7 @@ void Function() showToast(
);
});
Timer.run(() {
Overlay.of(context)!.insert(entry!);
Overlay.of(context).insert(entry!);
});
return close;

View File

@ -30,10 +30,10 @@ int byteLength(String value) => utf8.encode(value).length;
InputCounterWidgetBuilder buildByteCounterFor(String currentValue) =>
(context, {required currentLength, required isFocused, maxLength}) {
final theme = Theme.of(context);
final caption = theme.textTheme.caption;
final caption = theme.textTheme.bodySmall;
final style = (byteLength(currentValue) <= (maxLength ?? 0))
? caption
: caption?.copyWith(color: theme.errorColor);
: caption?.copyWith(color: theme.colorScheme.error);
return Text(
maxLength != null ? '${byteLength(currentValue)}/$maxLength' : '',
style: style,