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 f287d29cf..990557ee5 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1313,49 +1313,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, - ), + 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, - ), + ), + 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 0225e7350..1ef7e2363 100644 --- a/lib/pages/chat/chat_emoji_picker.dart +++ b/lib/pages/chat/chat_emoji_picker.dart @@ -43,9 +43,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 b548c606b..3ad750376 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -21,6 +21,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(); @@ -37,7 +38,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( @@ -278,9 +279,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), ) : FloatingActionButton.small( @@ -291,10 +291,8 @@ 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), ), ), diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 422175f0f..b354e2c19 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -128,6 +128,7 @@ class ChatView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); if (controller.room.membership == Membership.invite) { showFutureLoadingDialog( context: context, @@ -173,14 +174,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) @@ -218,8 +219,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: () { @@ -308,7 +308,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, @@ -325,9 +325,8 @@ class ChatView extends StatelessWidget { padding: const EdgeInsets.all( 16, ), - foregroundColor: Theme.of(context) - .colorScheme - .error, + foregroundColor: + theme.colorScheme.error, ), icon: const Icon( Icons.archive_outlined, @@ -370,9 +369,7 @@ class ChatView extends StatelessWidget { ), if (controller.dragging) Container( - color: Theme.of(context) - .scaffoldBackgroundColor - .withOpacity(0.9), + color: theme.scaffoldBackgroundColor.withOpacity(0.9), alignment: Alignment.center, child: const Icon( Icons.upload_outlined, 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 430bac2d7..d4667bb9d 100644 --- a/lib/pages/chat/events/audio_player.dart +++ b/lib/pages/chat/events/audio_player.dart @@ -218,6 +218,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( @@ -304,8 +306,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 e9eab056b..4a2befae2 100644 --- a/lib/pages/chat/events/map_bubble.dart +++ b/lib/pages/chat/events/map_bubble.dart @@ -22,6 +22,8 @@ class MapBubble extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return ClipRRect( borderRadius: BorderRadius.circular(radius), child: Container( @@ -72,11 +74,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 5f1e7dc35..08bf9e306 100644 --- a/lib/pages/chat/events/message.dart +++ b/lib/pages/chat/events/message.dart @@ -57,6 +57,8 @@ class Message extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + if (!{ EventTypes.Message, EventTypes.Sticker, @@ -78,7 +80,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); @@ -100,9 +102,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; @@ -131,7 +132,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; @@ -168,14 +169,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, ), @@ -253,8 +250,7 @@ class Message extends StatelessWidget { displayname, style: TextStyle( fontSize: 12, - color: (Theme.of(context) - .brightness == + color: (theme.brightness == Brightness.light ? displayname.color : displayname @@ -442,10 +438,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, ), ], @@ -473,14 +469,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), @@ -489,12 +485,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 945ae22ac..02e986f81 100644 --- a/lib/pages/chat/events/reply_content.dart +++ b/lib/pages/chat/events/reply_content.dart @@ -27,20 +27,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, @@ -81,8 +80,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 5ccd560f9..a23ab7bb0 100644 --- a/lib/pages/chat/events/video_player.dart +++ b/lib/pages/chat/events/video_player.dart @@ -96,6 +96,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') ?? @@ -123,7 +125,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 d4917c1dc..1e1f3f40e 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -221,6 +221,7 @@ class InputBar extends StatelessWidget { Map suggestion, Client? client, ) { + final theme = Theme.of(context); const size = 30.0; const padding = EdgeInsets.all(4.0); if (suggestion['type'] == 'command') { @@ -242,7 +243,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 7256e00bc..4488e05df 100644 --- a/lib/pages/chat/reactions_picker.dart +++ b/lib/pages/chat/reactions_picker.dart @@ -15,6 +15,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 && @@ -60,7 +62,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), ), @@ -92,7 +94,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 6d8718854..937b0045d 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -131,6 +131,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')}'; @@ -159,7 +161,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), ), @@ -185,11 +187,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), ), ), ), @@ -209,8 +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), ), ), ), diff --git a/lib/pages/chat/reply_display.dart b/lib/pages/chat/reply_display.dart index 03acd269e..8de51d0f3 100644 --- a/lib/pages/chat/reply_display.dart +++ b/lib/pages/chat/reply_display.dart @@ -14,6 +14,8 @@ class ReplyDisplay extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return AnimatedContainer( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, @@ -22,7 +24,7 @@ class ReplyDisplay extends StatelessWidget { : 0, clipBehavior: Clip.hardEdge, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, ), child: Row( children: [ @@ -55,6 +57,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(); @@ -63,7 +66,7 @@ class _EditContent extends StatelessWidget { children: [ Icon( Icons.edit, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), Container(width: 15.0), Text( @@ -75,7 +78,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 9b1ad8953..76fa7106f 100644 --- a/lib/pages/chat/seen_by_row.dart +++ b/lib/pages/chat/seen_by_row.dart @@ -12,6 +12,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( @@ -49,7 +51,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 c0a6ec76b..1517b8a40 100644 --- a/lib/pages/chat/sticker_picker_dialog.dart +++ b/lib/pages/chat/sticker_picker_dialog.dart @@ -27,6 +27,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(); @@ -100,7 +102,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 3c17112a5..c55e3fe0f 100644 --- a/lib/pages/chat_details/chat_details_view.dart +++ b/lib/pages/chat_details/chat_details_view.dart @@ -23,6 +23,8 @@ 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) { return Scaffold( @@ -45,7 +47,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)!), ); @@ -53,7 +55,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: [ if (room.canonicalAlias.isNotEmpty) IconButton( @@ -68,7 +70,7 @@ class ChatDetailsView extends StatelessWidget { ChatSettingsPopupMenu(room, false), ], title: Text(L10n.of(context)!.chatDetails), - backgroundColor: Theme.of(context).appBarTheme.backgroundColor, + backgroundColor: theme.appBarTheme.backgroundColor, ), body: MaxWidthBody( child: ListView.builder( @@ -143,9 +145,8 @@ class ChatDetailsView extends StatelessWidget { size: 16, ), style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .onSurface, + foregroundColor: + theme.colorScheme.onSurface, ), label: Text( room.isDirectChat @@ -167,9 +168,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( @@ -185,13 +185,13 @@ class ChatDetailsView extends StatelessWidget { ), ], ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.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, ), ), @@ -204,12 +204,10 @@ class ChatDetailsView extends StatelessWidget { label: 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, ), ), ), @@ -231,21 +229,19 @@ class ChatDetailsView extends StatelessWidget { fontStyle: room.topic.isEmpty ? FontStyle.italic : FontStyle.normal, - color: - Theme.of(context).textTheme.bodyMedium!.color, + color: theme.textTheme.bodyMedium!.color, decorationColor: - Theme.of(context).textTheme.bodyMedium!.color, + 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, @@ -260,8 +256,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), ), @@ -282,8 +277,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, @@ -293,14 +287,14 @@ class ChatDetailsView extends StatelessWidget { onTap: () => context .push('/rooms/${room.id}/details/permissions'), ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.countParticipants( actualMembersCount.toString(), ), style: TextStyle( - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -309,12 +303,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), ), @@ -332,8 +324,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 661153634..ddacbb7c1 100644 --- a/lib/pages/chat_details/participant_list_item.dart +++ b/lib/pages/chat_details/participant_list_item.dart @@ -14,6 +14,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,17 +56,17 @@ class ParticipantListItem extends StatelessWidget { ), margin: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primaryContainer, + color: theme.colorScheme.primaryContainer, borderRadius: BorderRadius.circular(8), border: Border.all( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), ), child: Text( permissionBatch, style: TextStyle( fontSize: 14, - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, ), ), ), @@ -74,7 +76,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 d1be4e7d1..2a17a5a33 100644 --- a/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart +++ b/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart @@ -18,6 +18,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( @@ -43,10 +45,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 +56,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { Icon( CupertinoIcons.lock_shield, size: 128, - color: Theme.of(context).colorScheme.onInverseSurface, + color: theme.colorScheme.onInverseSurface, ), const Divider(), if (room.isDirectChat) @@ -144,13 +144,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( @@ -158,9 +155,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, ), @@ -175,7 +170,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 d78a88e34..2ce644625 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -28,6 +28,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) { @@ -59,10 +61,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, ), ), @@ -249,7 +243,7 @@ class ChatListViewBody extends StatelessWidget { child: Icon( CupertinoIcons.chat_bubble_2, size: 128, - color: Theme.of(context).colorScheme.secondary, + color: theme.colorScheme.secondary, ), ), ], @@ -266,7 +260,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 d60cc9ba2..864a7a7f8 100644 --- a/lib/pages/chat_list/chat_list_header.dart +++ b/lib/pages/chat_list/chat_list_header.dart @@ -19,6 +19,8 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final selectMode = controller.selectMode; return SliverAppBar( @@ -36,7 +38,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( @@ -52,7 +54,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), @@ -60,7 +62,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, @@ -69,14 +71,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 1ba515e29..dacc6bec0 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -63,12 +63,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 @@ -126,7 +127,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, @@ -146,7 +147,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 94341ed9e..0295d2b55 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -241,6 +241,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; @@ -359,8 +361,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), @@ -368,9 +369,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, @@ -378,9 +377,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 610f6b0e8..458e1c503 100644 --- a/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart +++ b/lib/pages/chat_permissions_settings/chat_permissions_settings_view.dart @@ -15,6 +15,8 @@ class ChatPermissionsSettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Scaffold( appBar: AppBar( leading: const Center(child: BackButton()), @@ -47,12 +49,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, ), ), @@ -72,12 +74,12 @@ class ChatPermissionsSettingsView extends StatelessWidget { ), canEdit: room.canChangePowerLevel, ), - 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, ), ), @@ -107,12 +109,12 @@ class ChatPermissionsSettingsView extends StatelessWidget { ); }, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), ListTile( title: Text( L10n.of(context)!.configureChat, style: TextStyle( - color: Theme.of(context).colorScheme.primary, + color: theme.colorScheme.primary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/chat_permissions_settings/permission_list_tile.dart b/lib/pages/chat_permissions_settings/permission_list_tile.dart index 118982d37..0ca516965 100644 --- a/lib/pages/chat_permissions_settings/permission_list_tile.dart +++ b/lib/pages/chat_permissions_settings/permission_list_tile.dart @@ -71,6 +71,8 @@ class PermissionsListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final color = permission >= 100 ? Colors.orangeAccent : permission >= 50 @@ -79,7 +81,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 8a1ad4e2b..3ba506454 100644 --- a/lib/pages/homeserver_picker/homeserver_app_bar.dart +++ b/lib/pages/homeserver_picker/homeserver_app_bar.dart @@ -17,14 +17,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, ), ), @@ -92,9 +93,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 ce86abec0..dd6c50d04 100644 --- a/lib/pages/homeserver_picker/homeserver_picker_view.dart +++ b/lib/pages/homeserver_picker/homeserver_picker_view.dart @@ -19,6 +19,8 @@ class HomeserverPickerView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final identityProviders = controller.identityProviders; final errorText = controller.error; final publicHomeserver = controller.cachedHomeservers?.singleWhereOrNull( @@ -32,7 +34,7 @@ class HomeserverPickerView extends StatelessWidget { appBar: AppBar( titleSpacing: 12, automaticallyImplyLeading: false, - surfaceTintColor: Theme.of(context).colorScheme.surface, + surfaceTintColor: theme.colorScheme.surface, title: HomeserverAppBar(controller: controller), ), body: Column( @@ -50,7 +52,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), @@ -80,7 +82,7 @@ class HomeserverPickerView extends StatelessWidget { errorText, textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, fontSize: 18, ), ), @@ -91,7 +93,7 @@ class HomeserverPickerView extends StatelessWidget { .pleaseTryAgainLaterOrChooseDifferentServer, textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context).colorScheme.error, + color: theme.colorScheme.error, fontSize: 12, ), ), @@ -189,6 +191,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), @@ -201,16 +205,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 92596e894..795334e04 100644 --- a/lib/pages/invitation_selection/invitation_selection_view.dart +++ b/lib/pages/invitation_selection/invitation_selection_view.dart @@ -153,6 +153,8 @@ class _InviteContactListTile extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Opacity( opacity: isMember ? 0.5 : 1, child: ListTile( @@ -171,7 +173,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 8ec092cbf..0358c44a6 100644 --- a/lib/pages/login/login_view.dart +++ b/lib/pages/login/login_view.dart @@ -14,6 +14,8 @@ class LoginView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final homeserver = Matrix.of(context) .getLoginClient() .homeserver @@ -23,9 +25,9 @@ class LoginView extends StatelessWidget { final titleParts = title.split(homeserver); final textFieldFillColor = FluffyThemes.isColumnMode(context) - ? Theme.of(context).colorScheme.surface + ? theme.colorScheme.surface // ignore: deprecated_member_use - : Theme.of(context).colorScheme.surfaceVariant; + : theme.colorScheme.surfaceVariant; return LoginScaffold( enforceMobileMode: Matrix.of(context).client.isLogged(), @@ -111,8 +113,8 @@ class LoginView extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8.0), 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), @@ -129,7 +131,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 df2a4ac49..0f86efb45 100644 --- a/lib/pages/new_group/new_group_view.dart +++ b/lib/pages/new_group/new_group_view.dart @@ -15,6 +15,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( @@ -86,12 +88,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, @@ -126,12 +128,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 81d10bcf8..ceee0ef45 100644 --- a/lib/pages/new_private_chat/new_private_chat_view.dart +++ b/lib/pages/new_private_chat/new_private_chat_view.dart @@ -22,13 +22,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: @@ -109,7 +111,7 @@ class NewPrivateChatView extends StatelessWidget { ], ), style: TextStyle( - color: Theme.of(context).colorScheme.onSurface, + color: theme.colorScheme.onSurface, fontSize: 13, ), ), @@ -117,10 +119,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), @@ -128,10 +128,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), @@ -140,10 +138,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), @@ -158,8 +154,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), @@ -169,12 +164,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, ), ), ), @@ -198,7 +190,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), @@ -227,7 +219,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 b2293f4b2..70133433b 100644 --- a/lib/pages/settings/settings_view.dart +++ b/lib/pages/settings/settings_view.dart @@ -19,6 +19,7 @@ class SettingsView extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); final showChatBackupBanner = controller.showChatBackupBanner; return Scaffold( appBar: AppBar( @@ -30,7 +31,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: [ @@ -79,8 +80,7 @@ class SettingsView extends StatelessWidget { size: 16, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( displayname, @@ -98,8 +98,7 @@ class SettingsView extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.secondary, + foregroundColor: theme.colorScheme.secondary, ), label: Text( mxid, @@ -115,7 +114,7 @@ class SettingsView extends StatelessWidget { ); }, ), - Divider(color: Theme.of(context).dividerColor), + Divider(color: theme.dividerColor), if (showChatBackupBanner == null) ListTile( leading: const Icon(Icons.backup_outlined), @@ -131,7 +130,7 @@ class SettingsView extends StatelessWidget { onChanged: controller.firstRunBootstrapAction, ), Divider( - color: Theme.of(context).dividerColor, + color: theme.dividerColor, ), ListTile( leading: const Icon(Icons.format_paint_outlined), @@ -158,7 +157,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), @@ -174,7 +173,7 @@ class SettingsView extends StatelessWidget { title: Text(L10n.of(context)!.about), onTap: () => PlatformInfos.showDialog(context), ), - 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 4c5377c64..af5e1f757 100644 --- a/lib/pages/settings_3pid/settings_3pid_view.dart +++ b/lib/pages/settings_3pid/settings_3pid_view.dart @@ -14,6 +14,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( @@ -53,7 +55,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( @@ -75,8 +77,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 01cc7af29..e23829d87 100644 --- a/lib/pages/settings_chat/settings_chat_view.dart +++ b/lib/pages/settings_chat/settings_chat_view.dart @@ -18,10 +18,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 { storeKey: SettingKeys.swipeRightToLeftToReply, defaultValue: AppConfig.swipeRightToLeftToReply, ), - 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 dee5e808a..e66387503 100644 --- a/lib/pages/settings_ignore_list/settings_ignore_list_view.dart +++ b/lib/pages/settings_ignore_list/settings_ignore_list_view.dart @@ -16,6 +16,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( @@ -58,7 +60,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 6ff7e1696..76ea243a0 100644 --- a/lib/pages/settings_security/settings_security_view.dart +++ b/lib/pages/settings_security/settings_security_view.dart @@ -18,10 +18,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) @@ -45,7 +47,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, ), ), @@ -86,13 +88,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 0b78c27f9..16426f871 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: () => @@ -361,8 +355,8 @@ class UserBottomSheetView extends StatelessWidget { ), 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 @@ -382,8 +376,8 @@ class UserBottomSheetView extends StatelessWidget { if (userId != client.userID && !client.ignoredUsers.contains(userId)) 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 96d08378e..38334a508 100644 --- a/lib/utils/show_update_snackbar.dart +++ b/lib/utils/show_update_snackbar.dart @@ -11,6 +11,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(); @@ -28,7 +29,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 c8096ed85..c6bcaf9f1 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -35,6 +35,8 @@ class Avatar extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + var fallbackLetters = '@'; final name = this.name; if (name != null) { @@ -68,7 +70,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( @@ -89,7 +91,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, ), ), @@ -118,8 +120,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, @@ -131,7 +132,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 b253ec4fa..7337e8ebd 100644 --- a/lib/widgets/layouts/login_scaffold.dart +++ b/lib/widgets/layouts/login_scaffold.dart @@ -23,6 +23,8 @@ class LoginScaffold extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final isMobileMode = enforceMobileMode || !FluffyThemes.isColumnMode(context); final scaffold = Scaffold( @@ -40,13 +42,12 @@ class LoginScaffold extends StatelessWidget { backgroundColor: isMobileMode ? null : Colors.transparent, ), body: 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, ), @@ -72,9 +73,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 3105cc576..991739ac6 100644 --- a/lib/widgets/public_room_bottom_sheet.dart +++ b/lib/widgets/public_room_bottom_sheet.dart @@ -113,6 +113,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, @@ -150,8 +152,7 @@ class PublicRoomBottomSheet extends StatelessWidget { size: 14, ), style: TextButton.styleFrom( - foregroundColor: - Theme.of(context).colorScheme.onSurface, + foregroundColor: theme.colorScheme.onSurface, ), label: Text( roomLink ?? '...', @@ -166,8 +167,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( @@ -211,7 +211,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 5270c0db3..495173496 100644 --- a/lib/widgets/unread_rooms_badge.dart +++ b/lib/widgets/unread_rooms_badge.dart @@ -19,6 +19,8 @@ class UnreadRoomsBadge extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + final unreadCount = Matrix.of(context) .client .rooms @@ -27,17 +29,17 @@ class UnreadRoomsBadge extends StatelessWidget { .length; return b.Badge( badgeStyle: b.BadgeStyle( - badgeColor: Theme.of(context).colorScheme.primary, + badgeColor: theme.colorScheme.primary, elevation: 4, borderSide: BorderSide( - color: Theme.of(context).colorScheme.surface, + color: theme.colorScheme.surface, width: 2, ), ), badgeContent: Text( unreadCount.toString(), style: TextStyle( - color: Theme.of(context).colorScheme.onPrimary, + color: theme.colorScheme.onPrimary, fontSize: 12, ), ),