|
| 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 | +class _AppBarDefaultsM3 extends AppBarThemeData { |
| 6 | + _AppBarDefaultsM3(this.context) |
| 7 | + : super( |
| 8 | + elevation: 0.0, |
| 9 | + scrolledUnderElevation: 3.0, |
| 10 | + titleSpacing: NavigationToolbar.kMiddleSpacing, |
| 11 | + toolbarHeight: 64.0, |
| 12 | + ); |
| 13 | + |
| 14 | + final BuildContext context; |
| 15 | + late final ThemeData _theme = Theme.of(context); |
| 16 | + late final ColorScheme _colors = _theme.colorScheme; |
| 17 | + late final TextTheme _textTheme = _theme.textTheme; |
| 18 | + |
| 19 | + @override |
| 20 | + Color? get backgroundColor => _colors.surface; |
| 21 | + |
| 22 | + @override |
| 23 | + Color? get foregroundColor => _colors.onSurface; |
| 24 | + |
| 25 | + @override |
| 26 | + Color? get shadowColor => Colors.transparent; |
| 27 | + |
| 28 | + @override |
| 29 | + Color? get surfaceTintColor => Colors.transparent; |
| 30 | + |
| 31 | + @override |
| 32 | + IconThemeData? get iconTheme => IconThemeData(color: _colors.onSurface, size: 24.0); |
| 33 | + |
| 34 | + @override |
| 35 | + IconThemeData? get actionsIconTheme => IconThemeData(color: _colors.onSurfaceVariant, size: 24.0); |
| 36 | + |
| 37 | + @override |
| 38 | + TextStyle? get toolbarTextStyle => _textTheme.bodyMedium; |
| 39 | + |
| 40 | + @override |
| 41 | + TextStyle? get titleTextStyle => _textTheme.titleLarge; |
| 42 | + |
| 43 | + // TODO(Craftplacer): Consider using EdgeInsets.only(right: 8.0) instead of |
| 44 | + // EdgeInsets.zero for Material 3 in the future, |
| 45 | + // https://github.com/flutter/flutter/issues/155747 |
| 46 | + @override |
| 47 | + EdgeInsets? get actionsPadding => EdgeInsets.zero; |
| 48 | +} |
| 49 | + |
| 50 | +// Variant configuration |
| 51 | +class _MediumScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { |
| 52 | + _MediumScrollUnderFlexibleConfig(this.context); |
| 53 | + |
| 54 | + final BuildContext context; |
| 55 | + late final ThemeData _theme = Theme.of(context); |
| 56 | + late final ColorScheme _colors = _theme.colorScheme; |
| 57 | + late final TextTheme _textTheme = _theme.textTheme; |
| 58 | + |
| 59 | + static const double collapsedHeight = 64.0; |
| 60 | + static const double expandedHeight = 112.0; |
| 61 | + |
| 62 | + @override |
| 63 | + TextStyle? get collapsedTextStyle => _textTheme.titleLarge?.apply(color: _colors.onSurface); |
| 64 | + |
| 65 | + @override |
| 66 | + TextStyle? get expandedTextStyle => _textTheme.headlineSmall?.apply(color: _colors.onSurface); |
| 67 | + |
| 68 | + @override |
| 69 | + EdgeInsetsGeometry get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 20); |
| 70 | +} |
| 71 | + |
| 72 | +class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { |
| 73 | + _LargeScrollUnderFlexibleConfig(this.context); |
| 74 | + |
| 75 | + final BuildContext context; |
| 76 | + late final ThemeData _theme = Theme.of(context); |
| 77 | + late final ColorScheme _colors = _theme.colorScheme; |
| 78 | + late final TextTheme _textTheme = _theme.textTheme; |
| 79 | + |
| 80 | + static const double collapsedHeight = 64.0; |
| 81 | + static const double expandedHeight = 152.0; |
| 82 | + |
| 83 | + @override |
| 84 | + TextStyle? get collapsedTextStyle => _textTheme.titleLarge?.apply(color: _colors.onSurface); |
| 85 | + |
| 86 | + @override |
| 87 | + TextStyle? get expandedTextStyle => _textTheme.headlineMedium?.apply(color: _colors.onSurface); |
| 88 | + |
| 89 | + @override |
| 90 | + EdgeInsetsGeometry get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28); |
| 91 | +} |
0 commit comments