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
|
|
@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ class ConnectionStatusHeaderState extends State<ConnectionStatusHeader> {
|
|||
|
||||
@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<ConnectionStatusHeader> {
|
|||
status.toLocalizedString(context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||
style: TextStyle(color: theme.colorScheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
body: FutureBuilder<PublicRoomsChunk>(
|
||||
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) =>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue