From fc867b33a14db0dbe16d81eed098a7f296ca701a Mon Sep 17 00:00:00 2001 From: Krille Date: Thu, 4 Jul 2024 10:59:52 +0200 Subject: [PATCH 1/3] chore: Follow up time of day format --- lib/utils/date_time_extension.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index f546f9a5a..d02f45334 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -35,7 +35,9 @@ extension DateTimeExtension on DateTime { /// Returns a simple time String. String localizedTimeOfDay(BuildContext context) => - DateFormat.Hm(L10n.of(context)!.localeName).format(this); + MediaQuery.of(context).alwaysUse24HourFormat + ? DateFormat('HH:mm', L10n.of(context)!.localeName).format(this) + : DateFormat('h:mm a', L10n.of(context)!.localeName).format(this); /// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week /// day if the ChatTime is this week and a date string else. From e88afdd357ff1af52287644bc2157b42a5fbfc1b Mon Sep 17 00:00:00 2001 From: Krille Date: Thu, 4 Jul 2024 15:37:28 +0200 Subject: [PATCH 2/3] chore: Follow up use 24 hour format --- assets/l10n/intl_de.arb | 4 ++++ assets/l10n/intl_en.arb | 4 ++++ lib/utils/date_time_extension.dart | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/l10n/intl_de.arb b/assets/l10n/intl_de.arb index adf2d99d0..07dea5ae8 100644 --- a/assets/l10n/intl_de.arb +++ b/assets/l10n/intl_de.arb @@ -1,6 +1,10 @@ { "@@locale": "de", "@@last_modified": "2021-08-14 12:41:10.119255", + "alwaysUse24HourFormat": "true", + "@alwaysUse24HourFormat": { + "description": "Set to true to always display time of day in 24 hour format." + }, "about": "Über", "@about": { "type": "text", diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index b687dc863..cfd26a7c4 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -1,6 +1,10 @@ { "@@locale": "en", "@@last_modified": "2021-08-14 12:38:37.885451", + "alwaysUse24HourFormat": "false", + "@alwaysUse24HourFormat": { + "description": "Set to true to always display time of day in 24 hour format." + }, "repeatPassword": "Repeat password", "@repeatPassword": {}, "notAnImage": "Not an image file.", diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index d02f45334..13bae4efa 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -35,7 +35,7 @@ extension DateTimeExtension on DateTime { /// Returns a simple time String. String localizedTimeOfDay(BuildContext context) => - MediaQuery.of(context).alwaysUse24HourFormat + L10n.of(context)!.alwaysUse24HourFormat == 'true' ? DateFormat('HH:mm', L10n.of(context)!.localeName).format(this) : DateFormat('h:mm a', L10n.of(context)!.localeName).format(this); From ef5ea57c5832966c946e24973274b5e975597875 Mon Sep 17 00:00:00 2001 From: Krille Date: Thu, 4 Jul 2024 15:42:00 +0200 Subject: [PATCH 3/3] refactor: Omit local types --- analysis_options.yaml | 1 + lib/pages/chat/chat_emoji_picker.dart | 2 +- lib/pages/chat/event_info_dialog.dart | 4 ++-- lib/pages/chat/input_bar.dart | 2 +- lib/pages/chat/send_file_dialog.dart | 2 +- lib/pages/chat_list/client_chooser_button.dart | 6 +++--- .../flutter_hive_collections_database.dart | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 34a01078b..d74b36355 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -9,6 +9,7 @@ linter: - prefer_final_in_for_each - sort_pub_dependencies - require_trailing_commas + - omit_local_variable_types analyzer: errors: diff --git a/lib/pages/chat/chat_emoji_picker.dart b/lib/pages/chat/chat_emoji_picker.dart index 153abad67..0225e7350 100644 --- a/lib/pages/chat/chat_emoji_picker.dart +++ b/lib/pages/chat/chat_emoji_picker.dart @@ -14,7 +14,7 @@ class ChatEmojiPicker extends StatelessWidget { @override Widget build(BuildContext context) { - final ThemeData theme = Theme.of(context); + final theme = Theme.of(context); return AnimatedContainer( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, diff --git a/lib/pages/chat/event_info_dialog.dart b/lib/pages/chat/event_info_dialog.dart index 38acdc84c..3b3503593 100644 --- a/lib/pages/chat/event_info_dialog.dart +++ b/lib/pages/chat/event_info_dialog.dart @@ -28,8 +28,8 @@ class EventInfoDialog extends StatelessWidget { }); String get prettyJson { - const JsonDecoder decoder = JsonDecoder(); - const JsonEncoder encoder = JsonEncoder.withIndent(' '); + const decoder = JsonDecoder(); + const encoder = JsonEncoder.withIndent(' '); final object = decoder.convert(jsonEncode(event.toJson())); return encoder.convert(object); } diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 5cd801e04..d4917c1dc 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -55,7 +55,7 @@ class InputBar extends StatelessWidget { } final searchText = controller!.text.substring(0, controller!.selection.baseOffset); - final List> ret = >[]; + final ret = >[]; const maxResults = 30; final commandMatch = RegExp(r'^/(\w*)$').firstMatch(searchText); diff --git a/lib/pages/chat/send_file_dialog.dart b/lib/pages/chat/send_file_dialog.dart index b2885a635..b50a7d19e 100644 --- a/lib/pages/chat/send_file_dialog.dart +++ b/lib/pages/chat/send_file_dialog.dart @@ -64,7 +64,7 @@ class SendFileDialogState extends State { @override Widget build(BuildContext context) { var sendStr = L10n.of(context)!.sendFile; - final bool allFilesAreImages = + final allFilesAreImages = widget.files.every((file) => file is MatrixImageFile); final sizeString = widget.files .fold(0, (p, file) => p + file.bytes.length) diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index a37901b2f..d937b7cb1 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -165,7 +165,7 @@ class ClientChooserButton extends StatelessWidget { Widget build(BuildContext context) { final matrix = Matrix.of(context); - int clientCount = 0; + var clientCount = 0; matrix.accountBundles.forEach((key, value) => clientCount += value.length); return FutureBuilder( future: matrix.client.fetchOwnProfile(), @@ -292,7 +292,7 @@ class ClientChooserButton extends StatelessWidget { ); // beginning from end if negative if (index < 0) { - int clientCount = 0; + var clientCount = 0; matrix.accountBundles .forEach((key, value) => clientCount += value.length); _handleKeyboardShortcut(matrix, clientCount, context); @@ -312,7 +312,7 @@ class ClientChooserButton extends StatelessWidget { } int? _shortcutIndexOfClient(MatrixState matrix, Client client) { - int index = 0; + var index = 0; final bundles = matrix.accountBundles.keys.toList() ..sort( diff --git a/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart b/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart index 1fb9a4e4c..d10a09bd3 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart @@ -82,7 +82,7 @@ class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase { } static Future findDatabasePath(Client client) async { - String path = client.clientName; + var path = client.clientName; if (!kIsWeb) { Directory directory; try {