Add support for surface tint color overlays to Material widget. (#100036)
This commit is contained in:
@@ -21,6 +21,7 @@ import 'package:gen_defaults/dialog_template.dart';
|
||||
import 'package:gen_defaults/fab_template.dart';
|
||||
import 'package:gen_defaults/navigation_bar_template.dart';
|
||||
import 'package:gen_defaults/navigation_rail_template.dart';
|
||||
import 'package:gen_defaults/surface_tint.dart';
|
||||
import 'package:gen_defaults/typography_template.dart';
|
||||
|
||||
Map<String, dynamic> _readTokenFile(String fileName) {
|
||||
@@ -70,9 +71,10 @@ Future<void> main(List<String> args) async {
|
||||
tokens['colorsLight'] = _readTokenFile('color_light.json');
|
||||
tokens['colorsDark'] = _readTokenFile('color_dark.json');
|
||||
|
||||
DialogTemplate('$materialLib/dialog.dart', tokens).updateFile();
|
||||
FABTemplate('$materialLib/floating_action_button.dart', tokens).updateFile();
|
||||
NavigationBarTemplate('$materialLib/navigation_bar.dart', tokens).updateFile();
|
||||
NavigationRailTemplate('$materialLib/navigation_rail.dart', tokens).updateFile();
|
||||
SurfaceTintTemplate('$materialLib/elevation_overlay.dart', tokens).updateFile();
|
||||
TypographyTemplate('$materialLib/typography.dart', tokens).updateFile();
|
||||
DialogTemplate('$materialLib/dialog.dart', tokens).updateFile();
|
||||
}
|
||||
|
||||
27
dev/tools/gen_defaults/lib/surface_tint.dart
Normal file
27
dev/tools/gen_defaults/lib/surface_tint.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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 SurfaceTintTemplate extends TokenTemplate {
|
||||
const SurfaceTintTemplate(String fileName, Map<String, dynamic> tokens) : super(fileName, tokens);
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
// Generated version ${tokens["version"]}
|
||||
|
||||
// Surface tint opacities based on elevations according to the
|
||||
// Material Design 3 specification:
|
||||
// https://m3.material.io/styles/color/the-color-system/color-roles
|
||||
// Ordered by increasing elevation.
|
||||
const List<_ElevationOpacity> _surfaceTintElevationOpacities = <_ElevationOpacity>[
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level0']}, 0.0), // Elevation level 0
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level1']}, 0.05), // Elevation level 1
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level2']}, 0.08), // Elevation level 2
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level3']}, 0.11), // Elevation level 3
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level4']}, 0.12), // Elevation level 4
|
||||
_ElevationOpacity(${tokens['md.sys.elevation.level5']}, 0.14), // Elevation level 5
|
||||
];
|
||||
''';
|
||||
}
|
||||
Reference in New Issue
Block a user