Refactor: Reduce .of(context) calls theme

Signed commit
This commit is contained in:
Thomas Klein Langenhorst 2024-08-04 14:09:36 +02:00
commit 5d2aaef3ca
No known key found for this signature in database
GPG key ID: CA868C3CB279DA5B
69 changed files with 525 additions and 501 deletions

View file

@ -18,6 +18,8 @@ class ChatEncryptionSettingsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final room = controller.room;
return StreamBuilder<Object>(
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,
),
),
),