From 00f22d46b7b5cf568047ae082ced1eb6c22ec5a5 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Fri, 16 Oct 2026 10:56:55 -0400 Subject: [PATCH] slight cleanups --- lib/controllers/client.dart | 7 +++---- lib/helpers/hooks/chat_scroll.dart | 6 +++--- lib/widgets/highlight_wrapper.dart | 2 +- lib/widgets/html/spoiler_text.dart | 2 +- lib/widgets/notifications_list.dart | 4 ++-- lib/widgets/pages/settings.dart | 4 ++-- lib/widgets/pages/settings_category.dart | 4 ++-- lib/widgets/reset_encryption_sheet.dart | 2 +- lib/widgets/room_chat/room_chat.dart | 4 ++-- lib/widgets/sync_status_banner.dart | 2 +- lib/widgets/user_bottom_sheet.dart | 20 ++++++-------------- 11 files changed, 24 insertions(+), 33 deletions(-) diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index 3927a34..a282f81 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -191,10 +191,9 @@ class ClientController extends AsyncNotifier { } } - Future generateRecoveryKey({String passphrase = ""}) async => - .fromJson( - await _sendCommand("generate_recovery_key", {"passphrase": passphrase}), - ); + Future generateRecoveryKey(String passphrase) async => .fromJson( + await _sendCommand("generate_recovery_key", {"passphrase": passphrase}), + ); Future resetEncryption(RecoveryKey key) => _sendCommand("reset_encryption", key.toJson()); diff --git a/lib/helpers/hooks/chat_scroll.dart b/lib/helpers/hooks/chat_scroll.dart index dabea1b..2386cc1 100644 --- a/lib/helpers/hooks/chat_scroll.dart +++ b/lib/helpers/hooks/chat_scroll.dart @@ -67,7 +67,7 @@ final class ChatScroll({ await Scrollable.ensureVisible( context!, alignment: 0.5, - duration: const .new(milliseconds: 700), + duration: Durations.extralong1, curve: Curves.easeInOut, ); } @@ -179,7 +179,7 @@ final class ChatScroll({ await Scrollable.ensureVisible( context, alignment: 0.5, - duration: const .new(milliseconds: 700), + duration: Durations.extralong1, curve: Curves.easeInOut, ); return; @@ -203,7 +203,7 @@ final class ChatScroll({ await scrollController.animateTo( scrollController.position.minScrollExtent, - duration: const .new(milliseconds: 700), + duration: Durations.extralong1, curve: Curves.easeInOut, ); }, diff --git a/lib/widgets/highlight_wrapper.dart b/lib/widgets/highlight_wrapper.dart index b10e3ff..4612548 100644 --- a/lib/widgets/highlight_wrapper.dart +++ b/lib/widgets/highlight_wrapper.dart @@ -13,7 +13,7 @@ final class const HighlightWrapper( color: isHighlighted ? Theme.of(context).colorScheme.onSurface.withAlpha(50) : Colors.transparent, - duration: .new(milliseconds: 250), + duration: Durations.medium1, child: Material(color: Colors.transparent, child: child), ), ); diff --git a/lib/widgets/html/spoiler_text.dart b/lib/widgets/html/spoiler_text.dart index 92a5538..e4a5977 100644 --- a/lib/widgets/html/spoiler_text.dart +++ b/lib/widgets/html/spoiler_text.dart @@ -9,7 +9,7 @@ class const SpoilerText(final String text, {super.key}) extends HookWidget { return InkWell( onTap: () => revealed.value = !revealed.value, child: AnimatedContainer( - duration: const .new(milliseconds: 100), + duration: Durations.short2, padding: const .symmetric(horizontal: 4, vertical: 2), decoration: BoxDecoration( color: revealed.value ? Colors.transparent : Colors.blueGrey, diff --git a/lib/widgets/notifications_list.dart b/lib/widgets/notifications_list.dart index 11ea451..0b0741f 100644 --- a/lib/widgets/notifications_list.dart +++ b/lib/widgets/notifications_list.dart @@ -98,10 +98,10 @@ class const NotificationsList({super.key}) index: index, scrollController: scrollController, alignment: 0.5, - duration: (_) => .new(milliseconds: 700), + duration: (_) => Durations.extralong1, curve: (_) => Curves.easeInOut, ); - timer = Timer(.new(seconds: 1), () { + timer = Timer(Durations.extralong4, () { highlightedId.value = null; }); }); diff --git a/lib/widgets/pages/settings.dart b/lib/widgets/pages/settings.dart index 2a813e5..6bc298c 100644 --- a/lib/widgets/pages/settings.dart +++ b/lib/widgets/pages/settings.dart @@ -81,11 +81,11 @@ class const SettingsPage({super.key}) extends ConsumerWidget { index: match.$1.$2, scrollController: scrollController, alignment: 0.5, - duration: (_) => .new(milliseconds: 700), + duration: (_) => Durations.extralong1, curve: (_) => Curves.easeInOut, ); highlightedMatch.value = match.$1; - await Future.delayed(.new(seconds: 1), () { + await Future.delayed(Durations.extralong4, () { if (highlightedMatch.value == match.$1) { highlightedMatch.value = null; } diff --git a/lib/widgets/pages/settings_category.dart b/lib/widgets/pages/settings_category.dart index 8e94c56..2398f7f 100644 --- a/lib/widgets/pages/settings_category.dart +++ b/lib/widgets/pages/settings_category.dart @@ -31,10 +31,10 @@ class const SettingsCategoryPage( index: initialHighlight!, scrollController: scrollController, alignment: 0.5, - duration: (_) => .new(milliseconds: 700), + duration: (_) => Durations.extralong1, curve: (_) => Curves.easeInOut, ); - timer = Timer(.new(seconds: 1), () { + timer = Timer(Durations.extralong4, () { highlight.value = null; }); listController.value.removeListener(listener); diff --git a/lib/widgets/reset_encryption_sheet.dart b/lib/widgets/reset_encryption_sheet.dart index 52a10b4..a3044a1 100644 --- a/lib/widgets/reset_encryption_sheet.dart +++ b/lib/widgets/reset_encryption_sheet.dart @@ -53,7 +53,7 @@ class const ResetEncryptionSheet({ final recoveryKey = await ref .read(ClientController.provider.notifier) .generateRecoveryKey( - passphrase: usePassphrase.value ? passphrase : "", + usePassphrase.value ? passphrase : "", ); if (!context.mounted) return; diff --git a/lib/widgets/room_chat/room_chat.dart b/lib/widgets/room_chat/room_chat.dart index f02a743..f45a6f2 100644 --- a/lib/widgets/room_chat/room_chat.dart +++ b/lib/widgets/room_chat/room_chat.dart @@ -143,7 +143,7 @@ final class const RoomChat({ highlightedEvent.value = rowId; await scroll.jumpToEvent(rowId); - await Future.delayed(.new(milliseconds: 700), () { + await Future.delayed(Durations.extralong1, () { if (highlightedEvent.value == rowId) { highlightedEvent.value = null; } @@ -240,7 +240,7 @@ final class const RoomChat({ ignoring: scroll.atBottom, child: AnimatedOpacity( opacity: scroll.atBottom ? 0 : 1, - duration: const Duration(milliseconds: 200), + duration: Durations.short4, child: FloatingActionButton.small( onPressed: scroll.jumpToBottom, child: const Icon(Icons.keyboard_arrow_down), diff --git a/lib/widgets/sync_status_banner.dart b/lib/widgets/sync_status_banner.dart index a0c6bcc..3f1e47e 100644 --- a/lib/widgets/sync_status_banner.dart +++ b/lib/widgets/sync_status_banner.dart @@ -42,7 +42,7 @@ class const SyncStatusBanner({super.key}) extends ConsumerWidget { ]; return AnimatedSize( - duration: const .new(milliseconds: 200), + duration: Durations.short4, alignment: .topCenter, child: banner == null ? const SizedBox(width: double.infinity) diff --git a/lib/widgets/user_bottom_sheet.dart b/lib/widgets/user_bottom_sheet.dart index a648876..0232b08 100644 --- a/lib/widgets/user_bottom_sheet.dart +++ b/lib/widgets/user_bottom_sheet.dart @@ -233,13 +233,9 @@ final class const UserBottomSheet( shape: .square, icon: Icon(Icons.sports_martial_arts), label: Text("Kick"), - decoration: .new( - backgroundColor: WidgetStatePropertyAll( - theme.colorScheme.error, - ), - foregroundColor: WidgetStatePropertyAll( - theme.colorScheme.onError, - ), + decoration: .styleFrom( + backgroundColor: theme.colorScheme.error, + foregroundColor: theme.colorScheme.onError, ), ), @@ -248,13 +244,9 @@ final class const UserBottomSheet( shape: .square, icon: Icon(Icons.gavel), label: Text("Ban"), - decoration: .new( - backgroundColor: WidgetStatePropertyAll( - theme.colorScheme.errorContainer, - ), - foregroundColor: WidgetStatePropertyAll( - theme.colorScheme.onErrorContainer, - ), + decoration: .styleFrom( + backgroundColor: theme.colorScheme.errorContainer, + foregroundColor: theme.colorScheme.onErrorContainer, ), ), ].map((e) => Expanded(child: e)).toList(),