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/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 e3ff06b16..62e118f63 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/pages/chat/chat_emoji_picker.dart b/lib/pages/chat/chat_emoji_picker.dart index e7bf9c744..99dac40ec 100644 --- a/lib/pages/chat/chat_emoji_picker.dart +++ b/lib/pages/chat/chat_emoji_picker.dart @@ -13,96 +13,141 @@ class ChatEmojiPicker extends StatelessWidget { @override Widget build(BuildContext context) { - final ThemeData theme = Theme.of(context); - // #Pangea - return Material( - // Pangea# - child: AnimatedContainer( - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - clipBehavior: Clip.hardEdge, - decoration: const BoxDecoration(), - height: controller.showEmojiPicker - ? MediaQuery.of(context).size.height / 2 - : 0, - child: controller.showEmojiPicker - ? DefaultTabController( - length: 2, - child: Column( - children: [ - TabBar( - tabs: [ - Tab(text: L10n.of(context)!.emojis), - Tab(text: L10n.of(context)!.stickers), + final theme = Theme.of(context); + return AnimatedContainer( + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + clipBehavior: Clip.hardEdge, + decoration: const BoxDecoration(), + height: controller.showEmojiPicker + ? MediaQuery.of(context).size.height / 2 + : 0, + child: controller.showEmojiPicker + ? DefaultTabController( + length: 2, + child: Column( + children: [ + TabBar( + tabs: [ + Tab(text: L10n.of(context)!.emojis), + Tab(text: L10n.of(context)!.stickers), + ], + ), + Expanded( + child: TabBarView( + children: [ + EmojiPicker( + onEmojiSelected: controller.onEmojiSelected, + onBackspacePressed: controller.emojiPickerBackspace, + config: Config( + emojiViewConfig: EmojiViewConfig( + noRecents: const NoRecent(), + backgroundColor: Theme.of(context) + .colorScheme + .onInverseSurface, + ), + bottomActionBarConfig: const BottomActionBarConfig( + enabled: false, + ), + categoryViewConfig: CategoryViewConfig( + backspaceColor: theme.colorScheme.primary, + iconColor: + theme.colorScheme.primary.withOpacity(0.5), + iconColorSelected: theme.colorScheme.primary, + indicatorColor: theme.colorScheme.primary, + ), + skinToneConfig: SkinToneConfig( + dialogBackgroundColor: Color.lerp( + theme.colorScheme.surface, + theme.colorScheme.primaryContainer, + 0.75, + )!, + indicatorColor: theme.colorScheme.onSurface, + ), + ), + ), + StickerPickerDialog( + room: controller.room, + onSelected: (sticker) { + controller.room.sendEvent( + { + 'body': sticker.body, + 'info': sticker.info ?? {}, + 'url': sticker.url.toString(), + }, + type: EventTypes.Sticker, + ); + controller.hideEmojiPicker(); + }, + ), ], ), - Expanded( - child: TabBarView( - children: [ - EmojiPicker( - onEmojiSelected: controller.onEmojiSelected, - onBackspacePressed: controller.emojiPickerBackspace, - config: Config( - emojiViewConfig: EmojiViewConfig( - noRecents: const NoRecent(), - backgroundColor: Theme.of(context) - .colorScheme - .onInverseSurface, - ), - bottomActionBarConfig: - const BottomActionBarConfig( - enabled: false, - ), - categoryViewConfig: CategoryViewConfig( - backspaceColor: theme.colorScheme.primary, - iconColor: - theme.colorScheme.primary.withOpacity(0.5), - iconColorSelected: theme.colorScheme.primary, - indicatorColor: theme.colorScheme.primary, - ), - skinToneConfig: SkinToneConfig( - dialogBackgroundColor: Color.lerp( - theme.colorScheme.surface, - theme.colorScheme.primaryContainer, - 0.75, - )!, - indicatorColor: theme.colorScheme.onSurface, - ), + ), + Expanded( + child: TabBarView( + children: [ + EmojiPicker( + onEmojiSelected: controller.onEmojiSelected, + onBackspacePressed: controller.emojiPickerBackspace, + config: Config( + emojiViewConfig: EmojiViewConfig( + noRecents: const NoRecent(), + backgroundColor: Theme.of(context) + .colorScheme + .onInverseSurface, + ), + bottomActionBarConfig: const BottomActionBarConfig( + enabled: false, + ), + categoryViewConfig: CategoryViewConfig( + backspaceColor: theme.colorScheme.primary, + iconColor: + theme.colorScheme.primary.withOpacity(0.5), + iconColorSelected: theme.colorScheme.primary, + indicatorColor: theme.colorScheme.primary, + ), + skinToneConfig: SkinToneConfig( + dialogBackgroundColor: Color.lerp( + theme.colorScheme.surface, + theme.colorScheme.primaryContainer, + 0.75, + )!, + indicatorColor: theme.colorScheme.onSurface, ), ), - StickerPickerDialog( - room: controller.room, - onSelected: (sticker) { - controller.room.sendEvent( - { - 'body': sticker.body, - 'info': sticker.info ?? {}, - 'url': sticker.url.toString(), - }, - type: EventTypes.Sticker, - ); - controller.hideEmojiPicker(); - }, - ), - ], - ), + ), + StickerPickerDialog( + room: controller.room, + onSelected: (sticker) { + controller.room.sendEvent( + { + 'body': sticker.body, + 'info': sticker.info ?? {}, + 'url': sticker.url.toString(), + }, + type: EventTypes.Sticker, + ); + controller.hideEmojiPicker(); + }, + ), + ], ), - // #Pangea - Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: FloatingActionButton( - onPressed: controller.hideEmojiPicker, - shape: const CircleBorder(), - mini: true, - child: const Icon(Icons.close), - ), + ), + // #Pangea + Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: FloatingActionButton( + onPressed: controller.hideEmojiPicker, + shape: const CircleBorder(), + mini: true, + child: const Icon(Icons.close), ), - // Pangea# - ], - ), - ) - : null, - ), + ), + // Pangea# + ], + ), + ) + : null, ); } } 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 aea82a886..4d28675e1 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -51,9 +51,6 @@ class InputBar extends StatelessWidget { }); List> getSuggestions(String text) { - // #Pangea - final List> ret = >[]; - // Pangea# if (controller!.selection.baseOffset != controller!.selection.extentOffset || controller!.selection.baseOffset < 0) { @@ -61,9 +58,7 @@ class InputBar extends StatelessWidget { } final searchText = controller!.text.substring(0, controller!.selection.baseOffset); - // #Pangea - // final List> ret = >[]; - // Pangea# + 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 15f52ebe2..91c667545 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -259,7 +259,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(), @@ -430,7 +430,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); @@ -450,7 +450,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/date_time_extension.dart b/lib/utils/date_time_extension.dart index f546f9a5a..13bae4efa 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); + L10n.of(context)!.alwaysUse24HourFormat == 'true' + ? 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. 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 {