-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YaruMasterDetailPage: remove built-in app bar in favor of YaruDetailP…
…age (#263) * Add YaruDetailPage * YaruMasterDetailPage: remove built-in app bar In favor of YaruDetailPage. * Docs: add see also links
- Loading branch information
Showing
6 changed files
with
147 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Provides the recommended layout for [YaruMasterDetailPage.pageBuilder]. | ||
/// | ||
/// This widget is similar to [Scaffold] with the exception that it wraps the | ||
/// [appBar] in a [Hero] to keep it in place at the top during page transitions. | ||
class YaruDetailPage extends StatelessWidget { | ||
const YaruDetailPage({ | ||
super.key, | ||
this.appBar, | ||
this.body, | ||
this.floatingActionButton, | ||
this.floatingActionButtonLocation, | ||
this.floatingActionButtonAnimator, | ||
this.persistentFooterButtons, | ||
this.persistentFooterAlignment = AlignmentDirectional.centerEnd, | ||
this.bottomNavigationBar, | ||
this.bottomSheet, | ||
this.backgroundColor, | ||
this.extendBody = false, | ||
this.extendBodyBehindAppBar = false, | ||
}); | ||
|
||
/// See [Scaffold.extendBody]. | ||
final bool extendBody; | ||
|
||
/// See [Scaffold.extendBodyBehindAppBar]. | ||
final bool extendBodyBehindAppBar; | ||
|
||
/// See [Scaffold.appBar]. | ||
final PreferredSizeWidget? appBar; | ||
|
||
/// See [Scaffold.body]. | ||
final Widget? body; | ||
|
||
/// See [Scaffold.floatingActionButton]. | ||
final Widget? floatingActionButton; | ||
|
||
/// See [Scaffold.floatingActionButtonLocation]. | ||
final FloatingActionButtonLocation? floatingActionButtonLocation; | ||
|
||
/// See [Scaffold.floatingActionButtonAnimator]. | ||
final FloatingActionButtonAnimator? floatingActionButtonAnimator; | ||
|
||
/// See [Scaffold.persistentFooterButtons]. | ||
final List<Widget>? persistentFooterButtons; | ||
|
||
/// See [Scaffold.persistentFooterAlignment]. | ||
final AlignmentDirectional persistentFooterAlignment; | ||
|
||
/// See [Scaffold.backgroundColor]. | ||
final Color? backgroundColor; | ||
|
||
/// See [Scaffold.bottomNavigationBar]. | ||
final Widget? bottomNavigationBar; | ||
|
||
/// See [Scaffold.bottomSheet]. | ||
final Widget? bottomSheet; | ||
|
||
PreferredSizeWidget? _buildAppBar(BuildContext context) { | ||
if (appBar == null) return null; | ||
|
||
return PreferredSize( | ||
preferredSize: Size( | ||
0, | ||
Theme.of(context).appBarTheme.toolbarHeight ?? kToolbarHeight, | ||
), | ||
child: Hero( | ||
tag: '<YaruDetailPage Hero tag - $appBar>', | ||
child: appBar!, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: _buildAppBar(context), | ||
body: body, | ||
floatingActionButton: floatingActionButton, | ||
floatingActionButtonLocation: floatingActionButtonLocation, | ||
floatingActionButtonAnimator: floatingActionButtonAnimator, | ||
persistentFooterButtons: persistentFooterButtons, | ||
persistentFooterAlignment: persistentFooterAlignment, | ||
bottomNavigationBar: bottomNavigationBar, | ||
bottomSheet: bottomSheet, | ||
backgroundColor: backgroundColor, | ||
extendBody: extendBody, | ||
extendBodyBehindAppBar: extendBodyBehindAppBar, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters