-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[material_ui] Migrate AppBar M3 template to use new gen_defaults script #12122
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
Open
QuncCccccc
wants to merge
4
commits into
flutter:m3e_migration
Choose a base branch
from
QuncCccccc:app_bar_m3_defaults_migration
base: m3e_migration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
121 changes: 121 additions & 0 deletions
121
packages/material_ui/tool/gen_defaults/templates/app_bar_template.dart
This file contains hidden or 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,121 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
|
elliette marked this conversation as resolved.
|
||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import '../data/app_bar.dart'; | ||
| import '../data/app_bar_large.dart'; | ||
| import '../data/app_bar_medium.dart'; | ||
| import '../data/app_bar_small.dart'; | ||
| import 'template.dart'; | ||
|
|
||
| class AppBarTemplateM3 extends TokenTemplateM3 { | ||
| const AppBarTemplateM3(); | ||
|
|
||
| @override | ||
| String get name => 'App Bar'; | ||
|
|
||
| @override | ||
| String get parentFilePath => 'app_bar.dart'; | ||
|
|
||
| @override | ||
| String generateContents(String className) => | ||
| ''' | ||
| class $className extends AppBarThemeData { | ||
| $className(this.context) | ||
| : super( | ||
| elevation: ${number(TokenAppBar.containerElevation)}, | ||
| scrolledUnderElevation: ${number(TokenAppBar.onScrollContainerElevation)}, | ||
| titleSpacing: NavigationToolbar.kMiddleSpacing, | ||
| toolbarHeight: ${number(TokenAppBarSmall.containerHeight)}, | ||
| ); | ||
| final BuildContext context; | ||
| late final ThemeData _theme = Theme.of(context); | ||
| late final ColorScheme _colors = _theme.colorScheme; | ||
| late final TextTheme _textTheme = _theme.textTheme; | ||
| @override | ||
| Color? get backgroundColor => ${color(TokenAppBar.containerColor, '_colors')}; | ||
| @override | ||
| Color? get foregroundColor => ${color(TokenAppBar.titleColor, '_colors')}; | ||
| @override | ||
| Color? get shadowColor => Colors.transparent; | ||
| @override | ||
| Color? get surfaceTintColor => Colors.transparent; | ||
| @override | ||
| IconThemeData? get iconTheme => IconThemeData( | ||
| color: ${color(TokenAppBar.leadingIconColor, '_colors')}, | ||
| size: ${number(TokenAppBar.iconSize)}, | ||
| ); | ||
| @override | ||
| IconThemeData? get actionsIconTheme => IconThemeData( | ||
| color: ${color(TokenAppBar.trailingIconColor, '_colors')}, | ||
| size: ${number(TokenAppBar.iconSize)}, | ||
| ); | ||
| @override | ||
| TextStyle? get toolbarTextStyle => _textTheme.bodyMedium; | ||
| @override | ||
| TextStyle? get titleTextStyle => _textTheme.titleLarge; | ||
| // TODO(Craftplacer): Consider using EdgeInsets.only(right: 8.0) instead of | ||
| // EdgeInsets.zero for Material 3 in the future, | ||
| // https://github.com/flutter/flutter/issues/155747 | ||
| @override | ||
| EdgeInsets? get actionsPadding => EdgeInsets.zero; | ||
| } | ||
| // Variant configuration | ||
| class _MediumScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { | ||
| _MediumScrollUnderFlexibleConfig(this.context); | ||
| final BuildContext context; | ||
| late final ThemeData _theme = Theme.of(context); | ||
| late final ColorScheme _colors = _theme.colorScheme; | ||
| late final TextTheme _textTheme = _theme.textTheme; | ||
| static const double collapsedHeight = ${number(TokenAppBarSmall.containerHeight)}; | ||
| static const double expandedHeight = ${number(TokenAppBarMedium.containerHeight)}; | ||
| @override | ||
| TextStyle? get collapsedTextStyle => | ||
| _textTheme.titleLarge?.apply(color: ${color(TokenAppBar.titleColor, '_colors')}); | ||
| @override | ||
| TextStyle? get expandedTextStyle => | ||
| _textTheme.headlineSmall?.apply(color: ${color(TokenAppBar.titleColor, '_colors')}); | ||
| @override | ||
| EdgeInsetsGeometry get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 20); | ||
| } | ||
| class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { | ||
| _LargeScrollUnderFlexibleConfig(this.context); | ||
| final BuildContext context; | ||
| late final ThemeData _theme = Theme.of(context); | ||
| late final ColorScheme _colors = _theme.colorScheme; | ||
| late final TextTheme _textTheme = _theme.textTheme; | ||
| static const double collapsedHeight = ${number(TokenAppBarSmall.containerHeight)}; | ||
| static const double expandedHeight = ${number(TokenAppBarLarge.containerHeight)}; | ||
| @override | ||
| TextStyle? get collapsedTextStyle => | ||
| _textTheme.titleLarge?.apply(color: ${color(TokenAppBar.titleColor, '_colors')}); | ||
| @override | ||
| TextStyle? get expandedTextStyle => | ||
| _textTheme.headlineMedium?.apply(color: ${color(TokenAppBar.titleColor, '_colors')}); | ||
| @override | ||
| EdgeInsetsGeometry get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28); | ||
| } | ||
| '''; | ||
| } | ||
111 changes: 0 additions & 111 deletions
111
packages/material_ui/tool/gen_defaults/temporarily_excluded/templates/app_bar_template.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.