treewide: small refactors
This commit is contained in:
parent
9117663c48
commit
8d944831f5
10 changed files with 63 additions and 63 deletions
|
|
@ -6,6 +6,7 @@ import "package:hooks_riverpod/hooks_riverpod.dart";
|
|||
import "package:nexus/controllers/auth_url.dart";
|
||||
import "package:nexus/controllers/client.dart";
|
||||
import "package:nexus/controllers/client_id.dart";
|
||||
import "package:nexus/helpers/extensions/show_error_snack_bar.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:nexus/main.dart";
|
||||
import "package:nexus/models/gomuks_exception.dart";
|
||||
|
|
@ -27,14 +28,8 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
|||
|
||||
Future<void> setHomeserver(Uri? newHomeserver) async {
|
||||
if (newHomeserver == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"Failed to parse homeserver URL. Are you sure you typed it correctly?",
|
||||
style: .new(color: theme.colorScheme.onErrorContainer),
|
||||
),
|
||||
backgroundColor: theme.colorScheme.errorContainer,
|
||||
),
|
||||
ScaffoldMessenger.of(context).showErrorSnackBar(
|
||||
"Failed to parse homeserver URL. Are you sure you typed it correctly?",
|
||||
);
|
||||
}
|
||||
isLoading.value = true;
|
||||
|
|
@ -58,14 +53,8 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
|||
} on GomuksException catch (error) {
|
||||
if (error.errorCode != "M_UNRECOGNIZED") rethrow;
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"${url.host} doesn't support OAuth login, which Nexus requires. Try a different homeserver, or ask your homeserver's admin to enable OAuth.",
|
||||
style: .new(color: theme.colorScheme.onErrorContainer),
|
||||
),
|
||||
backgroundColor: theme.colorScheme.errorContainer,
|
||||
),
|
||||
ScaffoldMessenger.of(context).showErrorSnackBar(
|
||||
"${url.host} doesn't support OAuth login, which Nexus requires. Try a different homeserver, or ask your homeserver's admin to enable OAuth.",
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
|
@ -109,18 +98,11 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
if (newUrl == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"Homeserver verification failed.",
|
||||
style: .new(color: theme.colorScheme.onErrorContainer),
|
||||
),
|
||||
action: SnackBarAction(
|
||||
onPressed: () => tryLogin(newHomeserver!).onError(showError),
|
||||
label: "Attempt log in anyways",
|
||||
textColor: theme.colorScheme.onErrorContainer,
|
||||
),
|
||||
backgroundColor: theme.colorScheme.errorContainer,
|
||||
ScaffoldMessenger.of(context).showErrorSnackBar(
|
||||
"Homeserver verification failed.",
|
||||
action: (
|
||||
label: "Attempt log in anyways",
|
||||
onPressed: () => tryLogin(newHomeserver!).onError(showError),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import "package:m3e_card_list/m3e_card_list.dart";
|
|||
import "package:navigation_rail_m3e/navigation_rail_m3e.dart";
|
||||
import "package:nexus/controllers/settings_sections.dart";
|
||||
import "package:nexus/helpers/extensions/better_when.dart";
|
||||
import "package:nexus/helpers/extensions/show_about_dialog.dart";
|
||||
import "package:nexus/helpers/extensions/show_about_sheet.dart";
|
||||
import "package:nexus/widgets/pages/settings_category.dart";
|
||||
import "package:nexus/widgets/divider_text.dart";
|
||||
import "package:nexus/widgets/highlight_wrapper.dart";
|
||||
|
|
@ -106,7 +106,7 @@ class const SettingsPage({super.key}) extends ConsumerWidget {
|
|||
actionsPadding: .symmetric(horizontal: 12),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => context.showAboutDialog(ref),
|
||||
onPressed: () => context.showAboutSheet(ref),
|
||||
icon: Icon(Icons.info_outline),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue