diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index e1c4cde71..64e7febad 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -88,6 +88,7 @@ class BootstrapDialogState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); _wipe ??= widget.wipe; final buttons = []; Widget body = const CircularProgressIndicator.adaptive(); @@ -119,7 +120,7 @@ class BootstrapDialogState extends State { backgroundColor: Colors.transparent, child: Icon( Icons.info_outlined, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), ), subtitle: Text(L10n.of(context)!.chatBackupDescription), @@ -144,7 +145,7 @@ class BootstrapDialogState extends State { CheckboxListTile.adaptive( contentPadding: const EdgeInsets.symmetric(horizontal: 8.0), value: _storeInSecureStorage, - activeColor: Theme.of(context).colorScheme.primary, + activeColor: theme.colorScheme.primary, onChanged: (b) { setState(() { _storeInSecureStorage = b; @@ -158,7 +159,7 @@ class BootstrapDialogState extends State { CheckboxListTile.adaptive( contentPadding: const EdgeInsets.symmetric(horizontal: 8.0), value: _recoveryKeyCopied, - activeColor: Theme.of(context).colorScheme.primary, + activeColor: theme.colorScheme.primary, onChanged: (b) { FluffyShare.share(key!, context); setState(() => _recoveryKeyCopied = true); @@ -241,7 +242,7 @@ class BootstrapDialogState extends State { const EdgeInsets.symmetric(horizontal: 8.0), trailing: Icon( Icons.info_outlined, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), subtitle: Text( L10n.of(context)!.pleaseEnterRecoveryKeyDescription, @@ -261,8 +262,7 @@ class BootstrapDialogState extends State { decoration: InputDecoration( contentPadding: const EdgeInsets.all(16), hintStyle: TextStyle( - fontFamily: - Theme.of(context).textTheme.bodyLarge?.fontFamily, + fontFamily: theme.textTheme.bodyLarge?.fontFamily, ), hintText: L10n.of(context)!.recoveryKey, errorText: _recoveryKeyInputError, @@ -272,9 +272,8 @@ class BootstrapDialogState extends State { const SizedBox(height: 16), ElevatedButton.icon( style: ElevatedButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onPrimary, - backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: theme.colorScheme.onPrimary, + backgroundColor: theme.colorScheme.primary, ), icon: _recoveryKeyInputLoading ? const CircularProgressIndicator.adaptive() @@ -386,10 +385,8 @@ class BootstrapDialogState extends State { const SizedBox(height: 16), ElevatedButton.icon( style: ElevatedButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.errorContainer, - foregroundColor: - Theme.of(context).colorScheme.onErrorContainer, + backgroundColor: theme.colorScheme.errorContainer, + foregroundColor: theme.colorScheme.onErrorContainer, ), icon: const Icon(Icons.delete_outlined), label: Text(L10n.of(context)!.recoveryKeyLost), diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index b86067ddb..1bc6f76ce 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1638,49 +1638,52 @@ class ChatController extends State } @override - Widget build(BuildContext context) => Row( - children: [ - Expanded( - child: ChatView(this), - ), - AnimatedSize( - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - child: ValueListenableBuilder( - valueListenable: _displayChatDetailsColumn, - builder: (context, displayChatDetailsColumn, _) { - if (!FluffyThemes.isThreeColumnMode(context) || - room.membership != Membership.join || - !displayChatDetailsColumn) { - return const SizedBox( - height: double.infinity, - width: 0, - ); - } - return Container( - width: FluffyThemes.columnWidth, - clipBehavior: Clip.hardEdge, - decoration: BoxDecoration( - border: Border( - left: BorderSide( - width: 1, - color: Theme.of(context).dividerColor, - ), - ), - ), - child: ChatDetails( - roomId: roomId, - embeddedCloseButton: IconButton( - icon: const Icon(Icons.close), - onPressed: toggleDisplayChatDetailsColumn, - ), - ), + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Row( + children: [ + Expanded( + child: ChatView(this), + ), + AnimatedSize( + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + child: ValueListenableBuilder( + valueListenable: _displayChatDetailsColumn, + builder: (context, displayChatDetailsColumn, _) { + if (!FluffyThemes.isThreeColumnMode(context) || + room.membership != Membership.join || + !displayChatDetailsColumn) { + return const SizedBox( + height: double.infinity, + width: 0, ); - }, - ), + } + return Container( + width: FluffyThemes.columnWidth, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + border: Border( + left: BorderSide( + width: 1, + color: theme.dividerColor, + ), + ), + ), + child: ChatDetails( + roomId: roomId, + embeddedCloseButton: IconButton( + icon: const Icon(Icons.close), + onPressed: toggleDisplayChatDetailsColumn, + ), + ), + ); + }, ), - ], - ); + ), + ], + ); + } } enum EmojiPickerType { reaction, keyboard } diff --git a/lib/pages/chat/chat_app_bar_list_tile.dart b/lib/pages/chat/chat_app_bar_list_tile.dart index 259144251..1ca0c5fba 100644 --- a/lib/pages/chat/chat_app_bar_list_tile.dart +++ b/lib/pages/chat/chat_app_bar_list_tile.dart @@ -22,6 +22,7 @@ class ChatAppBarListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); final leading = this.leading; final trailing = this.trailing; return SizedBox( @@ -40,16 +41,15 @@ class ChatAppBarListTile extends StatelessWidget { maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant, + color: theme.colorScheme.onSurfaceVariant, overflow: TextOverflow.ellipsis, fontSize: 14, ), linkStyle: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant, + color: theme.colorScheme.onSurfaceVariant, fontSize: 14, decoration: TextDecoration.underline, - decorationColor: - Theme.of(context).colorScheme.onSurfaceVariant, + decorationColor: theme.colorScheme.onSurfaceVariant, ), onOpen: (url) => UrlLauncher(context, url.url).launchUrl(), ), diff --git a/lib/pages/chat/chat_emoji_picker.dart b/lib/pages/chat/chat_emoji_picker.dart index 99dac40ec..011e3dc4b 100644 --- a/lib/pages/chat/chat_emoji_picker.dart +++ b/lib/pages/chat/chat_emoji_picker.dart @@ -42,9 +42,8 @@ class ChatEmojiPicker extends StatelessWidget { config: Config( emojiViewConfig: EmojiViewConfig( noRecents: const NoRecent(), - backgroundColor: Theme.of(context) - .colorScheme - .onInverseSurface, + backgroundColor: + theme.colorScheme.onInverseSurface, ), bottomActionBarConfig: const BottomActionBarConfig( enabled: false, diff --git a/lib/pages/chat/chat_input_row.dart b/lib/pages/chat/chat_input_row.dart index bee8a1af8..cc931ef12 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -1,6 +1,5 @@ import 'package:animations/animations.dart'; import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/pages/chat/input_bar.dart'; import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart'; import 'package:fluffychat/pangea/constants/language_constants.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -12,6 +11,7 @@ import 'package:matrix/matrix.dart'; import '../../config/themes.dart'; import 'chat.dart'; +import 'input_bar.dart'; class ChatInputRow extends StatelessWidget { final ChatController controller; @@ -20,6 +20,7 @@ class ChatInputRow extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); if (controller.showEmojiPicker && controller.emojiPickerType == EmojiPickerType.reaction) { return const SizedBox.shrink(); @@ -66,7 +67,7 @@ class ChatInputRow extends StatelessWidget { height: height, child: TextButton( style: TextButton.styleFrom( - foregroundColor: Theme.of(context).colorScheme.error, + foregroundColor: theme.colorScheme.error, ), onPressed: controller.deleteErrorEventsAction, child: Row( @@ -139,15 +140,7 @@ class ChatInputRow extends StatelessWidget { duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, height: height, - // #Pangea - // width: - // controller.sendController.text.isEmpty ? height : 0, - width: controller.sendController.text.isEmpty && - controller.pangeaController.permissionsController - .showChatInputAddButton(controller.roomId) - ? height - : 0, - // Pangea# + width: controller.sendController.text.isEmpty ? height : 0, alignment: Alignment.center, clipBehavior: Clip.hardEdge, decoration: const BoxDecoration(), @@ -224,21 +217,6 @@ class ChatInputRow extends StatelessWidget { contentPadding: const EdgeInsets.all(0), ), ), - if (controller.room - .getImagePacks(ImagePackUsage.sticker) - .isNotEmpty) - PopupMenuItem( - value: 'sticker', - child: ListTile( - leading: const CircleAvatar( - backgroundColor: Colors.orange, - foregroundColor: Colors.white, - child: Icon(Icons.emoji_emotions_outlined), - ), - title: Text(L10n.of(context)!.sendSticker), - contentPadding: const EdgeInsets.all(0), - ), - ), //#Pangea // if (PlatformInfos.isMobile) if (PlatformInfos.isMobile && @@ -260,9 +238,6 @@ class ChatInputRow extends StatelessWidget { ], ), ), - // #Pangea - // ), - // Pangea# Container( height: height, width: height, @@ -303,9 +278,6 @@ class ChatInputRow extends StatelessWidget { ), onPressed: controller.emojiPickerAction, ), - // #Pangea - // ), - // Pangea# ), // #Pangea // if (Matrix.of(context).isMultiAccount && @@ -373,10 +345,8 @@ class ChatInputRow extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(height), ), - backgroundColor: - Theme.of(context).colorScheme.primary, - foregroundColor: - Theme.of(context).colorScheme.onPrimary, + backgroundColor: theme.colorScheme.primary, + foregroundColor: theme.colorScheme.onPrimary, child: const Icon(Icons.mic_none_outlined), ) : @@ -390,11 +360,9 @@ class ChatInputRow extends StatelessWidget { // shape: RoundedRectangleBorder( // borderRadius: BorderRadius.circular(height), // ), - // backgroundColor: Theme.of(context) - // .colorScheme - // .onPrimaryContainer, - // foregroundColor: - // Theme.of(context).colorScheme.onPrimary, + // backgroundColor: + // theme.colorScheme.onPrimaryContainer, + // foregroundColor: theme.colorScheme.onPrimary, // child: const Icon(Icons.send_outlined), // ), // Pangea# diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 1327141e2..5065bebdc 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -3,15 +3,11 @@ import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/chat_app_bar_list_tile.dart'; import 'package:fluffychat/pages/chat/chat_app_bar_title.dart'; -import 'package:fluffychat/pages/chat/chat_emoji_picker.dart'; import 'package:fluffychat/pages/chat/chat_event_list.dart'; import 'package:fluffychat/pages/chat/pinned_events.dart'; import 'package:fluffychat/pages/chat/reply_display.dart'; import 'package:fluffychat/pangea/choreographer/widgets/it_bar.dart'; -import 'package:fluffychat/pangea/choreographer/widgets/start_igc_button.dart'; import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart'; -import 'package:fluffychat/pangea/widgets/chat/chat_floating_action_button.dart'; -import 'package:fluffychat/pangea/widgets/chat/input_bar_wrapper.dart'; import 'package:fluffychat/utils/account_config.dart'; import 'package:fluffychat/widgets/chat_settings_popup_menu.dart'; import 'package:fluffychat/widgets/connection_status_header.dart'; @@ -25,6 +21,8 @@ import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; import '../../utils/stream_extension.dart'; +import 'chat_emoji_picker.dart'; +import 'chat_input_row.dart'; enum _EventContextAction { info, report } @@ -42,15 +40,11 @@ class ChatView extends StatelessWidget { tooltip: L10n.of(context)!.edit, onPressed: controller.editSelectedEventAction, ), - // #Pangea - if (controller.selectedEvents.length == 1 && - controller.selectedEvents.single.messageType == MessageTypes.Text) - // Pangea# - IconButton( - icon: const Icon(Icons.copy_outlined), - tooltip: L10n.of(context)!.copy, - onPressed: controller.copyEventsAction, - ), + IconButton( + icon: const Icon(Icons.copy_outlined), + tooltip: L10n.of(context)!.copy, + onPressed: controller.copyEventsAction, + ), if (controller.canSaveSelectedEvent) // Use builder context to correctly position the share dialog on iPad Builder( @@ -143,6 +137,7 @@ class ChatView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); if (controller.room.membership == Membership.invite) { showFutureLoadingDialog( context: context, @@ -193,14 +188,14 @@ class ChatView extends StatelessWidget { actionsIconTheme: IconThemeData( color: controller.selectedEvents.isEmpty ? null - : Theme.of(context).colorScheme.primary, + : theme.colorScheme.primary, ), leading: controller.selectMode ? IconButton( icon: const Icon(Icons.close), onPressed: controller.clearSelectedEvents, tooltip: L10n.of(context)!.close, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ) : StreamBuilder( stream: Matrix.of(context) @@ -209,7 +204,12 @@ class ChatView extends StatelessWidget { .stream .where((syncUpdate) => syncUpdate.hasRoomUpdate), builder: (context, _) => UnreadRoomsBadge( - filter: (r) => r.id != controller.roomId, + filter: (r) => + r.id != controller.roomId + // #Pangea + && + !r.isAnalyticsRoom, + // Pangea# badgePosition: BadgePosition.topEnd(end: 8, top: 4), child: const Center(child: BackButton()), ), @@ -238,8 +238,7 @@ class ChatView extends StatelessWidget { if (scrollUpBannerEventId != null) ChatAppBarListTile( leading: IconButton( - color: - Theme.of(context).colorScheme.onSurfaceVariant, + color: theme.colorScheme.onSurfaceVariant, icon: const Icon(Icons.close), tooltip: L10n.of(context)!.close, onPressed: () { @@ -340,7 +339,7 @@ class ChatView extends StatelessWidget { alignment: Alignment.center, child: Material( clipBehavior: Clip.hardEdge, - color: Theme.of(context) + color: theme .colorScheme // ignore: deprecated_member_use .surfaceVariant, @@ -353,43 +352,16 @@ class ChatView extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - // #Pangea - if (controller.room.isRoomAdmin) - TextButton.icon( - style: TextButton.styleFrom( - padding: const EdgeInsets.all( - 16, - ), - foregroundColor: - Theme.of(context) - .colorScheme - .error, - ), - icon: const Icon( - Icons.archive_outlined, - ), - onPressed: - controller.archiveChat, - label: Text( - L10n.of(context)!.archive, - ), - ), - // Pangea# TextButton.icon( style: TextButton.styleFrom( padding: const EdgeInsets.all( 16, ), foregroundColor: - Theme.of(context) - .colorScheme - .error, + theme.colorScheme.error, ), icon: const Icon( - // #Pangea - // Icons.archive_outlined, - Icons.arrow_forward, - // Pangea# + Icons.archive_outlined, ), onPressed: controller.leaveChat, label: Text( @@ -413,119 +385,40 @@ class ChatView extends StatelessWidget { ), ], ) - : - // #Pangea - null, - // Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // const ConnectionStatusHeader(), - // ITBar( - // choreographer: - // controller.choreographer, - // ), - // ReactionsPicker(controller), - // ReplyDisplay(controller), - // ChatInputRow(controller), - // ChatEmojiPicker(controller), - // ], - // ), - // Pangea# + : Column( + mainAxisSize: MainAxisSize.min, + children: [ + const ConnectionStatusHeader(), + // #Pangea + ITBar( + choreographer: + controller.choreographer, + ), + // ReactionsPicker(controller), + // Pangea# + ReplyDisplay(controller), + ChatInputRow(controller), + ChatEmojiPicker(controller), + ], + ), ), ), - // #Pangea - // Keep messages above minimum input bar height - const SizedBox( - height: 60, - ), - // Pangea# ], ), - // #Pangea - Positioned( - left: 0, - right: 0, - bottom: 16, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (!controller.selectMode) - Container( - margin: EdgeInsets.only( - bottom: 10, - left: bottomSheetPadding, - right: bottomSheetPadding, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 2.4, - ), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - StartIGCButton( - controller: controller, - ), - ChatFloatingActionButton( - controller: controller, - ), - ], - ), - ), - Container( - margin: EdgeInsets.only( - bottom: bottomSheetPadding, - left: bottomSheetPadding, - right: bottomSheetPadding, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 2.5, - ), - alignment: Alignment.center, - child: Material( - clipBehavior: Clip.hardEdge, - color: Theme.of(context) - .colorScheme - .surfaceContainerHighest, - borderRadius: const BorderRadius.all( - Radius.circular(24), - ), - child: Column( - children: [ - const ConnectionStatusHeader(), - ITBar( - choreographer: controller.choreographer, - ), - ReplyDisplay(controller), - ChatInputRowWrapper( - controller: controller, - ), - ChatEmojiPicker(controller), - ], - ), - ), - ), - ], - ), - ), - // Pangea# ], ), - // #Pangea - // if (controller.dragging) - // Container( - // color: Theme.of(context) - // .scaffoldBackgroundColor - // .withOpacity(0.9), - // alignment: Alignment.center, - // child: const Icon( - // Icons.upload_outlined, - // size: 100, - // ), - // ), - // Pangea# ), + // #Pangea + // if (controller.dragging) + // Container( + // color: theme.scaffoldBackgroundColor.withOpacity(0.9), + // alignment: Alignment.center, + // child: const Icon( + // Icons.upload_outlined, + // size: 100, + // ), + // ), + // Pangea# ], ), ); diff --git a/lib/pages/chat/event_info_dialog.dart b/lib/pages/chat/event_info_dialog.dart index 3b3503593..c930e4b14 100644 --- a/lib/pages/chat/event_info_dialog.dart +++ b/lib/pages/chat/event_info_dialog.dart @@ -36,6 +36,7 @@ class EventInfoDialog extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); return Scaffold( appBar: AppBar( title: Text(L10n.of(context)!.messageInfo), @@ -72,14 +73,14 @@ class EventInfoDialog extends StatelessWidget { padding: const EdgeInsets.all(12.0), child: Material( borderRadius: BorderRadius.circular(AppConfig.borderRadius), - color: Theme.of(context).colorScheme.inverseSurface, + color: theme.colorScheme.inverseSurface, child: SingleChildScrollView( padding: const EdgeInsets.all(8), scrollDirection: Axis.horizontal, child: SelectableText( prettyJson, style: TextStyle( - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, ), ), ), diff --git a/lib/pages/chat/events/audio_player.dart b/lib/pages/chat/events/audio_player.dart index f0ec64bab..d848cb6cc 100644 --- a/lib/pages/chat/events/audio_player.dart +++ b/lib/pages/chat/events/audio_player.dart @@ -307,6 +307,8 @@ class AudioPlayerState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final statusText = this.statusText ??= _durationString ?? '00:00'; final audioPlayer = this.audioPlayer; return Padding( @@ -409,8 +411,8 @@ class AudioPlayerState extends State { // : Text( // '${audioPlayer.speed.toString()}x', // ), - // backgroundColor: Theme.of(context).colorScheme.secondary, - // textColor: Theme.of(context).colorScheme.onSecondary, + // backgroundColor: theme.colorScheme.secondary, + // textColor: theme.colorScheme.onSecondary, // child: InkWell( // splashColor: widget.color.withAlpha(128), // borderRadius: BorderRadius.circular(64), diff --git a/lib/pages/chat/events/image_bubble.dart b/lib/pages/chat/events/image_bubble.dart index f5219b054..3ee745eeb 100644 --- a/lib/pages/chat/events/image_bubble.dart +++ b/lib/pages/chat/events/image_bubble.dart @@ -67,6 +67,8 @@ class ImageBubble extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final borderRadius = this.borderRadius ?? BorderRadius.circular(AppConfig.borderRadius); return Material( @@ -77,7 +79,7 @@ class ImageBubble extends StatelessWidget { side: BorderSide( color: event.messageType == MessageTypes.Sticker ? Colors.transparent - : Theme.of(context).dividerColor, + : theme.dividerColor, ), ), child: InkWell( diff --git a/lib/pages/chat/events/map_bubble.dart b/lib/pages/chat/events/map_bubble.dart index d9cea7695..b417680bb 100644 --- a/lib/pages/chat/events/map_bubble.dart +++ b/lib/pages/chat/events/map_bubble.dart @@ -21,6 +21,8 @@ class MapBubble extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return ClipRRect( borderRadius: BorderRadius.circular(radius), child: Container( @@ -71,11 +73,10 @@ class MapBubble extends StatelessWidget { child: Text( ' © OpenStreetMap contributors ', style: TextStyle( - color: Theme.of(context).brightness == Brightness.dark + color: theme.brightness == Brightness.dark ? Colors.white : Colors.black, - backgroundColor: - Theme.of(context).appBarTheme.backgroundColor, + backgroundColor: theme.appBarTheme.backgroundColor, ), ), ), diff --git a/lib/pages/chat/events/message.dart b/lib/pages/chat/events/message.dart index cf3b8689a..3dab1a01a 100644 --- a/lib/pages/chat/events/message.dart +++ b/lib/pages/chat/events/message.dart @@ -95,6 +95,8 @@ class Message extends StatelessWidget { } }); // Pangea# + final theme = Theme.of(context); + if (!{ EventTypes.Message, EventTypes.Sticker, @@ -116,7 +118,7 @@ class Message extends StatelessWidget { final ownMessage = event.senderId == client.userID; final alignment = ownMessage ? Alignment.topRight : Alignment.topLeft; // ignore: deprecated_member_use - var color = Theme.of(context).colorScheme.surfaceVariant; + var color = theme.colorScheme.surfaceVariant; final displayTime = event.type == EventTypes.RoomCreate || nextEvent == null || !event.originServerTs.sameEnvironment(nextEvent!.originServerTs); @@ -138,9 +140,8 @@ class Message extends StatelessWidget { previousEvent!.senderId == event.senderId && previousEvent!.originServerTs.sameEnvironment(event.originServerTs); - final textColor = ownMessage - ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.onSurface; + final textColor = + ownMessage ? theme.colorScheme.onPrimary : theme.colorScheme.onSurface; final rowMainAxisAlignment = ownMessage ? MainAxisAlignment.end : MainAxisAlignment.start; @@ -169,7 +170,7 @@ class Message extends StatelessWidget { if (ownMessage) { color = displayEvent.status.isError ? Colors.redAccent - : Theme.of(context).colorScheme.primary; + : theme.colorScheme.primary; } final resetAnimateIn = this.resetAnimateIn; @@ -209,14 +210,10 @@ class Message extends StatelessWidget { borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), color: selected - ? Theme.of(context) - .colorScheme - .secondaryContainer + ? theme.colorScheme.secondaryContainer .withAlpha(100) : highlightMarker - ? Theme.of(context) - .colorScheme - .tertiaryContainer + ? theme.colorScheme.tertiaryContainer .withAlpha(100) : Colors.transparent, ), @@ -300,8 +297,7 @@ class Message extends StatelessWidget { displayname, style: TextStyle( fontSize: 12, - color: (Theme.of(context) - .brightness == + color: (theme.brightness == Brightness.light ? displayname.color : displayname @@ -564,10 +560,10 @@ class Message extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.bold, fontSize: 12 * AppConfig.fontSizeFactor, - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, shadows: [ Shadow( - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, blurRadius: 3, ), ], @@ -614,14 +610,14 @@ class Message extends StatelessWidget { Row( children: [ Expanded( - child: Divider(color: Theme.of(context).colorScheme.primary), + child: Divider(color: theme.colorScheme.primary), ), Container( decoration: BoxDecoration( border: Border.all( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), - color: Theme.of(context).colorScheme.primaryContainer, + color: theme.colorScheme.primaryContainer, borderRadius: BorderRadius.circular(4), ), margin: const EdgeInsets.all(8.0), @@ -630,12 +626,11 @@ class Message extends StatelessWidget { ), child: Text( L10n.of(context)!.readUpToHere, - style: - TextStyle(color: Theme.of(context).colorScheme.primary), + style: TextStyle(color: theme.colorScheme.primary), ), ), Expanded( - child: Divider(color: Theme.of(context).colorScheme.primary), + child: Divider(color: theme.colorScheme.primary), ), ], ), diff --git a/lib/pages/chat/events/message_reactions.dart b/lib/pages/chat/events/message_reactions.dart index 56286cae0..a4b2addbc 100644 --- a/lib/pages/chat/events/message_reactions.dart +++ b/lib/pages/chat/events/message_reactions.dart @@ -108,10 +108,10 @@ class _Reaction extends StatelessWidget { @override Widget build(BuildContext context) { - final textColor = Theme.of(context).brightness == Brightness.dark - ? Colors.white - : Colors.black; - final color = Theme.of(context).colorScheme.surface; + final theme = Theme.of(context); + final textColor = + theme.brightness == Brightness.dark ? Colors.white : Colors.black; + final color = theme.colorScheme.surface; Widget content; if (reactionKey.startsWith('mxc://')) { content = Row( @@ -158,8 +158,8 @@ class _Reaction extends StatelessWidget { border: Border.all( width: 1, color: reacted! - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.primaryContainer, + ? theme.colorScheme.primary + : theme.colorScheme.primaryContainer, ), borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), ), diff --git a/lib/pages/chat/events/reply_content.dart b/lib/pages/chat/events/reply_content.dart index b48f16cd9..08756df33 100644 --- a/lib/pages/chat/events/reply_content.dart +++ b/lib/pages/chat/events/reply_content.dart @@ -26,20 +26,19 @@ class ReplyContent extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final timeline = this.timeline; final displayEvent = timeline != null ? replyEvent.getDisplayEvent(timeline) : replyEvent; final fontSize = AppConfig.messageFontSize * AppConfig.fontSizeFactor; final color = ownMessage - ? Theme.of(context).colorScheme.primaryContainer - : Theme.of(context).colorScheme.primary; + ? theme.colorScheme.primaryContainer + : theme.colorScheme.primary; return Material( color: backgroundColor ?? - Theme.of(context) - .colorScheme - .surface - .withOpacity(ownMessage ? 0.2 : 0.33), + theme.colorScheme.surface.withOpacity(ownMessage ? 0.2 : 0.33), borderRadius: borderRadius, child: Row( mainAxisSize: MainAxisSize.min, @@ -80,8 +79,8 @@ class ReplyContent extends StatelessWidget { maxLines: 1, style: TextStyle( color: ownMessage - ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.onSurface, + ? theme.colorScheme.onPrimary + : theme.colorScheme.onSurface, fontSize: fontSize, ), ), diff --git a/lib/pages/chat/events/state_message.dart b/lib/pages/chat/events/state_message.dart index ebd6f7373..e38f75815 100644 --- a/lib/pages/chat/events/state_message.dart +++ b/lib/pages/chat/events/state_message.dart @@ -12,6 +12,8 @@ class StateMessage extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Center( @@ -27,7 +29,7 @@ class StateMessage extends StatelessWidget { decoration: event.redacted ? TextDecoration.lineThrough : null, shadows: [ Shadow( - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, blurRadius: 3, ), ], diff --git a/lib/pages/chat/events/verification_request_content.dart b/lib/pages/chat/events/verification_request_content.dart index b6ec3fd09..a09f007f7 100644 --- a/lib/pages/chat/events/verification_request_content.dart +++ b/lib/pages/chat/events/verification_request_content.dart @@ -17,6 +17,8 @@ class VerificationRequestContent extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final events = event.aggregatedEvents(timeline, 'm.reference'); final done = events.where((e) => e.type == EventTypes.KeyVerificationDone); final start = @@ -36,10 +38,10 @@ class VerificationRequestContent extends StatelessWidget { padding: const EdgeInsets.all(8), decoration: BoxDecoration( border: Border.all( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), borderRadius: BorderRadius.circular(AppConfig.borderRadius), - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, ), child: Row( mainAxisSize: MainAxisSize.min, diff --git a/lib/pages/chat/events/video_player.dart b/lib/pages/chat/events/video_player.dart index 4a60d9f58..385f83567 100644 --- a/lib/pages/chat/events/video_player.dart +++ b/lib/pages/chat/events/video_player.dart @@ -95,6 +95,8 @@ class EventVideoPlayerState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final hasThumbnail = widget.event.hasThumbnail; final blurHash = (widget.event.infoMap as Map) .tryGet('xyz.amorgan.blurhash') ?? @@ -122,7 +124,7 @@ class EventVideoPlayerState extends State { Center( child: IconButton( style: IconButton.styleFrom( - backgroundColor: Theme.of(context).colorScheme.surface, + backgroundColor: theme.colorScheme.surface, ), icon: _isDownloading ? const SizedBox( diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 4d28675e1..d845c8a96 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -224,6 +224,7 @@ class InputBar extends StatelessWidget { Map suggestion, Client? client, ) { + final theme = Theme.of(context); const size = 30.0; // #Pangea // const padding = EdgeInsets.all(4.0); @@ -248,7 +249,7 @@ class InputBar extends StatelessWidget { hint, maxLines: 1, overflow: TextOverflow.ellipsis, - style: Theme.of(context).textTheme.bodySmall, + style: theme.textTheme.bodySmall, ), ], ), diff --git a/lib/pages/chat/pinned_events.dart b/lib/pages/chat/pinned_events.dart index 7afe413db..1baa488c5 100644 --- a/lib/pages/chat/pinned_events.dart +++ b/lib/pages/chat/pinned_events.dart @@ -53,6 +53,8 @@ class PinnedEvents extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final pinnedEventIds = controller.room.pinnedEventIds; if (pinnedEventIds.isEmpty) { @@ -73,7 +75,7 @@ class PinnedEvents extends StatelessWidget { leading: IconButton( splashRadius: 18, iconSize: 18, - color: Theme.of(context).colorScheme.onSurfaceVariant, + color: theme.colorScheme.onSurfaceVariant, icon: const Icon(Icons.push_pin), tooltip: L10n.of(context)!.unpin, onPressed: controller.room.canSendEvent(EventTypes.RoomPinnedEvents) diff --git a/lib/pages/chat/reactions_picker.dart b/lib/pages/chat/reactions_picker.dart index c61dc4f48..b695da5f1 100644 --- a/lib/pages/chat/reactions_picker.dart +++ b/lib/pages/chat/reactions_picker.dart @@ -14,6 +14,8 @@ class ReactionsPicker extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + if (controller.showEmojiPicker) return const SizedBox.shrink(); final display = controller.editEvent == null && controller.replyEvent == null && @@ -59,7 +61,7 @@ class ReactionsPicker extends StatelessWidget { Expanded( child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, borderRadius: const BorderRadius.only( bottomRight: Radius.circular(AppConfig.borderRadius), ), @@ -91,7 +93,7 @@ class ReactionsPicker extends StatelessWidget { width: 36, height: 56, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, shape: BoxShape.circle, ), child: const Icon(Icons.add_outlined), diff --git a/lib/pages/chat/recording_dialog.dart b/lib/pages/chat/recording_dialog.dart index 2628874a6..0d2c2adb6 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -151,6 +151,8 @@ class RecordingDialogState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + const maxDecibalWidth = 64.0; final time = '${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}'; @@ -179,7 +181,7 @@ class RecordingDialogState extends State { margin: const EdgeInsets.only(left: 2), width: 4, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, borderRadius: BorderRadius.circular(AppConfig.borderRadius), ), @@ -205,11 +207,7 @@ class RecordingDialogState extends State { child: Text( L10n.of(context)!.cancel.toUpperCase(), style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyMedium - ?.color - ?.withAlpha(150), + color: theme.textTheme.bodyMedium?.color?.withAlpha(150), ), ), ), @@ -229,8 +227,7 @@ class RecordingDialogState extends State { child: Text( L10n.of(context)!.cancel.toUpperCase(), style: TextStyle( - color: - Theme.of(context).textTheme.bodyMedium?.color?.withAlpha(150), + color: theme.textTheme.bodyMedium?.color?.withAlpha(150), ), ), ), diff --git a/lib/pages/chat/reply_display.dart b/lib/pages/chat/reply_display.dart index e2bacac83..0b182f719 100644 --- a/lib/pages/chat/reply_display.dart +++ b/lib/pages/chat/reply_display.dart @@ -13,6 +13,8 @@ class ReplyDisplay extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return AnimatedContainer( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, @@ -21,7 +23,7 @@ class ReplyDisplay extends StatelessWidget { : 0, clipBehavior: Clip.hardEdge, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, ), child: Row( children: [ @@ -54,6 +56,7 @@ class _EditContent extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); final event = this.event; if (event == null) { return const SizedBox.shrink(); @@ -62,7 +65,7 @@ class _EditContent extends StatelessWidget { children: [ Icon( Icons.edit, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), Container(width: 15.0), Text( @@ -74,7 +77,7 @@ class _EditContent extends StatelessWidget { overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( - color: Theme.of(context).textTheme.bodyMedium!.color, + color: theme.textTheme.bodyMedium!.color, ), ), ], diff --git a/lib/pages/chat/seen_by_row.dart b/lib/pages/chat/seen_by_row.dart index af8b82069..793a90746 100644 --- a/lib/pages/chat/seen_by_row.dart +++ b/lib/pages/chat/seen_by_row.dart @@ -11,6 +11,8 @@ class SeenByRow extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final seenByUsers = controller.room.getSeenByUsers(controller.timeline!); const maxAvatars = 7; return Container( @@ -48,7 +50,7 @@ class SeenByRow extends StatelessWidget { width: 16, height: 16, child: Material( - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, borderRadius: BorderRadius.circular(32), child: Center( child: Text( diff --git a/lib/pages/chat/send_file_dialog.dart b/lib/pages/chat/send_file_dialog.dart index f97a4f2c6..79b4eed83 100644 --- a/lib/pages/chat/send_file_dialog.dart +++ b/lib/pages/chat/send_file_dialog.dart @@ -66,6 +66,8 @@ class SendFileDialogState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + var sendStr = L10n.of(context)!.sendFile; final allFilesAreImages = widget.files.every((file) => file is MatrixImageFile); @@ -91,9 +93,8 @@ class SendFileDialogState extends State { Flexible( child: Material( borderRadius: BorderRadius.circular(AppConfig.borderRadius), - elevation: - Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4, - shadowColor: Theme.of(context).appBarTheme.shadowColor, + elevation: theme.appBarTheme.scrolledUnderElevation ?? 4, + shadowColor: theme.appBarTheme.shadowColor, clipBehavior: Clip.hardEdge, child: Image.memory( widget.files.first.bytes, diff --git a/lib/pages/chat/sticker_picker_dialog.dart b/lib/pages/chat/sticker_picker_dialog.dart index 39e8fef5d..800c3cd24 100644 --- a/lib/pages/chat/sticker_picker_dialog.dart +++ b/lib/pages/chat/sticker_picker_dialog.dart @@ -25,6 +25,8 @@ class StickerPickerDialogState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final stickerPacks = widget.room.getImagePacks(ImagePackUsage.sticker); final packSlugs = stickerPacks.keys.toList(); @@ -98,7 +100,7 @@ class StickerPickerDialogState extends State { }; return Scaffold( - backgroundColor: Theme.of(context).colorScheme.onInverseSurface, + backgroundColor: theme.colorScheme.onInverseSurface, body: SizedBox( width: double.maxFinite, child: CustomScrollView( diff --git a/lib/pages/chat/typing_indicators.dart b/lib/pages/chat/typing_indicators.dart index 35fbf5d25..a58138a90 100644 --- a/lib/pages/chat/typing_indicators.dart +++ b/lib/pages/chat/typing_indicators.dart @@ -14,6 +14,8 @@ class TypingIndicators extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + const avatarSize = Avatar.defaultSize / 2; return StreamBuilder( @@ -81,7 +83,7 @@ class TypingIndicators extends StatelessWidget { Material( color: // ignore: deprecated_member_use - Theme.of(context).colorScheme.surfaceVariant, + theme.colorScheme.surfaceVariant, borderRadius: const BorderRadius.all( Radius.circular(AppConfig.borderRadius), ), @@ -137,6 +139,7 @@ class __TypingDotsState extends State<_TypingDots> { @override Widget build(BuildContext context) { + final theme = Theme.of(context); const size = 8.0; return Row( @@ -154,7 +157,7 @@ class __TypingDotsState extends State<_TypingDots> { ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(size * 2), - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, ), ), ], diff --git a/lib/pages/chat_access_settings/chat_access_settings_page.dart b/lib/pages/chat_access_settings/chat_access_settings_page.dart index c23d9dc6b..a4a6538a6 100644 --- a/lib/pages/chat_access_settings/chat_access_settings_page.dart +++ b/lib/pages/chat_access_settings/chat_access_settings_page.dart @@ -14,6 +14,8 @@ class ChatAccessSettingsPageView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final room = controller.room; return Scaffold( appBar: AppBar( @@ -38,7 +40,7 @@ class ChatAccessSettingsPageView extends StatelessWidget { title: Text( L10n.of(context)!.visibilityOfTheChatHistory, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -56,12 +58,12 @@ class ChatAccessSettingsPageView extends StatelessWidget { ? null : controller.setHistoryVisibility, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.whoIsAllowedToJoinThisGroup, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -79,14 +81,14 @@ class ChatAccessSettingsPageView extends StatelessWidget { ? null : controller.setJoinRule, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), if ({JoinRules.public, JoinRules.knock} .contains(room.joinRules)) ...[ ListTile( title: Text( L10n.of(context)!.areGuestsAllowedToJoin, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -105,12 +107,12 @@ class ChatAccessSettingsPageView extends StatelessWidget { ? null : controller.setGuestAccess, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.publicChatAddresses, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -163,7 +165,7 @@ class ChatAccessSettingsPageView extends StatelessWidget { ); }, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), FutureBuilder( future: room.client.getRoomVisibilityOnDirectory(room.id), builder: (context, snapshot) => SwitchListTile.adaptive( @@ -225,6 +227,8 @@ class _AliasListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return ListTile( leading: isCanonicalAlias ? const Icon(Icons.star) @@ -238,15 +242,15 @@ class _AliasListTile extends StatelessWidget { 'https://matrix.to/#/$alias', style: TextStyle( decoration: TextDecoration.underline, - decorationColor: Theme.of(context).colorScheme.primary, - color: Theme.of(context).colorScheme.primary, + decorationColor: theme.colorScheme.primary, + color: theme.colorScheme.primary, fontSize: 14, ), ), ), trailing: onDelete != null ? IconButton( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, icon: const Icon(Icons.delete_outlined), onPressed: onDelete, ) diff --git a/lib/pages/chat_details/chat_details_view.dart b/lib/pages/chat_details/chat_details_view.dart index 393c2a743..5c5d1b840 100644 --- a/lib/pages/chat_details/chat_details_view.dart +++ b/lib/pages/chat_details/chat_details_view.dart @@ -31,8 +31,13 @@ class ChatDetailsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final room = Matrix.of(context).client.getRoomById(controller.roomId!); - if (room == null) { + // #Pangea + if (room == null || room.membership == Membership.leave) { + // if (room == null) { + // Pangea# return Scaffold( appBar: AppBar( title: Text(L10n.of(context)!.oopsSomethingWentWrong), @@ -53,7 +58,7 @@ class ChatDetailsView extends StatelessWidget { final actualMembersCount = (room.summary.mInvitedMemberCount ?? 0) + (room.summary.mJoinedMemberCount ?? 0); final canRequestMoreMembers = members.length < actualMembersCount; - final iconColor = Theme.of(context).textTheme.bodyLarge!.color; + final iconColor = theme.textTheme.bodyLarge!.color; final displayname = room.getLocalizedDisplayname( MatrixLocals(L10n.of(context)!), ); @@ -61,7 +66,7 @@ class ChatDetailsView extends StatelessWidget { appBar: AppBar( leading: controller.widget.embeddedCloseButton ?? const Center(child: BackButton()), - elevation: Theme.of(context).appBarTheme.elevation, + elevation: theme.appBarTheme.elevation, actions: [ // #Pangea // if (room.canonicalAlias.isNotEmpty) @@ -84,7 +89,7 @@ class ChatDetailsView extends StatelessWidget { ), // title: Text(L10n.of(context)!.chatDetails), // Pangea# - backgroundColor: Theme.of(context).appBarTheme.backgroundColor, + backgroundColor: theme.appBarTheme.backgroundColor, ), body: MaxWidthBody( // #Pangea @@ -167,9 +172,8 @@ class ChatDetailsView extends StatelessWidget { size: 16, ), style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .onSurface, + foregroundColor: + theme.colorScheme.onSurface, ), label: Text( room.isDirectChat @@ -191,9 +195,8 @@ class ChatDetailsView extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .secondary, + foregroundColor: + theme.colorScheme.secondary, ), label: Text( L10n.of(context)!.countParticipants( @@ -209,7 +212,7 @@ class ChatDetailsView extends StatelessWidget { ), ], ), - + Divider(color: theme.dividerColor), // #Pangea if (room.isRoomAdmin) ClassNameButton( @@ -225,14 +228,12 @@ class ChatDetailsView extends StatelessWidget { room: room, controller: controller, ), - // Divider(color: Theme.of(context).dividerColor), // if (!room.canChangeStateEvent(EventTypes.RoomTopic)) // ListTile( // title: Text( // L10n.of(context)!.chatDescription, // style: TextStyle( - // color: - // Theme.of(context).colorScheme.secondary, + // color: theme.colorScheme.secondary, // fontWeight: FontWeight.bold, // ), // ), @@ -246,12 +247,10 @@ class ChatDetailsView extends StatelessWidget { // Text(L10n.of(context)!.setChatDescription), // icon: const Icon(Icons.edit_outlined), // style: TextButton.styleFrom( - // backgroundColor: Theme.of(context) - // .colorScheme - // .secondaryContainer, - // foregroundColor: Theme.of(context) - // .colorScheme - // .onSecondaryContainer, + // backgroundColor: + // theme.colorScheme.secondaryContainer, + // foregroundColor: + // theme.colorScheme.onSecondaryContainer, // ), // ), // ), @@ -273,25 +272,19 @@ class ChatDetailsView extends StatelessWidget { // fontStyle: room.topic.isEmpty // ? FontStyle.italic // : FontStyle.normal, - // color: Theme.of(context) - // .textTheme - // .bodyMedium! - // .color, - // decorationColor: Theme.of(context) - // .textTheme - // .bodyMedium! - // .color, + // color: theme.textTheme.bodyMedium!.color, + // decorationColor: + // theme.textTheme.bodyMedium!.color, // ), // onOpen: (url) => // UrlLauncher(context, url.url).launchUrl(), // ), // ), // const SizedBox(height: 16), - // Divider(color: Theme.of(context).dividerColor), + // Divider(color: theme.dividerColor), // ListTile( // leading: CircleAvatar( - // backgroundColor: - // Theme.of(context).scaffoldBackgroundColor, + // backgroundColor: theme.scaffoldBackgroundColor, // foregroundColor: iconColor, // child: const Icon( // Icons.insert_emoticon_outlined, @@ -306,8 +299,7 @@ class ChatDetailsView extends StatelessWidget { // if (!room.isDirectChat) // ListTile( // leading: CircleAvatar( - // backgroundColor: - // Theme.of(context).scaffoldBackgroundColor, + // backgroundColor: theme.scaffoldBackgroundColor, // foregroundColor: iconColor, // child: const Icon(Icons.shield_outlined), // ), @@ -334,8 +326,7 @@ class ChatDetailsView extends StatelessWidget { title: Text( L10n.of(context)!.editChatPermissions, style: TextStyle( - color: - Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -344,8 +335,7 @@ class ChatDetailsView extends StatelessWidget { L10n.of(context)!.whoCanPerformWhichAction, ), leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, + backgroundColor: theme.scaffoldBackgroundColor, foregroundColor: iconColor, child: const Icon( Icons.edit_attributes_outlined, @@ -357,7 +347,7 @@ class ChatDetailsView extends StatelessWidget { '/rooms/${room.id}/details/permissions', ), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), // #Pangea if (room.canInvite && !room.isDirectChat && @@ -578,7 +568,7 @@ class ChatDetailsView extends StatelessWidget { actualMembersCount.toString(), ), style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -588,12 +578,10 @@ class ChatDetailsView extends StatelessWidget { // ListTile( // title: Text(L10n.of(context)!.inviteContact), // leading: CircleAvatar( - // backgroundColor: Theme.of(context) - // .colorScheme - // .primaryContainer, - // foregroundColor: Theme.of(context) - // .colorScheme - // .onPrimaryContainer, + // backgroundColor: + // theme.colorScheme.primaryContainer, + // foregroundColor: + // theme.colorScheme.onPrimaryContainer, // radius: Avatar.defaultSize / 2, // child: const Icon(Icons.add_outlined), // ), @@ -615,8 +603,7 @@ class ChatDetailsView extends StatelessWidget { ), ), leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, + backgroundColor: theme.scaffoldBackgroundColor, child: const Icon( Icons.group_outlined, color: Colors.grey, diff --git a/lib/pages/chat_details/participant_list_item.dart b/lib/pages/chat_details/participant_list_item.dart index 9b5580692..dc24163d5 100644 --- a/lib/pages/chat_details/participant_list_item.dart +++ b/lib/pages/chat_details/participant_list_item.dart @@ -13,6 +13,8 @@ class ParticipantListItem extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final membershipBatch = switch (user.membership) { Membership.ban => L10n.of(context)!.banned, Membership.invite => L10n.of(context)!.invited, @@ -54,11 +56,13 @@ class ParticipantListItem extends StatelessWidget { margin: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( // #Pangea - // color: Theme.of(context).colorScheme.primaryContainer, - color: Theme.of(context).secondaryHeaderColor, + // color: theme.colorScheme.primaryContainer, + color: theme.secondaryHeaderColor, + // Pangea# borderRadius: BorderRadius.circular(8), + // #Pangea // border: Border.all( - // color: Theme.of(context).colorScheme.primary, + // color: theme.colorScheme.primary, // ), // Pangea# ), @@ -67,7 +71,7 @@ class ParticipantListItem extends StatelessWidget { // #Pangea // style: TextStyle( // fontSize: 14, - // color: Theme.of(context).colorScheme.primary, + // color: theme.colorScheme.primary, // ), // Pangea# ), @@ -78,7 +82,7 @@ class ParticipantListItem extends StatelessWidget { padding: const EdgeInsets.all(4), margin: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( - color: Theme.of(context).secondaryHeaderColor, + color: theme.secondaryHeaderColor, borderRadius: BorderRadius.circular(8), ), child: Center(child: Text(membershipBatch)), diff --git a/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart b/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart index d53239a07..13974dfca 100644 --- a/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart +++ b/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart @@ -1,14 +1,12 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:go_router/go_router.dart'; -import 'package:matrix/matrix.dart'; -import 'package:url_launcher/url_launcher_string.dart'; - import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings.dart'; import 'package:fluffychat/utils/beautify_string_extension.dart'; import 'package:fluffychat/widgets/layouts/max_width_body.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:go_router/go_router.dart'; +import 'package:matrix/matrix.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class ChatEncryptionSettingsView extends StatelessWidget { final ChatEncryptionSettingsController controller; @@ -17,6 +15,8 @@ class ChatEncryptionSettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final room = controller.room; return StreamBuilder( stream: room.client.onSync.stream.where( @@ -42,10 +42,8 @@ class ChatEncryptionSettingsView extends StatelessWidget { children: [ SwitchListTile( secondary: CircleAvatar( - foregroundColor: - Theme.of(context).colorScheme.onPrimaryContainer, - backgroundColor: - Theme.of(context).colorScheme.primaryContainer, + foregroundColor: theme.colorScheme.onPrimaryContainer, + backgroundColor: theme.colorScheme.primaryContainer, child: const Icon(Icons.lock_outlined), ), title: Text(L10n.of(context)!.encryptThisChat), @@ -56,7 +54,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { // Icon( // CupertinoIcons.lock_shield, // size: 128, - // color: Theme.of(context).colorScheme.onInverseSurface, + // color: theme.colorScheme.onInverseSurface, // ), // Pangea# const Divider(), @@ -145,13 +143,10 @@ class ChatEncryptionSettingsView extends StatelessWidget { AppConfig.borderRadius, ), side: BorderSide( - color: - Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), ), - color: Theme.of(context) - .colorScheme - .primaryContainer, + color: theme.colorScheme.primaryContainer, child: Padding( padding: const EdgeInsets.all(4.0), child: Text( @@ -159,9 +154,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( - color: Theme.of(context) - .colorScheme - .primary, + color: theme.colorScheme.primary, fontSize: 12, fontStyle: FontStyle.italic, ), @@ -176,7 +169,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { L10n.of(context)!.unknownEncryptionAlgorithm, style: TextStyle( fontFamily: 'RobotoMono', - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, ), ), ), diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 2f5aa96ff..9dffaed8a 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -26,6 +26,8 @@ class ChatListViewBody extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final client = Matrix.of(context).client; final activeSpace = controller.activeSpaceId; if (activeSpace != null) { @@ -57,10 +59,8 @@ class ChatListViewBody extends StatelessWidget { .toList(); final userSearchResult = controller.userSearchResult; const dummyChatCount = 4; - final titleColor = - Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(100); - final subtitleColor = - Theme.of(context).textTheme.bodyLarge!.color!.withAlpha(50); + final titleColor = theme.textTheme.bodyLarge!.color!.withAlpha(100); + final subtitleColor = theme.textTheme.bodyLarge!.color!.withAlpha(50); final filter = controller.searchController.text.toLowerCase(); return StreamBuilder( key: ValueKey( @@ -144,7 +144,7 @@ class ChatListViewBody extends StatelessWidget { clipBehavior: Clip.hardEdge, decoration: const BoxDecoration(), child: Material( - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, child: ListTile( leading: const Icon(Icons.vpn_key), title: Text(L10n.of(context)!.dehydrateTor), @@ -199,11 +199,8 @@ class ChatListViewBody extends StatelessWidget { decoration: BoxDecoration( color: filter == controller.activeFilter - ? Theme.of(context) - .colorScheme - .primary - : Theme.of(context) - .colorScheme + ? theme.colorScheme.primary + : theme.colorScheme .secondaryContainer, borderRadius: BorderRadius.circular( AppConfig.borderRadius, @@ -219,11 +216,8 @@ class ChatListViewBody extends StatelessWidget { : FontWeight.normal, color: filter == controller.activeFilter - ? Theme.of(context) - .colorScheme - .onPrimary - : Theme.of(context) - .colorScheme + ? theme.colorScheme.onPrimary + : theme.colorScheme .onSecondaryContainer, ), ), @@ -245,19 +239,19 @@ class ChatListViewBody extends StatelessWidget { rooms.isEmpty && !controller.isSearchMode) ...[ // #Pangea - // Padding( - // padding: const EdgeInsets.all(32.0), - // child: Icon( - // CupertinoIcons.chat_bubble_2, - // size: 128, - // color: Theme.of(context).colorScheme.secondary, - // ), - // ), Center( child: ChatListBodyStartText( controller: controller, ), ), + // Padding( + // padding: const EdgeInsets.all(32.0), + // child: Icon( + // CupertinoIcons.chat_bubble_2, + // size: 128, + // color: theme.colorScheme.secondary, + // ), + // ), // Pangea# ], ], @@ -273,7 +267,7 @@ class ChatListViewBody extends StatelessWidget { backgroundColor: titleColor, child: CircularProgressIndicator( strokeWidth: 1, - color: Theme.of(context).textTheme.bodyLarge!.color, + color: theme.textTheme.bodyLarge!.color, ), ), title: Row( diff --git a/lib/pages/chat_list/chat_list_header.dart b/lib/pages/chat_list/chat_list_header.dart index b16711021..411709a99 100644 --- a/lib/pages/chat_list/chat_list_header.dart +++ b/lib/pages/chat_list/chat_list_header.dart @@ -16,6 +16,8 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final selectMode = controller.selectMode; return SliverAppBar( @@ -33,7 +35,7 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { tooltip: L10n.of(context)!.cancel, icon: const Icon(Icons.close_outlined), onPressed: controller.cancelAction, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), title: selectMode == SelectMode.share ? Text( @@ -51,7 +53,7 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { // globalSearch: globalSearch, // ), // decoration: InputDecoration( - // fillColor: Theme.of(context).colorScheme.secondaryContainer, + // fillColor: theme.colorScheme.secondaryContainer, // border: OutlineInputBorder( // borderSide: BorderSide.none, // borderRadius: BorderRadius.circular(99), @@ -59,7 +61,7 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { // contentPadding: EdgeInsets.zero, // hintText: L10n.of(context)!.searchChatsRooms, // hintStyle: TextStyle( - // color: Theme.of(context).colorScheme.onPrimaryContainer, + // color: theme.colorScheme.onPrimaryContainer, // fontWeight: FontWeight.normal, // ), // floatingLabelBehavior: FloatingLabelBehavior.never, @@ -68,14 +70,13 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { // tooltip: L10n.of(context)!.cancel, // icon: const Icon(Icons.close_outlined), // onPressed: controller.cancelSearch, - // color: Theme.of(context).colorScheme.onPrimaryContainer, + // color: theme.colorScheme.onPrimaryContainer, // ) // : IconButton( // onPressed: controller.startSearch, // icon: Icon( // Icons.search_outlined, - // color: - // Theme.of(context).colorScheme.onPrimaryContainer, + // color: theme.colorScheme.onPrimaryContainer, // ), // ), // suffixIcon: controller.isSearchMode && globalSearch diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index e24cfdb70..5cae0c824 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -65,12 +65,13 @@ class ChatListItem extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final isMuted = room.pushRuleState != PushRuleState.notify; final typingText = room.getLocalizedTypingText(context); final lastEvent = room.lastEvent; final ownMessage = lastEvent?.senderId == room.client.userID; final unread = room.isUnread || room.membership == Membership.invite; - final theme = Theme.of(context); final directChatMatrixId = room.directChatMatrixID; final isDirectChat = directChatMatrixId != null; final unreadBubbleSize = unread || room.hasNewMessages @@ -128,7 +129,7 @@ class ChatListItem extends StatelessWidget { border: BorderSide( width: 2, color: backgroundColor ?? - Theme.of(context).colorScheme.surface, + theme.colorScheme.surface, ), borderRadius: BorderRadius.circular( AppConfig.borderRadius / 4, @@ -148,7 +149,7 @@ class ChatListItem extends StatelessWidget { : BorderSide( width: 2, color: backgroundColor ?? - Theme.of(context).colorScheme.surface, + theme.colorScheme.surface, ), borderRadius: room.isSpace ? BorderRadius.circular( diff --git a/lib/pages/chat_list/nav_rail_item.dart b/lib/pages/chat_list/nav_rail_item.dart index d09659f88..6264b0b18 100644 --- a/lib/pages/chat_list/nav_rail_item.dart +++ b/lib/pages/chat_list/nav_rail_item.dart @@ -35,6 +35,8 @@ class _NaviRailItemState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final borderRadius = BorderRadius.circular(AppConfig.borderRadius); return SizedBox( height: 64, @@ -50,7 +52,7 @@ class _NaviRailItemState extends State { duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, borderRadius: const BorderRadius.only( topRight: Radius.circular(90), bottomRight: Radius.circular(90), @@ -66,8 +68,8 @@ class _NaviRailItemState extends State { child: Material( borderRadius: borderRadius, color: widget.isSelected - ? Theme.of(context).colorScheme.primaryContainer - : Theme.of(context).colorScheme.surface, + ? theme.colorScheme.primaryContainer + : theme.colorScheme.surface, child: Tooltip( message: widget.toolTip, child: InkWell( diff --git a/lib/pages/chat_list/navi_rail_item.dart b/lib/pages/chat_list/navi_rail_item.dart index 6cbb70e2e..77837bfef 100644 --- a/lib/pages/chat_list/navi_rail_item.dart +++ b/lib/pages/chat_list/navi_rail_item.dart @@ -27,6 +27,8 @@ class NaviRailItem extends StatelessWidget { }); @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final borderRadius = BorderRadius.circular(AppConfig.borderRadius); final icon = isSelected ? selectedIcon ?? this.icon : this.icon; final unreadBadgeFilter = this.unreadBadgeFilter; @@ -46,7 +48,7 @@ class NaviRailItem extends StatelessWidget { duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, borderRadius: const BorderRadius.only( topRight: Radius.circular(90), bottomRight: Radius.circular(90), @@ -62,8 +64,8 @@ class NaviRailItem extends StatelessWidget { child: Material( borderRadius: borderRadius, color: isSelected - ? Theme.of(context).colorScheme.primaryContainer - : Theme.of(context).colorScheme.surface, + ? theme.colorScheme.primaryContainer + : theme.colorScheme.surface, child: Tooltip( message: toolTip, child: InkWell( diff --git a/lib/pages/chat_list/search_title.dart b/lib/pages/chat_list/search_title.dart index 62bcfb684..496a5feec 100644 --- a/lib/pages/chat_list/search_title.dart +++ b/lib/pages/chat_list/search_title.dart @@ -17,55 +17,59 @@ class SearchTitle extends StatelessWidget { }); @override - Widget build(BuildContext context) => Material( - shape: Border( - top: BorderSide( - color: Theme.of(context).dividerColor, - width: 1, - ), - bottom: BorderSide( - color: Theme.of(context).dividerColor, - width: 1, - ), + Widget build(BuildContext context) { + final theme = Theme.of(context); + + return Material( + shape: Border( + top: BorderSide( + color: theme.dividerColor, + width: 1, ), - color: color ?? Theme.of(context).colorScheme.surface, - child: InkWell( - onTap: onTap, - splashColor: Theme.of(context).colorScheme.surface, - child: Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 8, - ), - child: IconTheme( - data: Theme.of(context).iconTheme.copyWith(size: 16), - child: Row( - children: [ - icon, - const SizedBox(width: 16), - Text( - title, - textAlign: TextAlign.left, - style: TextStyle( - color: Theme.of(context).colorScheme.onSurface, - fontSize: 12, - fontWeight: FontWeight.bold, + bottom: BorderSide( + color: theme.dividerColor, + width: 1, + ), + ), + color: color ?? theme.colorScheme.surface, + child: InkWell( + onTap: onTap, + splashColor: theme.colorScheme.surface, + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + child: IconTheme( + data: theme.iconTheme.copyWith(size: 16), + child: Row( + children: [ + icon, + const SizedBox(width: 16), + Text( + title, + textAlign: TextAlign.left, + style: TextStyle( + color: theme.colorScheme.onSurface, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + if (trailing != null) + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: trailing!, ), ), - if (trailing != null) - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: trailing!, - ), - ), - ], - ), + ], ), ), ), ), - ); + ), + ); + } } diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 363d92cb6..96261ea82 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -239,6 +239,8 @@ class _SpaceViewState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final room = Matrix.of(context).client.getRoomById(widget.spaceId); final displayname = room?.getLocalizedDisplayname() ?? L10n.of(context)!.nothingFound; @@ -357,8 +359,7 @@ class _SpaceViewState extends State { onChanged: (_) => setState(() {}), textInputAction: TextInputAction.search, decoration: InputDecoration( - fillColor: - Theme.of(context).colorScheme.secondaryContainer, + fillColor: theme.colorScheme.secondaryContainer, border: OutlineInputBorder( borderSide: BorderSide.none, borderRadius: BorderRadius.circular(99), @@ -366,9 +367,7 @@ class _SpaceViewState extends State { contentPadding: EdgeInsets.zero, hintText: L10n.of(context)!.search, hintStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, + color: theme.colorScheme.onPrimaryContainer, fontWeight: FontWeight.normal, ), floatingLabelBehavior: FloatingLabelBehavior.never, @@ -376,9 +375,7 @@ class _SpaceViewState extends State { onPressed: () {}, icon: Icon( Icons.search_outlined, - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, + color: theme.colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/pages/chat_list/status_msg_list.dart b/lib/pages/chat_list/status_msg_list.dart index 9b69e2a16..9039f908a 100644 --- a/lib/pages/chat_list/status_msg_list.dart +++ b/lib/pages/chat_list/status_msg_list.dart @@ -116,6 +116,8 @@ class PresenceAvatar extends StatelessWidget { return FutureBuilder( future: client.getProfileFromUserId(presence.userid), builder: (context, snapshot) { + final theme = Theme.of(context); + final profile = snapshot.data; final displayName = profile?.displayName ?? presence.userid.localpart ?? @@ -123,9 +125,8 @@ class PresenceAvatar extends StatelessWidget { final statusMsg = presence.statusMsg; final statusMsgBubbleElevation = - Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4; - final statusMsgBubbleShadowColor = - Theme.of(context).colorScheme.onSurface; + theme.appBarTheme.scrolledUnderElevation ?? 4; + final statusMsgBubbleShadowColor = theme.colorScheme.onSurface; final statusMsgBubbleColor = Colors.white.withAlpha(245); return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), diff --git a/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart b/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart index 11c834b50..8d03b043b 100644 --- a/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart +++ b/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart @@ -13,6 +13,8 @@ class ChatPermissionsSettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Scaffold( appBar: AppBar( leading: const Center(child: BackButton()), @@ -63,12 +65,12 @@ class ChatPermissionsSettingsView extends StatelessWidget { L10n.of(context)!.chatPermissionsDescription, ), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.chatPermissions, style: TextStyle( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, fontWeight: FontWeight.bold, ), ), @@ -89,13 +91,12 @@ class ChatPermissionsSettingsView extends StatelessWidget { canEdit: room.canChangePowerLevel, ), // #Pangea - // Why would teacher need to stop students from seeing notifications? - // Divider(color: Theme.of(context).dividerColor), + // Divider(color: theme.dividerColor), // ListTile( // title: Text( // L10n.of(context)!.notifications, // style: TextStyle( - // color: Theme.of(context).colorScheme.primary, + // color: theme.colorScheme.primary, // fontWeight: FontWeight.bold, // ), // ), @@ -125,22 +126,17 @@ class ChatPermissionsSettingsView extends StatelessWidget { // ); // }, // ), - // Only show if there are actually items in this category - if (eventsPowerLevels.isNotEmpty) - // Pangea# - Divider(color: Theme.of(context).dividerColor), - // #Pangea - if (eventsPowerLevels.isNotEmpty) - // Pangea# - ListTile( - title: Text( - L10n.of(context)!.configureChat, - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - fontWeight: FontWeight.bold, - ), + // Pangea# + Divider(color: theme.dividerColor), + ListTile( + title: Text( + L10n.of(context)!.configureChat, + style: TextStyle( + color: theme.colorScheme.primary, + fontWeight: FontWeight.bold, ), ), + ), for (final entry in eventsPowerLevels.entries) PermissionsListTile( permissionKey: entry.key, diff --git a/lib/pages/chat_permissions_settings/permission_list_tile.dart b/lib/pages/chat_permissions_settings/permission_list_tile.dart index b65b403d8..2914f9112 100644 --- a/lib/pages/chat_permissions_settings/permission_list_tile.dart +++ b/lib/pages/chat_permissions_settings/permission_list_tile.dart @@ -69,6 +69,8 @@ class PermissionsListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final color = permission >= 100 ? Colors.orangeAccent : permission >= 50 @@ -77,7 +79,7 @@ class PermissionsListTile extends StatelessWidget { return ListTile( title: Text( getLocalizedPowerLevelString(context), - style: Theme.of(context).textTheme.titleSmall, + style: theme.textTheme.titleSmall, ), trailing: Material( color: color.withAlpha(32), diff --git a/lib/pages/chat_search/chat_search_files_tab.dart b/lib/pages/chat_search/chat_search_files_tab.dart index 85525ab6f..e981efb19 100644 --- a/lib/pages/chat_search/chat_search_files_tab.dart +++ b/lib/pages/chat_search/chat_search_files_tab.dart @@ -28,6 +28,7 @@ class ChatSearchFilesTab extends StatelessWidget { return StreamBuilder( stream: searchStream, builder: (context, snapshot) { + final theme = Theme.of(context); final events = snapshot.data?.$1; if (searchStream == null || events == null) { return Column( @@ -82,10 +83,8 @@ class ChatSearchFilesTab extends StatelessWidget { padding: const EdgeInsets.all(16.0), child: TextButton.icon( style: TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.secondaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onSecondaryContainer, + backgroundColor: theme.colorScheme.secondaryContainer, + foregroundColor: theme.colorScheme.onSecondaryContainer, ), onPressed: () => startSearch( prevBatch: nextBatch, @@ -127,21 +126,21 @@ class ChatSearchFilesTab extends StatelessWidget { Expanded( child: Container( height: 1, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( event.originServerTs.localizedTime(context), - style: Theme.of(context).textTheme.labelSmall, + style: theme.textTheme.labelSmall, textAlign: TextAlign.center, ), ), Expanded( child: Container( height: 1, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ), ], @@ -151,7 +150,7 @@ class ChatSearchFilesTab extends StatelessWidget { Material( borderRadius: BorderRadius.circular(AppConfig.borderRadius), - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, clipBehavior: Clip.hardEdge, child: ListTile( leading: const Icon(Icons.file_present_outlined), diff --git a/lib/pages/chat_search/chat_search_images_tab.dart b/lib/pages/chat_search/chat_search_images_tab.dart index 9f8c1f0c9..90cdc839b 100644 --- a/lib/pages/chat_search/chat_search_images_tab.dart +++ b/lib/pages/chat_search/chat_search_images_tab.dart @@ -28,6 +28,7 @@ class ChatSearchImagesTab extends StatelessWidget { return StreamBuilder( stream: searchStream, builder: (context, snapshot) { + final theme = Theme.of(context); final events = snapshot.data?.$1; if (searchStream == null || events == null) { return Column( @@ -91,10 +92,8 @@ class ChatSearchImagesTab extends StatelessWidget { padding: const EdgeInsets.all(16.0), child: TextButton.icon( style: TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.secondaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onSecondaryContainer, + backgroundColor: theme.colorScheme.secondaryContainer, + foregroundColor: theme.colorScheme.onSecondaryContainer, ), onPressed: () => startSearch( prevBatch: nextBatch, @@ -119,7 +118,7 @@ class ChatSearchImagesTab extends StatelessWidget { Expanded( child: Container( height: 1, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ), Padding( @@ -128,14 +127,14 @@ class ChatSearchImagesTab extends StatelessWidget { DateFormat.yMMMM( Localizations.localeOf(context).languageCode, ).format(eventsByMonthList[i].key), - style: Theme.of(context).textTheme.labelSmall, + style: theme.textTheme.labelSmall, textAlign: TextAlign.center, ), ), Expanded( child: Container( height: 1, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ), ], diff --git a/lib/pages/chat_search/chat_search_message_tab.dart b/lib/pages/chat_search/chat_search_message_tab.dart index 7542d6ae9..a2d34fa9e 100644 --- a/lib/pages/chat_search/chat_search_message_tab.dart +++ b/lib/pages/chat_search/chat_search_message_tab.dart @@ -33,6 +33,7 @@ class ChatSearchMessageTab extends StatelessWidget { key: ValueKey(searchQuery), stream: searchStream, builder: (context, snapshot) { + final theme = Theme.of(context); if (searchStream == null) { return Column( mainAxisAlignment: MainAxisAlignment.center, @@ -55,7 +56,7 @@ class ChatSearchMessageTab extends StatelessWidget { child: ListView.separated( itemCount: events.length + 1, separatorBuilder: (context, _) => Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, height: 1, ), itemBuilder: (context, i) { @@ -79,10 +80,8 @@ class ChatSearchMessageTab extends StatelessWidget { padding: const EdgeInsets.all(16.0), child: TextButton.icon( style: TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.secondaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onSecondaryContainer, + backgroundColor: theme.colorScheme.secondaryContainer, + foregroundColor: theme.colorScheme.onSecondaryContainer, ), onPressed: () => startSearch( prevBatch: nextBatch, @@ -130,6 +129,8 @@ class _MessageSearchResultListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return ListTile( title: Row( children: [ @@ -153,9 +154,9 @@ class _MessageSearchResultListTile extends StatelessWidget { subtitle: Linkify( options: const LinkifyOptions(humanize: false), linkStyle: TextStyle( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, decoration: TextDecoration.underline, - decorationColor: Theme.of(context).colorScheme.primary, + decorationColor: theme.colorScheme.primary, ), onOpen: (url) => UrlLauncher(context, url.url).launchUrl(), text: event diff --git a/lib/pages/device_settings/device_settings_view.dart b/lib/pages/device_settings/device_settings_view.dart index e107d30c9..20fb9e800 100644 --- a/lib/pages/device_settings/device_settings_view.dart +++ b/lib/pages/device_settings/device_settings_view.dart @@ -22,6 +22,7 @@ class DevicesSettingsView extends StatelessWidget { child: FutureBuilder( future: controller.loadUserDevices(context), builder: (BuildContext context, snapshot) { + final theme = Theme.of(context); if (snapshot.hasError) { return Center( child: Column( @@ -58,7 +59,7 @@ class DevicesSettingsView extends StatelessWidget { L10n.of(context)!.thisDevice, style: TextStyle( fontWeight: FontWeight.bold, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), textAlign: TextAlign.left, ), @@ -86,12 +87,10 @@ class DevicesSettingsView extends StatelessWidget { L10n.of(context)!.removeAllOtherDevices, ), style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .onErrorContainer, - backgroundColor: Theme.of(context) - .colorScheme - .errorContainer, + foregroundColor: + theme.colorScheme.onErrorContainer, + backgroundColor: + theme.colorScheme.errorContainer, ), icon: controller.loadingDeletingDevices ? const CircularProgressIndicator.adaptive( diff --git a/lib/pages/homeserver_picker/homeserver_app_bar.dart b/lib/pages/homeserver_picker/homeserver_app_bar.dart index d041c8852..1830988fe 100644 --- a/lib/pages/homeserver_picker/homeserver_app_bar.dart +++ b/lib/pages/homeserver_picker/homeserver_app_bar.dart @@ -16,14 +16,15 @@ class HomeserverAppBar extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return TypeAheadField( decorationBuilder: (context, child) => ConstrainedBox( constraints: const BoxConstraints(maxHeight: 256), child: Material( borderRadius: BorderRadius.circular(AppConfig.borderRadius), - elevation: Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4, - shadowColor: - Theme.of(context).appBarTheme.shadowColor ?? Colors.black, + elevation: theme.appBarTheme.scrolledUnderElevation ?? 4, + shadowColor: theme.appBarTheme.shadowColor ?? Colors.black, child: child, ), ), @@ -91,9 +92,9 @@ class HomeserverAppBar extends StatelessWidget { ) : null, fillColor: FluffyThemes.isColumnMode(context) - ? Theme.of(context).colorScheme.surface + ? theme.colorScheme.surface // ignore: deprecated_member_use - : Theme.of(context).colorScheme.surfaceVariant, + : theme.colorScheme.surfaceVariant, prefixText: '${L10n.of(context)!.homeserver}: ', hintText: L10n.of(context)!.enterYourHomeserver, suffixIcon: const Icon(Icons.search), diff --git a/lib/pages/homeserver_picker/homeserver_picker_view.dart b/lib/pages/homeserver_picker/homeserver_picker_view.dart index 9e8ca13ff..6a1473c19 100644 --- a/lib/pages/homeserver_picker/homeserver_picker_view.dart +++ b/lib/pages/homeserver_picker/homeserver_picker_view.dart @@ -16,6 +16,8 @@ class HomeserverPickerView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final identityProviders = controller.identityProviders; final errorText = controller.error; // #Pangea @@ -30,10 +32,10 @@ class HomeserverPickerView extends StatelessWidget { // #Pangea // enforceMobileMode: Matrix.of(context).client.isLogged(), // appBar: AppBar( - // titleSpacing: 12, - // automaticallyImplyLeading: false, - // surfaceTintColor: Theme.of(context).colorScheme.background, - // title: HomeserverAppBar(controller: controller), + // titleSpacing,: 12, + // automaticallyImplyLeading: false, + // surfaceTintColor: theme.colorScheme.surface, + // title: HomeserverAppBar(controller: controller), // ), appBar: AppBar( centerTitle: true, @@ -58,7 +60,7 @@ class HomeserverPickerView extends StatelessWidget { // clipBehavior: Clip.hardEdge, // borderRadius: // const BorderRadius.vertical(bottom: Radius.circular(8)), - // color: Theme.of(context).colorScheme.surface, + // color: theme.colorScheme.surface, // child: ListTile( // leading: const Icon(Icons.vpn_key), // title: Text(L10n.of(context)!.hydrateTor), @@ -96,7 +98,7 @@ class HomeserverPickerView extends StatelessWidget { errorText, textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, fontSize: 18, ), ), @@ -108,7 +110,7 @@ class HomeserverPickerView extends StatelessWidget { // .pleaseTryAgainLaterOrChooseDifferentServer, // textAlign: TextAlign.center, // style: TextStyle( - // color: Theme.of(context).colorScheme.error, + // color: theme.colorScheme.error, // fontSize: 12, // ), // ), @@ -251,6 +253,8 @@ class _LoginButton extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final icon = this.icon; return Container( margin: const EdgeInsets.only(bottom: 12), @@ -263,16 +267,15 @@ class _LoginButton extends StatelessWidget { side: FluffyThemes.isColumnMode(context) ? BorderSide.none : BorderSide( - color: Theme.of(context).colorScheme.outlineVariant, + color: theme.colorScheme.outlineVariant, width: 1, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(99), ), - foregroundColor: Theme.of(context).colorScheme.onSurface, - backgroundColor: withBorder - ? Theme.of(context).colorScheme.surface - : Colors.transparent, + foregroundColor: theme.colorScheme.onSurface, + backgroundColor: + withBorder ? theme.colorScheme.surface : Colors.transparent, ), onPressed: onPressed, label: Text(label), diff --git a/lib/pages/invitation_selection/invitation_selection_view.dart b/lib/pages/invitation_selection/invitation_selection_view.dart index a776cccb0..793631e22 100644 --- a/lib/pages/invitation_selection/invitation_selection_view.dart +++ b/lib/pages/invitation_selection/invitation_selection_view.dart @@ -189,6 +189,8 @@ class _InviteContactListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Opacity( opacity: isMember ? 0.5 : 1, child: ListTile( @@ -207,7 +209,7 @@ class _InviteContactListTile extends StatelessWidget { maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, ), ), onTap: isMember ? null : onTap, diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index 99d082a76..b4e5a91ae 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -94,6 +94,8 @@ class KeyVerificationPageState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + User? user; final directChatId = widget.request.client.getDirectChatFromUserId(widget.request.userId); @@ -139,10 +141,8 @@ class KeyVerificationPageState extends State { obscureText: true, decoration: InputDecoration( hintText: L10n.of(context)!.passphraseOrKey, - prefixStyle: - TextStyle(color: Theme.of(context).colorScheme.primary), - suffixStyle: - TextStyle(color: Theme.of(context).colorScheme.primary), + prefixStyle: TextStyle(color: theme.colorScheme.primary), + suffixStyle: TextStyle(color: theme.colorScheme.primary), border: const OutlineInputBorder(), ), ), diff --git a/lib/pages/login/login_view.dart b/lib/pages/login/login_view.dart index 818dd06b4..eedfc4b2f 100644 --- a/lib/pages/login/login_view.dart +++ b/lib/pages/login/login_view.dart @@ -11,6 +11,8 @@ class LoginView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + // #Pangea // final homeserver = Matrix.of(context) // .getLoginClient() @@ -21,8 +23,9 @@ class LoginView extends StatelessWidget { // final titleParts = title.split(homeserver); // final textFieldFillColor = FluffyThemes.isColumnMode(context) - // ? Theme.of(context).colorScheme.background - // : Theme.of(context).colorScheme.surfaceVariant; + // ? theme.colorScheme.surface + // // ignore: deprecated_member_use + // : theme.colorScheme.surfaceVariant; // Pangea# return LoginScaffold( @@ -100,18 +103,13 @@ class LoginView extends StatelessWidget { // #Pangea // errorStyle: const TextStyle(color: Colors.orange), errorStyle: TextStyle( - color: Theme.of(context).textTheme.bodyMedium?.color, + color: theme.textTheme.bodyMedium?.color, fontSize: 14, ), + // fillColor: textFieldFillColor, + fillColor: theme.colorScheme.surface.withOpacity(0.75), // Pangea# hintText: L10n.of(context)!.emailOrUsername, - // #Pangea - // fillColor: textFieldFillColor, - fillColor: Theme.of(context) - .colorScheme - .surface - .withOpacity(0.75), - // Pangea# ), ), ), @@ -133,10 +131,11 @@ class LoginView extends StatelessWidget { // #Pangea // errorStyle: const TextStyle(color: Colors.orange), errorStyle: TextStyle( - color: Theme.of(context).textTheme.bodyMedium?.color, + color: theme.textTheme.bodyMedium?.color, fontSize: 14, ), // fillColor: textFieldFillColor, + fillColor: theme.colorScheme.surface.withOpacity(0.75), // prevent enter key from clicking show password button suffixIcon: MouseRegion( cursor: SystemMouseCursors.click, @@ -162,12 +161,6 @@ class LoginView extends StatelessWidget { // ), // Pangea# hintText: L10n.of(context)!.password, - // #Pangea - fillColor: Theme.of(context) - .colorScheme - .surface - .withOpacity(0.75), - // Pangea# ), ), ), @@ -184,8 +177,8 @@ class LoginView extends StatelessWidget { ), // child: ElevatedButton.icon( // style: ElevatedButton.styleFrom( - // backgroundColor: Theme.of(context).colorScheme.primary, - // foregroundColor: Theme.of(context).colorScheme.onPrimary, + // backgroundColor: theme.colorScheme.primary, + // foregroundColor: theme.colorScheme.onPrimary, // ), // onPressed: controller.loading ? null : controller.login, // icon: const Icon(Icons.login_outlined), @@ -240,7 +233,7 @@ class LoginView extends StatelessWidget { // ? () {} // : controller.passwordForgotten, // style: TextButton.styleFrom( - // foregroundColor: Theme.of(context).colorScheme.error, + // foregroundColor: theme.colorScheme.error, // ), // icon: const Icon(Icons.safety_check_outlined), // label: Text(L10n.of(context)!.passwordForgotten), diff --git a/lib/pages/new_group/new_group_view.dart b/lib/pages/new_group/new_group_view.dart index e3486e6a9..0192de6f6 100644 --- a/lib/pages/new_group/new_group_view.dart +++ b/lib/pages/new_group/new_group_view.dart @@ -16,6 +16,8 @@ class NewGroupView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final avatar = controller.avatar; final error = controller.error; return Scaffold( @@ -113,12 +115,12 @@ class NewGroupView extends StatelessWidget { // SwitchListTile.adaptive( // secondary: Icon( // Icons.lock_outlined, - // color: Theme.of(context).colorScheme.onSurface, + // color: theme.colorScheme.onSurface, // ), // title: Text( // L10n.of(context)!.enableEncryption, // style: TextStyle( - // color: Theme.of(context).colorScheme.onSurface, + // color: theme.colorScheme.onSurface, // ), // ), // value: !controller.publicGroup, @@ -154,12 +156,12 @@ class NewGroupView extends StatelessWidget { : ListTile( leading: Icon( Icons.warning_outlined, - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, ), title: Text( error.toLocalizedString(context), style: TextStyle( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, ), ), ), diff --git a/lib/pages/new_private_chat/new_private_chat_view.dart b/lib/pages/new_private_chat/new_private_chat_view.dart index 80cc725fc..6db860341 100644 --- a/lib/pages/new_private_chat/new_private_chat_view.dart +++ b/lib/pages/new_private_chat/new_private_chat_view.dart @@ -20,13 +20,15 @@ class NewPrivateChatView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final searchResponse = controller.searchResponse; return Scaffold( appBar: AppBar( scrolledUnderElevation: 0, leading: const Center(child: BackButton()), title: Text(L10n.of(context)!.newChat), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, + backgroundColor: theme.scaffoldBackgroundColor, actions: [ TextButton( onPressed: @@ -107,7 +109,7 @@ class NewPrivateChatView extends StatelessWidget { ], ), style: TextStyle( - color: Theme.of(context).colorScheme.onSurface, + color: theme.colorScheme.onSurface, fontSize: 13, ), ), @@ -115,10 +117,8 @@ class NewPrivateChatView extends StatelessWidget { const SizedBox(height: 8), ListTile( leading: CircleAvatar( - backgroundColor: - Theme.of(context).colorScheme.secondaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onSecondaryContainer, + backgroundColor: theme.colorScheme.secondaryContainer, + foregroundColor: theme.colorScheme.onSecondaryContainer, child: Icon(Icons.adaptive.share_outlined), ), title: Text(L10n.of(context)!.shareInviteLink), @@ -126,10 +126,8 @@ class NewPrivateChatView extends StatelessWidget { ), ListTile( leading: CircleAvatar( - backgroundColor: - Theme.of(context).colorScheme.tertiaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onTertiaryContainer, + backgroundColor: theme.colorScheme.tertiaryContainer, + foregroundColor: theme.colorScheme.onTertiaryContainer, child: const Icon(Icons.group_add_outlined), ), title: Text(L10n.of(context)!.createGroup), @@ -138,10 +136,8 @@ class NewPrivateChatView extends StatelessWidget { if (PlatformInfos.isMobile) ListTile( leading: CircleAvatar( - backgroundColor: - Theme.of(context).colorScheme.primaryContainer, - foregroundColor: - Theme.of(context).colorScheme.onPrimaryContainer, + backgroundColor: theme.colorScheme.primaryContainer, + foregroundColor: theme.colorScheme.onPrimaryContainer, child: const Icon(Icons.qr_code_scanner_outlined), ), title: Text(L10n.of(context)!.scanQrCode), @@ -156,8 +152,7 @@ class NewPrivateChatView extends StatelessWidget { borderRadius: BorderRadius.circular(12), elevation: 10, color: Colors.white, - shadowColor: - Theme.of(context).appBarTheme.shadowColor, + shadowColor: theme.appBarTheme.shadowColor, clipBehavior: Clip.hardEdge, child: Padding( padding: const EdgeInsets.all(8), @@ -167,12 +162,9 @@ class NewPrivateChatView extends StatelessWidget { decoration: PrettyQrDecoration( shape: PrettyQrSmoothSymbol( roundFactor: 1, - color: Theme.of(context).brightness == - Brightness.light - ? Theme.of(context).colorScheme.primary - : Theme.of(context) - .colorScheme - .onPrimary, + color: theme.brightness == Brightness.light + ? theme.colorScheme.primary + : theme.colorScheme.onPrimary, ), ), ), @@ -196,7 +188,7 @@ class NewPrivateChatView extends StatelessWidget { error.toLocalizedString(context), textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, ), ), const SizedBox(height: 12), @@ -225,7 +217,7 @@ class NewPrivateChatView extends StatelessWidget { controller.controller.text, ), style: TextStyle( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), textAlign: TextAlign.center, ), diff --git a/lib/pages/settings/settings_view.dart b/lib/pages/settings/settings_view.dart index 7adc17de3..286b5d8e9 100644 --- a/lib/pages/settings/settings_view.dart +++ b/lib/pages/settings/settings_view.dart @@ -28,6 +28,7 @@ class SettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); final showChatBackupBanner = controller.showChatBackupBanner; return Scaffold( appBar: AppBar( @@ -39,7 +40,7 @@ class SettingsView extends StatelessWidget { title: Text(L10n.of(context)!.settings), ), body: ListTileTheme( - iconColor: Theme.of(context).colorScheme.onSurface, + iconColor: theme.colorScheme.onSurface, child: ListView( key: const Key('SettingsListViewContent'), children: [ @@ -88,8 +89,7 @@ class SettingsView extends StatelessWidget { size: 16, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( displayname, @@ -107,8 +107,7 @@ class SettingsView extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.secondary, + foregroundColor: theme.colorScheme.secondary, ), label: Text( mxid, @@ -125,7 +124,7 @@ class SettingsView extends StatelessWidget { }, ), // #Pangea - // Divider(color: Theme.of(context).dividerColor), + // Divider(color: theme.dividerColor), // if (showChatBackupBanner == null) // ListTile( // leading: const Icon(Icons.backup_outlined), @@ -141,7 +140,7 @@ class SettingsView extends StatelessWidget { // onChanged: controller.firstRunBootstrapAction, // ), // Divider( - // color: Theme.of(context).dividerColor, + // color: theme.dividerColor, // ), // Pangea# ListTile( @@ -181,7 +180,7 @@ class SettingsView extends StatelessWidget { title: Text(L10n.of(context)!.security), onTap: () => context.go('/rooms/settings/security'), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( leading: const Icon(Icons.help_outline_outlined), title: Text(L10n.of(context)!.help), @@ -249,7 +248,7 @@ class SettingsView extends StatelessWidget { title: Text(L10n.of(context)!.connectedToStaging), ), // Pangea# - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( leading: const Icon(Icons.logout_outlined), title: Text(L10n.of(context)!.logout), diff --git a/lib/pages/settings_3pid/settings_3pid_view.dart b/lib/pages/settings_3pid/settings_3pid_view.dart index fcae861e8..72ee3f492 100644 --- a/lib/pages/settings_3pid/settings_3pid_view.dart +++ b/lib/pages/settings_3pid/settings_3pid_view.dart @@ -12,6 +12,8 @@ class Settings3PidView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + controller.request ??= Matrix.of(context).client.getAccount3PIDs(); return Scaffold( appBar: AppBar( @@ -51,7 +53,7 @@ class Settings3PidView extends StatelessWidget { children: [ ListTile( leading: CircleAvatar( - backgroundColor: Theme.of(context).scaffoldBackgroundColor, + backgroundColor: theme.scaffoldBackgroundColor, foregroundColor: identifier.isEmpty ? Colors.orange : Colors.grey, child: Icon( @@ -73,8 +75,7 @@ class Settings3PidView extends StatelessWidget { itemCount: identifier.length, itemBuilder: (BuildContext context, int i) => ListTile( leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, + backgroundColor: theme.scaffoldBackgroundColor, foregroundColor: Colors.grey, child: Icon(identifier[i].iconData), ), diff --git a/lib/pages/settings_chat/settings_chat_view.dart b/lib/pages/settings_chat/settings_chat_view.dart index 20e179cb6..c549237d8 100644 --- a/lib/pages/settings_chat/settings_chat_view.dart +++ b/lib/pages/settings_chat/settings_chat_view.dart @@ -13,10 +13,12 @@ class SettingsChatView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Scaffold( appBar: AppBar(title: Text(L10n.of(context)!.chat)), body: ListTileTheme( - iconColor: Theme.of(context).textTheme.bodyLarge!.color, + iconColor: theme.textTheme.bodyLarge!.color, child: MaxWidthBody( child: Column( children: [ @@ -71,12 +73,12 @@ class SettingsChatView extends StatelessWidget { defaultValue: AppConfig.swipeRightToLeftToReply, ), // #Pangea - // Divider(color: Theme.of(context).dividerColor), + // Divider(color: theme.dividerColor), // ListTile( // title: Text( // L10n.of(context)!.customEmojisAndStickers, // style: TextStyle( - // color: Theme.of(context).colorScheme.secondary, + // color: theme.colorScheme.secondary, // fontWeight: FontWeight.bold, // ), // ), @@ -90,12 +92,12 @@ class SettingsChatView extends StatelessWidget { // child: Icon(Icons.chevron_right_outlined), // ), // ), - // Divider(color: Theme.of(context).dividerColor), + // Divider(color: theme.dividerColor), // ListTile( // title: Text( // L10n.of(context)!.calls, // style: TextStyle( - // color: Theme.of(context).colorScheme.secondary, + // color: theme.colorScheme.secondary, // fontWeight: FontWeight.bold, // ), // ), diff --git a/lib/pages/settings_emotes/import_archive_dialog.dart b/lib/pages/settings_emotes/import_archive_dialog.dart index 0ed5bb21f..5c6361577 100644 --- a/lib/pages/settings_emotes/import_archive_dialog.dart +++ b/lib/pages/settings_emotes/import_archive_dialog.dart @@ -231,6 +231,8 @@ class _EmojiImportPreviewState extends State<_EmojiImportPreview> { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + // TODO: support Lottie here as well ... final controller = TextEditingController(text: widget.entry.value); @@ -281,11 +283,11 @@ class _EmojiImportPreviewState extends State<_EmojiImportPreview> { suffixText: ':', border: const OutlineInputBorder(), prefixStyle: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), suffixStyle: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -314,6 +316,8 @@ class _ImageFileError extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return SizedBox.square( dimension: 64, child: Tooltip( @@ -327,7 +331,7 @@ class _ImageFileError extends StatelessWidget { Text( L10n.of(context)!.notAnImage, textAlign: TextAlign.center, - style: Theme.of(context).textTheme.labelSmall, + style: theme.textTheme.labelSmall, ), ], ), diff --git a/lib/pages/settings_emotes/settings_emotes_view.dart b/lib/pages/settings_emotes/settings_emotes_view.dart index be1e36f92..1337873a2 100644 --- a/lib/pages/settings_emotes/settings_emotes_view.dart +++ b/lib/pages/settings_emotes/settings_emotes_view.dart @@ -19,6 +19,8 @@ class EmotesSettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final client = Matrix.of(context).client; final imageKeys = controller.pack!.images.keys.toList(); return Scaffold( @@ -73,7 +75,7 @@ class EmotesSettingsView extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(10)), - color: Theme.of(context).secondaryHeaderColor, + color: theme.secondaryHeaderColor, ), child: TextField( controller: controller.newImageCodeController, @@ -85,11 +87,11 @@ class EmotesSettingsView extends StatelessWidget { prefixText: ': ', suffixText: ':', prefixStyle: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), suffixStyle: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), border: InputBorder.none, @@ -152,7 +154,7 @@ class EmotesSettingsView extends StatelessWidget { decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(10)), - color: Theme.of(context).secondaryHeaderColor, + color: theme.secondaryHeaderColor, ), child: Shortcuts( shortcuts: !useShortCuts @@ -188,13 +190,11 @@ class EmotesSettingsView extends StatelessWidget { prefixText: ': ', suffixText: ':', prefixStyle: TextStyle( - color: - Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), suffixStyle: TextStyle( - color: - Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), border: InputBorder.none, diff --git a/lib/pages/settings_ignore_list/settings_ignore_list_view.dart b/lib/pages/settings_ignore_list/settings_ignore_list_view.dart index 785249c69..ad97f4cf7 100644 --- a/lib/pages/settings_ignore_list/settings_ignore_list_view.dart +++ b/lib/pages/settings_ignore_list/settings_ignore_list_view.dart @@ -15,6 +15,8 @@ class SettingsIgnoreListView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final client = Matrix.of(context).client; return Scaffold( appBar: AppBar( @@ -57,7 +59,7 @@ class SettingsIgnoreListView extends StatelessWidget { ), ), Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), Expanded( child: StreamBuilder( diff --git a/lib/pages/settings_notifications/settings_notifications_view.dart b/lib/pages/settings_notifications/settings_notifications_view.dart index 6c1d45cc5..0128b7593 100644 --- a/lib/pages/settings_notifications/settings_notifications_view.dart +++ b/lib/pages/settings_notifications/settings_notifications_view.dart @@ -30,6 +30,7 @@ class SettingsNotificationsView extends StatelessWidget { false, ), builder: (BuildContext context, _) { + final theme = Theme.of(context); return Column( children: [ SwitchListTile.adaptive( @@ -41,12 +42,12 @@ class SettingsNotificationsView extends StatelessWidget { ? null : (_) => controller.onToggleMuteAllNotifications(), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.notifyMeFor, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -64,12 +65,12 @@ class SettingsNotificationsView extends StatelessWidget { : (bool enabled) => controller .setNotificationSetting(item, enabled), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.devices, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/settings_password/settings_password_view.dart b/lib/pages/settings_password/settings_password_view.dart index 813bebd18..ee80e9361 100644 --- a/lib/pages/settings_password/settings_password_view.dart +++ b/lib/pages/settings_password/settings_password_view.dart @@ -12,6 +12,8 @@ class SettingsPasswordView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Scaffold( appBar: AppBar( title: Text(L10n.of(context)!.changePassword), @@ -23,7 +25,7 @@ class SettingsPasswordView extends StatelessWidget { ], ), body: ListTileTheme( - iconColor: Theme.of(context).colorScheme.onSurface, + iconColor: theme.colorScheme.onSurface, child: MaxWidthBody( child: Padding( padding: const EdgeInsets.all(16.0), @@ -32,7 +34,7 @@ class SettingsPasswordView extends StatelessWidget { Center( child: Icon( Icons.key_outlined, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, size: 80, ), ), diff --git a/lib/pages/settings_security/settings_security_view.dart b/lib/pages/settings_security/settings_security_view.dart index 5cb988070..71393a140 100644 --- a/lib/pages/settings_security/settings_security_view.dart +++ b/lib/pages/settings_security/settings_security_view.dart @@ -17,10 +17,12 @@ class SettingsSecurityView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Scaffold( appBar: AppBar(title: Text(L10n.of(context)!.security)), body: ListTileTheme( - iconColor: Theme.of(context).colorScheme.onSurface, + iconColor: theme.colorScheme.onSurface, child: MaxWidthBody( child: FutureBuilder( future: Matrix.of(context) @@ -44,7 +46,7 @@ class SettingsSecurityView extends StatelessWidget { title: Text( L10n.of(context)!.privacy, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -85,13 +87,13 @@ class SettingsSecurityView extends StatelessWidget { ), }, Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ListTile( title: Text( L10n.of(context)!.account, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/settings_style/settings_style_view.dart b/lib/pages/settings_style/settings_style_view.dart index 1a07dd2bc..fd0a4c4f9 100644 --- a/lib/pages/settings_style/settings_style_view.dart +++ b/lib/pages/settings_style/settings_style_view.dart @@ -20,6 +20,8 @@ class SettingsStyleView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + const colorPickerSize = 32.0; final client = Matrix.of(context).client; return Scaffold( @@ -27,7 +29,7 @@ class SettingsStyleView extends StatelessWidget { leading: const Center(child: BackButton()), title: Text(L10n.of(context)!.changeTheme), ), - backgroundColor: Theme.of(context).colorScheme.surface, + backgroundColor: theme.colorScheme.surface, body: MaxWidthBody( child: Column( children: [ @@ -35,7 +37,7 @@ class SettingsStyleView extends StatelessWidget { title: Text( L10n.of(context)!.setColorTheme, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -88,18 +90,16 @@ class SettingsStyleView extends StatelessWidget { child: Icon( Icons.check, size: 16, - color: Theme.of(context) - .colorScheme - .onSurface, + color: theme + .colorScheme.onSurface, ), ), Text( L10n.of(context)!.systemTheme, textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context) - .colorScheme - .onSurface, + color: theme + .colorScheme.onSurface, ), ), ], @@ -136,13 +136,13 @@ class SettingsStyleView extends StatelessWidget { ), const SizedBox(height: 8), Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ListTile( title: Text( L10n.of(context)!.setTheme, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -166,13 +166,13 @@ class SettingsStyleView extends StatelessWidget { onChanged: controller.switchTheme, ), Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ListTile( title: Text( L10n.of(context)!.overview, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -190,13 +190,13 @@ class SettingsStyleView extends StatelessWidget { defaultValue: AppConfig.separateChatTypes, ), Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ListTile( title: Text( L10n.of(context)!.messagesStyle, style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -246,7 +246,7 @@ class SettingsStyleView extends StatelessWidget { bottom: 12, ), child: Material( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, borderRadius: BorderRadius.circular( AppConfig.borderRadius, ), @@ -258,8 +258,7 @@ class SettingsStyleView extends StatelessWidget { child: Text( 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor', style: TextStyle( - color: - Theme.of(context).colorScheme.onPrimary, + color: theme.colorScheme.onPrimary, fontSize: AppConfig.messageFontSize * AppConfig.fontSizeFactor, ), @@ -277,7 +276,7 @@ class SettingsStyleView extends StatelessWidget { ? null : IconButton( icon: const Icon(Icons.delete_outlined), - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, onPressed: controller.deleteChatWallpaper, ), onTap: controller.setWallpaper, diff --git a/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart b/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart index 25552e51b..237efd1c8 100644 --- a/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart +++ b/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart @@ -62,6 +62,7 @@ class UserBottomSheetView extends StatelessWidget { false, ), builder: (context, snapshot) { + final theme = Theme.of(context); return ListView( children: [ if (user?.membership == Membership.knock) @@ -70,7 +71,7 @@ class UserBottomSheetView extends StatelessWidget { child: Material( color: // ignore: deprecated_member_use - Theme.of(context).colorScheme.surfaceVariant, + theme.colorScheme.surfaceVariant, borderRadius: BorderRadius.circular(AppConfig.borderRadius), child: ListTile( @@ -86,10 +87,8 @@ class UserBottomSheetView extends StatelessWidget { children: [ TextButton.icon( style: TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.surface, - foregroundColor: - Theme.of(context).colorScheme.primary, + backgroundColor: theme.colorScheme.surface, + foregroundColor: theme.colorScheme.primary, ), onPressed: controller.knockAccept, icon: const Icon(Icons.check_outlined), @@ -98,12 +97,10 @@ class UserBottomSheetView extends StatelessWidget { const SizedBox(width: 12), TextButton.icon( style: TextButton.styleFrom( - backgroundColor: Theme.of(context) - .colorScheme - .errorContainer, - foregroundColor: Theme.of(context) - .colorScheme - .onErrorContainer, + backgroundColor: + theme.colorScheme.errorContainer, + foregroundColor: + theme.colorScheme.onErrorContainer, ), onPressed: controller.knockDecline, icon: const Icon(Icons.cancel_outlined), @@ -142,8 +139,7 @@ class UserBottomSheetView extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( userId, @@ -187,8 +183,7 @@ class UserBottomSheetView extends StatelessWidget { Text( L10n.of(context)!.currentlyActive, overflow: TextOverflow.ellipsis, - style: - Theme.of(context).textTheme.bodySmall, + style: theme.textTheme.bodySmall, ) else if (lastActiveTimestamp != null) Text( @@ -197,8 +192,7 @@ class UserBottomSheetView extends StatelessWidget { .localizedTimeShort(context), ), overflow: TextOverflow.ellipsis, - style: - Theme.of(context).textTheme.bodySmall, + style: theme.textTheme.bodySmall, ), ], ); @@ -283,7 +277,7 @@ class UserBottomSheetView extends StatelessWidget { .participantAction(UserBottomSheetAction.mention), ), if (user != null) ...[ - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( '${L10n.of(context)!.userRole} (${user.powerLevel})', @@ -292,7 +286,7 @@ class UserBottomSheetView extends StatelessWidget { trailing: Material( borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, child: DropdownButton( onChanged: user.canChangeUserPowerLevel || // Workaround until https://github.com/famedly/matrix-dart-sdk/pull/1765 @@ -329,11 +323,11 @@ class UserBottomSheetView extends StatelessWidget { ), ), ], - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), if (user != null && user.canKick) ListTile( - textColor: Theme.of(context).colorScheme.error, - iconColor: Theme.of(context).colorScheme.error, + textColor: theme.colorScheme.error, + iconColor: theme.colorScheme.error, title: Text(L10n.of(context)!.kickFromChat), leading: const Icon(Icons.exit_to_app_outlined), onTap: () => controller @@ -343,8 +337,8 @@ class UserBottomSheetView extends StatelessWidget { user.canBan && user.membership != Membership.ban) ListTile( - textColor: Theme.of(context).colorScheme.onErrorContainer, - iconColor: Theme.of(context).colorScheme.onErrorContainer, + textColor: theme.colorScheme.onErrorContainer, + iconColor: theme.colorScheme.onErrorContainer, title: Text(L10n.of(context)!.banFromChat), leading: const Icon(Icons.warning_sharp), onTap: () => @@ -362,8 +356,8 @@ class UserBottomSheetView extends StatelessWidget { // #Pangea // if (user != null && user.id != client.userID) // ListTile( - // textColor: Theme.of(context).colorScheme.onErrorContainer, - // iconColor: Theme.of(context).colorScheme.onErrorContainer, + // textColor: theme.colorScheme.onErrorContainer, + // iconColor: theme.colorScheme.onErrorContainer, // title: Text(L10n.of(context)!.reportUser), // leading: const Icon(Icons.gavel_outlined), // onTap: () => controller @@ -389,8 +383,8 @@ class UserBottomSheetView extends StatelessWidget { // Pangea# ) ListTile( - textColor: Theme.of(context).colorScheme.onErrorContainer, - iconColor: Theme.of(context).colorScheme.onErrorContainer, + textColor: theme.colorScheme.onErrorContainer, + iconColor: theme.colorScheme.onErrorContainer, leading: const Icon(Icons.block_outlined), title: Text(L10n.of(context)!.block), onTap: () => controller diff --git a/lib/utils/show_update_snackbar.dart b/lib/utils/show_update_snackbar.dart index 3f8b80ff4..eece3b4fb 100644 --- a/lib/utils/show_update_snackbar.dart +++ b/lib/utils/show_update_snackbar.dart @@ -7,6 +7,7 @@ abstract class UpdateNotifier { static const String versionStoreKey = 'last_known_version'; static void showUpdateSnackBar(BuildContext context) async { + final theme = Theme.of(context); final scaffoldMessenger = ScaffoldMessenger.of(context); final currentVersion = await PlatformInfos.getVersion(); final store = await SharedPreferences.getInstance(); @@ -24,7 +25,7 @@ abstract class UpdateNotifier { icon: Icon( Icons.close_outlined, size: 20, - color: Theme.of(context).colorScheme.onPrimary, + color: theme.colorScheme.onPrimary, ), onPressed: () => controller?.close(), ), diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 3f2bd5fac..560fb5e9c 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -33,6 +33,8 @@ class Avatar extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + var fallbackLetters = '@'; final name = this.name; if (name != null) { @@ -66,7 +68,7 @@ class Avatar extends StatelessWidget { width: size, height: size, child: Material( - color: Theme.of(context).brightness == Brightness.light + color: theme.brightness == Brightness.light ? Colors.white : Colors.black, shape: RoundedRectangleBorder( @@ -87,7 +89,7 @@ class Avatar extends StatelessWidget { placeholder: (_) => Center( child: Icon( Icons.person_2, - color: Theme.of(context).colorScheme.tertiary, + color: theme.colorScheme.tertiary, size: size / 1.5, ), ), @@ -116,8 +118,7 @@ class Avatar extends StatelessWidget { width: 16, height: 16, decoration: BoxDecoration( - color: presenceBackgroundColor ?? - Theme.of(context).colorScheme.surface, + color: presenceBackgroundColor ?? theme.colorScheme.surface, borderRadius: BorderRadius.circular(32), ), alignment: Alignment.center, @@ -129,7 +130,7 @@ class Avatar extends StatelessWidget { borderRadius: BorderRadius.circular(16), border: Border.all( width: 1, - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, ), ), ), diff --git a/lib/widgets/connection_status_header.dart b/lib/widgets/connection_status_header.dart index 285ebb8bf..eef2b795d 100644 --- a/lib/widgets/connection_status_header.dart +++ b/lib/widgets/connection_status_header.dart @@ -35,6 +35,8 @@ class ConnectionStatusHeaderState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final client = Matrix.of(context).client; final status = client.onSyncStatus.value ?? const SyncStatusUpdate(SyncStatus.waitingForResponse); @@ -65,7 +67,7 @@ class ConnectionStatusHeaderState extends State { status.toLocalizedString(context), maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(color: Theme.of(context).colorScheme.onSurface), + style: TextStyle(color: theme.colorScheme.onSurface), ), ], ), diff --git a/lib/widgets/layouts/login_scaffold.dart b/lib/widgets/layouts/login_scaffold.dart index e5662417c..da09d2950 100644 --- a/lib/widgets/layouts/login_scaffold.dart +++ b/lib/widgets/layouts/login_scaffold.dart @@ -19,8 +19,12 @@ class LoginScaffold extends StatelessWidget { @override Widget build(BuildContext context) { - final isMobileMode = - enforceMobileMode || !FluffyThemes.isColumnMode(context); + // #Pangea + // final theme = Theme.of(context); + + // final isMobileMode = + // enforceMobileMode || !FluffyThemes.isColumnMode(context); + // Pangea# final scaffold = Scaffold( key: const Key('LoginScaffold'), // Pangea# @@ -56,13 +60,12 @@ class LoginScaffold extends StatelessWidget { child: body, ), ), - // backgroundColor: isMobileMode - // ? null - // : Theme.of(context).colorScheme.surface.withOpacity(0.8), + // backgroundColor: + // isMobileMode ? null : theme.colorScheme.surface.withOpacity(0.8), // bottomNavigationBar: isMobileMode // ? Material( // elevation: 4, - // shadowColor: Theme.of(context).colorScheme.onSurface, + // shadowColor: theme.colorScheme.onSurface, // child: const _PrivacyButtons( // mainAxisAlignment: MainAxisAlignment.center, // ), @@ -91,9 +94,8 @@ class LoginScaffold extends StatelessWidget { // color: Colors.transparent, // borderRadius: BorderRadius.circular(AppConfig.borderRadius), // clipBehavior: Clip.hardEdge, - // elevation: - // Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4, - // shadowColor: Theme.of(context).appBarTheme.shadowColor, + // elevation: theme.appBarTheme.scrolledUnderElevation ?? 4, + // shadowColor: theme.appBarTheme.shadowColor, // child: ConstrainedBox( // constraints: isMobileMode // ? const BoxConstraints() diff --git a/lib/widgets/layouts/max_width_body.dart b/lib/widgets/layouts/max_width_body.dart index 97c340231..4e44cc796 100644 --- a/lib/widgets/layouts/max_width_body.dart +++ b/lib/widgets/layouts/max_width_body.dart @@ -21,6 +21,8 @@ class MaxWidthBody extends StatelessWidget { return SafeArea( child: LayoutBuilder( builder: (context, constraints) { + final theme = Theme.of(context); + const desiredWidth = FluffyThemes.columnWidth * 1.5; final body = constraints.maxWidth <= desiredWidth ? child @@ -32,14 +34,11 @@ class MaxWidthBody extends StatelessWidget { maxWidth: FluffyThemes.columnWidth * 1.5, ), child: Material( - elevation: Theme.of(context) - .appBarTheme - .scrolledUnderElevation ?? - 4, + elevation: theme.appBarTheme.scrolledUnderElevation ?? 4, clipBehavior: Clip.hardEdge, borderRadius: BorderRadius.circular(AppConfig.borderRadius), - shadowColor: Theme.of(context).appBarTheme.shadowColor, + shadowColor: theme.appBarTheme.shadowColor, child: child, ), ), diff --git a/lib/widgets/layouts/two_column_layout.dart b/lib/widgets/layouts/two_column_layout.dart index cf1083a3f..36e815ebb 100644 --- a/lib/widgets/layouts/two_column_layout.dart +++ b/lib/widgets/layouts/two_column_layout.dart @@ -15,6 +15,8 @@ class TwoColumnLayout extends StatelessWidget { }); @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return ScaffoldMessenger( child: Scaffold( body: Row( @@ -28,7 +30,7 @@ class TwoColumnLayout extends StatelessWidget { ), Container( width: 1.0, - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), Expanded( child: ClipRRect( diff --git a/lib/widgets/public_room_bottom_sheet.dart b/lib/widgets/public_room_bottom_sheet.dart index e07728315..c8e84d53e 100644 --- a/lib/widgets/public_room_bottom_sheet.dart +++ b/lib/widgets/public_room_bottom_sheet.dart @@ -118,6 +118,8 @@ class PublicRoomBottomSheet extends StatelessWidget { body: FutureBuilder( future: _search(), builder: (context, snapshot) { + final theme = Theme.of(context); + final profile = snapshot.data; return ListView( padding: EdgeInsets.zero, @@ -155,8 +157,7 @@ class PublicRoomBottomSheet extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( roomLink ?? '...', @@ -171,8 +172,7 @@ class PublicRoomBottomSheet extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( L10n.of(context)!.countParticipants( @@ -216,7 +216,7 @@ class PublicRoomBottomSheet extends StatelessWidget { ), style: TextStyle( fontSize: 14, - color: Theme.of(context).textTheme.bodyMedium!.color, + color: theme.textTheme.bodyMedium!.color, ), options: const LinkifyOptions(humanize: false), onOpen: (url) => diff --git a/lib/widgets/unread_rooms_badge.dart b/lib/widgets/unread_rooms_badge.dart index 4704e6c26..1e001de60 100644 --- a/lib/widgets/unread_rooms_badge.dart +++ b/lib/widgets/unread_rooms_badge.dart @@ -1,5 +1,4 @@ import 'package:badges/badges.dart' as b; -import 'package:fluffychat/utils/stream_extension.dart'; import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; @@ -19,54 +18,44 @@ class UnreadRoomsBadge extends StatelessWidget { @override Widget build(BuildContext context) { - return StreamBuilder( - stream: Matrix.of(context) - .client - .onSync - .stream - .where((syncUpdate) => syncUpdate.hasRoomUpdate) - // #Pangea - .rateLimit(const Duration(seconds: 1)), - // Pangea# - builder: (context, _) { - // #Pangea - final unreadCounts = Matrix.of(context) - .client - .rooms - .where(filter) - .where((r) => (r.isUnread || r.membership == Membership.invite)) - .map((r) => r.notificationCount); - final unreadCount = - unreadCounts.isEmpty ? 0 : unreadCounts.reduce((a, b) => a + b); - // final unreadCount = Matrix.of(context) - // .client - // .rooms - // .where(filter) - // .where((r) => (r.isUnread || r.membership == Membership.invite)) - // .length; - // Pangea# - return b.Badge( - badgeStyle: b.BadgeStyle( - badgeColor: Theme.of(context).colorScheme.primary, - elevation: 4, - borderSide: BorderSide( - color: Theme.of(context).colorScheme.surface, - width: 2, - ), - ), - badgeContent: Text( - unreadCount.toString(), - style: TextStyle( - color: Theme.of(context).colorScheme.onPrimary, - fontSize: 12, - ), - ), - showBadge: unreadCount != 0, - badgeAnimation: const b.BadgeAnimation.scale(), - position: badgePosition ?? b.BadgePosition.bottomEnd(), - child: child, - ); - }, + final theme = Theme.of(context); + + // #Pangea + // final unreadCount = Matrix.of(context) + // .client + // .rooms + // .where(filter) + // .where((r) => (r.isUnread || r.membership == Membership.invite)) + // .length; + final unreadCounts = Matrix.of(context) + .client + .rooms + .where(filter) + .where((r) => (r.isUnread || r.membership == Membership.invite)) + .map((r) => r.notificationCount); + final unreadCount = + unreadCounts.isEmpty ? 0 : unreadCounts.reduce((a, b) => a + b); + // Pangea# + return b.Badge( + badgeStyle: b.BadgeStyle( + badgeColor: theme.colorScheme.primary, + elevation: 4, + borderSide: BorderSide( + color: theme.colorScheme.surface, + width: 2, + ), + ), + badgeContent: Text( + unreadCount.toString(), + style: TextStyle( + color: theme.colorScheme.onPrimary, + fontSize: 12, + ), + ), + showBadge: unreadCount != 0, + badgeAnimation: const b.BadgeAnimation.scale(), + position: badgePosition ?? b.BadgePosition.bottomEnd(), + child: child, ); } }