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

Add YaruNavigationPageTheme.railPadding #466

Merged
merged 2 commits into from
Jan 3, 2023
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: 10 additions & 0 deletions lib/src/layouts/yaru_navigation_page_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class NavigationPageThemeData extends ThemeExtension<NavigationPageThemeData>
with Diagnosticable {
/// Creates a theme that can be used with [YaruNavigationPage].
const NavigationPageThemeData({
this.railPadding,
this.pageTransitions,
});

Expand All @@ -16,16 +17,21 @@ class NavigationPageThemeData extends ThemeExtension<NavigationPageThemeData>
);
}

/// The padding around the navigation rail.
final EdgeInsetsGeometry? railPadding;

/// The page transitions to use.
final PageTransitionsTheme? pageTransitions;

/// Creates a copy of this object but with the given fields replaced with the
/// new values.
@override
NavigationPageThemeData copyWith({
EdgeInsetsGeometry? railPadding,
PageTransitionsTheme? pageTransitions,
}) {
return NavigationPageThemeData(
railPadding: railPadding ?? this.railPadding,
pageTransitions: pageTransitions ?? this.pageTransitions,
);
}
Expand All @@ -37,26 +43,30 @@ class NavigationPageThemeData extends ThemeExtension<NavigationPageThemeData>
) {
final o = other as NavigationPageThemeData?;
return NavigationPageThemeData(
railPadding: EdgeInsetsGeometry.lerp(railPadding, o?.railPadding, t),
pageTransitions: t < 0.5 ? pageTransitions : o?.pageTransitions,
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty('railPadding', railPadding));
properties.add(DiagnosticsProperty('pageTransitions', pageTransitions));
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is NavigationPageThemeData &&
other.railPadding == railPadding &&
other.pageTransitions == pageTransitions;
}

@override
int get hashCode {
return Object.hashAll([
railPadding,
pageTransitions,
]);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/src/layouts/yaru_navigation_rail.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'yaru_navigation_page.dart';
import 'yaru_navigation_page_theme.dart';
import 'yaru_navigation_rail_item.dart';

class YaruNavigationRail extends StatelessWidget {
Expand Down Expand Up @@ -43,8 +44,9 @@ class YaruNavigationRail extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = YaruNavigationPageTheme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 5),
padding: theme.railPadding ?? EdgeInsets.zero,
child: IntrinsicHeight(
child: Column(
children: <Widget>[
Expand Down
Binary file modified test/pages/goldens/yaru_navigation_page-compact-dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/pages/goldens/yaru_navigation_page-compact-light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/pages/goldens/yaru_navigation_page-labelled-dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/pages/goldens/yaru_navigation_page-labelled-extended-dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/pages/goldens/yaru_navigation_page-labelled-light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.