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

@ -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()

View file

@ -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,
),
),

View file

@ -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(