Refactor: Reduce .of(context) calls theme
Signed commit
This commit is contained in:
parent
a928ecec1e
commit
5d2aaef3ca
69 changed files with 525 additions and 501 deletions
|
|
@ -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<int>(
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue