|
| 1 | +// Copyright 2013 The Flutter Authors |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import '../data/navigation_rail.dart'; |
| 6 | +import 'template.dart'; |
| 7 | + |
| 8 | +class NavigationRailTemplateM3 extends TokenTemplateM3 { |
| 9 | + const NavigationRailTemplateM3(); |
| 10 | + |
| 11 | + @override |
| 12 | + String get name => 'Navigation Rail'; |
| 13 | + |
| 14 | + @override |
| 15 | + String get parentFilePath => 'navigation_rail.dart'; |
| 16 | + |
| 17 | + @override |
| 18 | + String generateContents(String className) => |
| 19 | + ''' |
| 20 | +class $className extends NavigationRailThemeData { |
| 21 | + $className(this.context) |
| 22 | + : super( |
| 23 | + elevation: ${number(TokenNavigationRail.containerElevation)}, |
| 24 | + groupAlignment: -1, |
| 25 | + labelType: NavigationRailLabelType.none, |
| 26 | + useIndicator: true, |
| 27 | + minWidth: ${number(TokenNavigationRail.containerWidth)}, |
| 28 | + minExtendedWidth: 256, |
| 29 | + ); |
| 30 | +
|
| 31 | + final BuildContext context; |
| 32 | + late final ColorScheme _colors = Theme.of(context).colorScheme; |
| 33 | + late final TextTheme _textTheme = Theme.of(context).textTheme; |
| 34 | +
|
| 35 | + @override |
| 36 | + Color? get backgroundColor => ${color(TokenNavigationRail.containerColor)}; |
| 37 | +
|
| 38 | + @override |
| 39 | + TextStyle? get unselectedLabelTextStyle { |
| 40 | + return ${textStyle(TokenNavigationRail.labelTextType, '_textTheme')}!.copyWith(color: ${color(TokenNavigationRail.inactiveFocusLabelTextColor)}); |
| 41 | + } |
| 42 | +
|
| 43 | + @override |
| 44 | + TextStyle? get selectedLabelTextStyle { |
| 45 | + return ${textStyle(TokenNavigationRail.labelTextType, '_textTheme')}!.copyWith(color: ${color(TokenNavigationRail.activeFocusLabelTextColor)}); |
| 46 | + } |
| 47 | +
|
| 48 | + @override |
| 49 | + IconThemeData? get unselectedIconTheme { |
| 50 | + return IconThemeData( |
| 51 | + size: ${number(TokenNavigationRail.iconSize)}, |
| 52 | + color: ${color(TokenNavigationRail.inactiveIconColor)}, |
| 53 | + ); |
| 54 | + } |
| 55 | +
|
| 56 | + @override |
| 57 | + IconThemeData? get selectedIconTheme { |
| 58 | + return IconThemeData( |
| 59 | + size: ${number(TokenNavigationRail.iconSize)}, |
| 60 | + color: ${color(TokenNavigationRail.activeIconColor)}, |
| 61 | + ); |
| 62 | + } |
| 63 | +
|
| 64 | + @override |
| 65 | + Color? get indicatorColor => ${color(TokenNavigationRail.activeIndicatorColor)}; |
| 66 | +
|
| 67 | + @override |
| 68 | + ShapeBorder? get indicatorShape => ${shape(TokenNavigationRail.activeIndicatorShape)}; |
| 69 | +} |
| 70 | +'''; |
| 71 | +} |
0 commit comments