Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce repetitive Theme.of() calls #438

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/src/layouts/yaru_master_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class YaruMasterTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scope = YaruMasterTileScope.maybeOf(context);
final isSelected = selected ?? scope?.selected ?? false;
final scrollbarThicknessWithTrack =
Expand All @@ -52,13 +53,12 @@ class YaruMasterTile extends StatelessWidget {
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(kYaruButtonRadius)),
color: isSelected
? Theme.of(context).colorScheme.onSurface.withOpacity(0.07)
: null,
color:
isSelected ? theme.colorScheme.onSurface.withOpacity(0.07) : null,
),
child: ListTile(
selectedColor: Theme.of(context).colorScheme.onSurface,
iconColor: Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
selectedColor: theme.colorScheme.onSurface,
iconColor: theme.colorScheme.onSurface.withOpacity(0.8),
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(kYaruButtonRadius)),
Expand Down
11 changes: 6 additions & 5 deletions lib/src/utilities/yaru_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,27 @@ class YaruBanner extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final borderRadius = BorderRadius.circular(10);

final light = Theme.of(context).brightness == Brightness.light;
final light = theme.brightness == Brightness.light;
final defaultCardColor = light
? Theme.of(context).colorScheme.background
: Theme.of(context).colorScheme.onSurface.withOpacity(0.01);
? theme.colorScheme.background
: theme.colorScheme.onSurface.withOpacity(0.01);
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: borderRadius,
hoverColor: Theme.of(context).colorScheme.onSurface.withOpacity(0.1),
hoverColor: theme.colorScheme.onSurface.withOpacity(0.1),
child: Card(
shadowColor: Colors.transparent,
surfaceTintColor: surfaceTintColor ?? defaultCardColor,
elevation: light ? 4 : 6,
shape: RoundedRectangleBorder(
borderRadius: borderRadius
.inner(const EdgeInsets.all(4.0)), // 4 is the default margin
side: BorderSide(color: Theme.of(context).dividerColor, width: 1),
side: BorderSide(color: theme.dividerColor, width: 1),
),
child: Container(
width: double.infinity,
Expand Down