nav drawer (#115668)
This commit is contained in:
@@ -29,6 +29,7 @@ import 'package:gen_defaults/checkbox_template.dart';
|
||||
import 'package:gen_defaults/color_scheme_template.dart';
|
||||
import 'package:gen_defaults/dialog_template.dart';
|
||||
import 'package:gen_defaults/divider_template.dart';
|
||||
import 'package:gen_defaults/drawer_template.dart';
|
||||
import 'package:gen_defaults/fab_template.dart';
|
||||
import 'package:gen_defaults/filter_chip_template.dart';
|
||||
import 'package:gen_defaults/icon_button_template.dart';
|
||||
@@ -36,6 +37,7 @@ import 'package:gen_defaults/input_chip_template.dart';
|
||||
import 'package:gen_defaults/input_decorator_template.dart';
|
||||
import 'package:gen_defaults/menu_template.dart';
|
||||
import 'package:gen_defaults/navigation_bar_template.dart';
|
||||
import 'package:gen_defaults/navigation_drawer_template.dart';
|
||||
import 'package:gen_defaults/navigation_rail_template.dart';
|
||||
import 'package:gen_defaults/popup_menu_template.dart';
|
||||
import 'package:gen_defaults/progress_indicator_template.dart';
|
||||
@@ -144,6 +146,7 @@ Future<void> main(List<String> args) async {
|
||||
DialogFullscreenTemplate('DialogFullscreen', '$materialLib/dialog.dart', tokens).updateFile();
|
||||
DialogTemplate('Dialog', '$materialLib/dialog.dart', tokens).updateFile();
|
||||
DividerTemplate('Divider', '$materialLib/divider.dart', tokens).updateFile();
|
||||
DrawerTemplate('Drawer', '$materialLib/drawer.dart', tokens).updateFile();
|
||||
FABTemplate('FAB', '$materialLib/floating_action_button.dart', tokens).updateFile();
|
||||
FilterChipTemplate('ChoiceChip', '$materialLib/choice_chip.dart', tokens).updateFile();
|
||||
FilterChipTemplate('FilterChip', '$materialLib/filter_chip.dart', tokens).updateFile();
|
||||
@@ -152,6 +155,7 @@ Future<void> main(List<String> args) async {
|
||||
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
|
||||
MenuTemplate('Menu', '$materialLib/menu_anchor.dart', tokens).updateFile();
|
||||
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
|
||||
NavigationDrawerTemplate('NavigationDrawer', '$materialLib/navigation_drawer.dart', tokens).updateFile();
|
||||
NavigationRailTemplate('NavigationRail', '$materialLib/navigation_rail.dart', tokens).updateFile();
|
||||
PopupMenuTemplate('PopupMenu', '$materialLib/popup_menu.dart', tokens).updateFile();
|
||||
ProgressIndicatorTemplate('ProgressIndicator', '$materialLib/progress_indicator.dart', tokens).updateFile();
|
||||
|
||||
42
dev/tools/gen_defaults/lib/drawer_template.dart
Normal file
42
dev/tools/gen_defaults/lib/drawer_template.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'template.dart';
|
||||
|
||||
class DrawerTemplate extends TokenTemplate {
|
||||
const DrawerTemplate(super.blockName, super.fileName, super.tokens);
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends DrawerThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
: super(elevation: ${elevation("md.comp.navigation-drawer.modal.container")});
|
||||
|
||||
final BuildContext context;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.navigation-drawer.container")};
|
||||
|
||||
@override
|
||||
Color? get surfaceTintColor => ${colorOrTransparent("md.comp.navigation-drawer.container.surface-tint-layer.color")};
|
||||
|
||||
@override
|
||||
Color? get shadowColor => ${colorOrTransparent("md.comp.navigation-drawer.container.shadow-color")};
|
||||
|
||||
// This don't appear to be tokens for this value, but it is
|
||||
// shown in the spec.
|
||||
@override
|
||||
ShapeBorder? get shape => const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.horizontal(right: Radius.circular(16.0)),
|
||||
);
|
||||
|
||||
// This don't appear to be tokens for this value, but it is
|
||||
// shown in the spec.
|
||||
@override
|
||||
ShapeBorder? get endShape => const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.horizontal(left: Radius.circular(16.0)),
|
||||
);
|
||||
}
|
||||
''';
|
||||
}
|
||||
60
dev/tools/gen_defaults/lib/navigation_drawer_template.dart
Normal file
60
dev/tools/gen_defaults/lib/navigation_drawer_template.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'template.dart';
|
||||
|
||||
class NavigationDrawerTemplate extends TokenTemplate {
|
||||
const NavigationDrawerTemplate(super.blockName, super.fileName, super.tokens);
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends NavigationDrawerThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation("md.comp.navigation-drawer.modal.container")},
|
||||
tileHeight: ${tokens["md.comp.navigation-drawer.active-indicator.height"]},
|
||||
indicatorShape: ${shape("md.comp.navigation-drawer.active-indicator")},
|
||||
indicatorSize: const Size(${tokens["md.comp.navigation-drawer.active-indicator.width"]}, ${tokens["md.comp.navigation-drawer.active-indicator.height"]}),
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.navigation-drawer.container")};
|
||||
|
||||
@override
|
||||
Color? get surfaceTintColor => ${colorOrTransparent("md.comp.navigation-drawer.container.surface-tint-layer.color")};
|
||||
|
||||
@override
|
||||
Color? get shadowColor => ${colorOrTransparent("md.comp.navigation-drawer.container.shadow-color")};
|
||||
|
||||
@override
|
||||
Color? get indicatorColor => ${componentColor("md.comp.navigation-drawer.active-indicator")};
|
||||
|
||||
@override
|
||||
MaterialStateProperty<IconThemeData?>? get iconTheme {
|
||||
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
return IconThemeData(
|
||||
size: ${tokens["md.comp.navigation-drawer.icon.size"]},
|
||||
color: states.contains(MaterialState.selected)
|
||||
? ${componentColor("md.comp.navigation-drawer.active.icon.")}
|
||||
: ${componentColor("md.comp.navigation-drawer.inactive.icon")},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
MaterialStateProperty<TextStyle?>? get labelTextStyle {
|
||||
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
final TextStyle style = ${textStyle("md.comp.navigation-drawer.label-text")}!;
|
||||
return style.apply(
|
||||
color: states.contains(MaterialState.selected)
|
||||
? ${componentColor("md.comp.navigation-drawer.active.label-text")}
|
||||
: ${componentColor("md.comp.navigation-drawer.inactive.label-text")},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
''';
|
||||
}
|
||||
Reference in New Issue
Block a user