|
| 1 | +// Copyright 2014 The Flutter Authors. All rights reserved. |
| 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 'template.dart'; |
| 6 | + |
| 7 | +class AppBarTemplate extends TokenTemplate { |
| 8 | + const AppBarTemplate(super.fileName, super.tokens) |
| 9 | + : super( |
| 10 | + colorSchemePrefix: '_colors.', |
| 11 | + textThemePrefix: '_textTheme.', |
| 12 | + ); |
| 13 | + |
| 14 | + @override |
| 15 | + String generate() => ''' |
| 16 | +// Generated version ${tokens["version"]} |
| 17 | +class _TokenDefaultsM3 extends AppBarTheme { |
| 18 | + _TokenDefaultsM3(this.context) |
| 19 | + : super( |
| 20 | + elevation: ${elevation('md.comp.top-app-bar.small.container')}, |
| 21 | + scrolledUnderElevation: ${elevation('md.comp.top-app-bar.small.on-scroll.container')}, |
| 22 | + titleSpacing: NavigationToolbar.kMiddleSpacing, |
| 23 | + toolbarHeight: ${tokens['md.comp.top-app-bar.small.container.height']}, |
| 24 | + ); |
| 25 | +
|
| 26 | + final BuildContext context; |
| 27 | + late final ThemeData _theme = Theme.of(context); |
| 28 | + late final ColorScheme _colors = _theme.colorScheme; |
| 29 | + late final TextTheme _textTheme = _theme.textTheme; |
| 30 | +
|
| 31 | + @override |
| 32 | + Color? get backgroundColor => ${componentColor('md.comp.top-app-bar.small.container')}; |
| 33 | +
|
| 34 | + @override |
| 35 | + Color? get foregroundColor => ${color('md.comp.top-app-bar.small.headline.color')}; |
| 36 | +
|
| 37 | + @override |
| 38 | + Color? get surfaceTintColor => ${componentColor('md.comp.top-app-bar.small.container.surface-tint-layer')}; |
| 39 | +
|
| 40 | + @override |
| 41 | + IconThemeData? get iconTheme => IconThemeData( |
| 42 | + color: ${componentColor('md.comp.top-app-bar.small.leading-icon')}, |
| 43 | + size: ${tokens['md.comp.top-app-bar.small.leading-icon.size']}, |
| 44 | + ); |
| 45 | +
|
| 46 | + @override |
| 47 | + IconThemeData? get actionsIconTheme => IconThemeData( |
| 48 | + color: ${componentColor('md.comp.top-app-bar.small.trailing-icon')}, |
| 49 | + size: ${tokens['md.comp.top-app-bar.small.trailing-icon.size']}, |
| 50 | + ); |
| 51 | +
|
| 52 | + @override |
| 53 | + TextStyle? get toolbarTextStyle => _textTheme.bodyText2; |
| 54 | +
|
| 55 | + @override |
| 56 | + TextStyle? get titleTextStyle => ${textStyle('md.comp.top-app-bar.small.headline')}; |
| 57 | +}'''; |
| 58 | +} |
0 commit comments