From 0a7b3d72c981975311280b448caeb4518b551cf7 Mon Sep 17 00:00:00 2001 From: Darren Austin Date: Wed, 23 Mar 2022 12:10:17 -0700 Subject: [PATCH] Updated tokens to v0.92. (#100599) --- dev/tools/gen_defaults/bin/gen_defaults.dart | 19 +++--- dev/tools/gen_defaults/data/banner.json | 2 +- .../gen_defaults/data/button_elevated.json | 36 +++++++++++ .../gen_defaults/data/button_filled.json | 40 ++++++++++++ .../data/button_filled_tonal.json | 35 +++++++++++ .../gen_defaults/data/button_outlined.json | 33 ++++++++++ dev/tools/gen_defaults/data/button_text.json | 26 ++++++++ ...{elevated_card.json => card_elevated.json} | 2 +- .../{filled_card.json => card_filled.json} | 2 +- ...{outlined_card.json => card_outlined.json} | 2 +- .../{assist_chip.json => chip_assist.json} | 2 +- .../{filter_chip.json => chip_filter.json} | 2 +- .../data/{input_chip.json => chip_input.json} | 2 +- ...gestion_chip.json => chip_suggestion.json} | 2 +- dev/tools/gen_defaults/data/color_dark.json | 2 +- dev/tools/gen_defaults/data/color_light.json | 2 +- dev/tools/gen_defaults/data/dialog.json | 2 +- dev/tools/gen_defaults/data/elevation.json | 2 +- .../data/fab_extended_primary.json | 2 +- .../gen_defaults/data/fab_large_primary.json | 2 +- dev/tools/gen_defaults/data/fab_primary.json | 2 +- .../gen_defaults/data/fab_small_primary.json | 2 +- dev/tools/gen_defaults/data/motion.json | 2 +- .../gen_defaults/data/navigation_bar.json | 2 +- .../gen_defaults/data/navigation_rail.json | 2 +- dev/tools/gen_defaults/data/palette.json | 2 +- dev/tools/gen_defaults/data/shape.json | 2 +- dev/tools/gen_defaults/data/slider.json | 2 +- dev/tools/gen_defaults/data/state.json | 2 +- dev/tools/gen_defaults/data/text_style.json | 2 +- .../gen_defaults/data/top_app_bar_large.json | 2 +- .../gen_defaults/data/top_app_bar_medium.json | 2 +- .../gen_defaults/data/top_app_bar_small.json | 2 +- dev/tools/gen_defaults/data/typeface.json | 2 +- dev/tools/gen_defaults/lib/card_template.dart | 6 +- .../gen_defaults/lib/dialog_template.dart | 20 +++--- dev/tools/gen_defaults/lib/fab_template.dart | 26 ++++---- .../lib/navigation_bar_template.dart | 31 +++++----- .../lib/navigation_rail_template.dart | 29 +++++---- dev/tools/gen_defaults/lib/template.dart | 61 ++++++++++++++++--- packages/flutter/lib/src/material/card.dart | 2 +- packages/flutter/lib/src/material/dialog.dart | 10 ++- .../lib/src/material/elevation_overlay.dart | 2 +- .../src/material/floating_action_button.dart | 10 ++- .../lib/src/material/navigation_bar.dart | 16 ++--- .../lib/src/material/navigation_rail.dart | 18 +++--- .../flutter/lib/src/material/typography.dart | 2 +- 47 files changed, 351 insertions(+), 127 deletions(-) create mode 100644 dev/tools/gen_defaults/data/button_elevated.json create mode 100644 dev/tools/gen_defaults/data/button_filled.json create mode 100644 dev/tools/gen_defaults/data/button_filled_tonal.json create mode 100644 dev/tools/gen_defaults/data/button_outlined.json create mode 100644 dev/tools/gen_defaults/data/button_text.json rename dev/tools/gen_defaults/data/{elevated_card.json => card_elevated.json} (98%) rename dev/tools/gen_defaults/data/{filled_card.json => card_filled.json} (98%) rename dev/tools/gen_defaults/data/{outlined_card.json => card_outlined.json} (98%) rename dev/tools/gen_defaults/data/{assist_chip.json => chip_assist.json} (99%) rename dev/tools/gen_defaults/data/{filter_chip.json => chip_filter.json} (99%) rename dev/tools/gen_defaults/data/{input_chip.json => chip_input.json} (99%) rename dev/tools/gen_defaults/data/{suggestion_chip.json => chip_suggestion.json} (99%) diff --git a/dev/tools/gen_defaults/bin/gen_defaults.dart b/dev/tools/gen_defaults/bin/gen_defaults.dart index caed5739ef..187e0f757c 100644 --- a/dev/tools/gen_defaults/bin/gen_defaults.dart +++ b/dev/tools/gen_defaults/bin/gen_defaults.dart @@ -32,29 +32,34 @@ Map _readTokenFile(String fileName) { Future main(List args) async { const String materialLib = 'packages/flutter/lib/src/material'; const List tokenFiles = [ - 'assist_chip.json', 'banner.json', + 'button_elevated.json', + 'button_filled.json', + 'button_filled_tonal.json', + 'button_outlined.json', + 'button_text.json', + 'card_elevated.json', + 'card_filled.json', + 'card_outlined.json', + 'chip_assist.json', + 'chip_filter.json', + 'chip_input.json', + 'chip_suggestion.json', 'color_dark.json', 'color_light.json', 'dialog.json', 'elevation.json', - 'elevated_card.json', 'fab_extended_primary.json', 'fab_large_primary.json', 'fab_primary.json', 'fab_small_primary.json', - 'filled_card.json', - 'filter_chip.json', - 'input_chip.json', 'motion.json', 'navigation_bar.json', 'navigation_rail.json', - 'outlined_card.json', 'palette.json', 'shape.json', 'slider.json', 'state.json', - 'suggestion_chip.json', 'text_style.json', 'top_app_bar_large.json', 'top_app_bar_medium.json', diff --git a/dev/tools/gen_defaults/data/banner.json b/dev/tools/gen_defaults/data/banner.json index 97d6541452..510a97ade0 100644 --- a/dev/tools/gen_defaults/data/banner.json +++ b/dev/tools/gen_defaults/data/banner.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.banner.action.focus.label-text.color": "primary", "md.comp.banner.action.focus.state-layer.color": "primary", diff --git a/dev/tools/gen_defaults/data/button_elevated.json b/dev/tools/gen_defaults/data/button_elevated.json new file mode 100644 index 0000000000..8b0b352363 --- /dev/null +++ b/dev/tools/gen_defaults/data/button_elevated.json @@ -0,0 +1,36 @@ +{ + "version": "v0_92", + + "md.comp.elevated-button.container.color": "surface", + "md.comp.elevated-button.container.elevation": "md.sys.elevation.level1", + "md.comp.elevated-button.container.height": 40.0, + "md.comp.elevated-button.container.shadow-color": "shadow", + "md.comp.elevated-button.container.shape": "md.sys.shape.corner.full", + "md.comp.elevated-button.container.surface-tint-layer.color": "surfaceTint", + "md.comp.elevated-button.disabled.container.color": "onSurface", + "md.comp.elevated-button.disabled.container.elevation": "md.sys.elevation.level0", + "md.comp.elevated-button.disabled.container.opacity": 0.12, + "md.comp.elevated-button.disabled.label-text.color": "onSurface", + "md.comp.elevated-button.disabled.label-text.opacity": 0.38, + "md.comp.elevated-button.focus.container.elevation": "md.sys.elevation.level1", + "md.comp.elevated-button.focus.label-text.color": "primary", + "md.comp.elevated-button.focus.state-layer.color": "primary", + "md.comp.elevated-button.focus.state-layer.opacity": "md.sys.state.focus.state-layer-opacity", + "md.comp.elevated-button.hover.container.elevation": "md.sys.elevation.level2", + "md.comp.elevated-button.hover.label-text.color": "primary", + "md.comp.elevated-button.hover.state-layer.color": "primary", + "md.comp.elevated-button.hover.state-layer.opacity": "md.sys.state.hover.state-layer-opacity", + "md.comp.elevated-button.label-text.color": "primary", + "md.comp.elevated-button.label-text.text-style": "labelLarge", + "md.comp.elevated-button.pressed.container.elevation": "md.sys.elevation.level1", + "md.comp.elevated-button.pressed.label-text.color": "primary", + "md.comp.elevated-button.pressed.state-layer.color": "primary", + "md.comp.elevated-button.pressed.state-layer.opacity": "md.sys.state.pressed.state-layer-opacity", + "md.comp.elevated-button.with-icon.disabled.icon.color": "onSurface", + "md.comp.elevated-button.with-icon.disabled.icon.opacity": 0.38, + "md.comp.elevated-button.with-icon.focus.icon.color": "primary", + "md.comp.elevated-button.with-icon.hover.icon.color": "primary", + "md.comp.elevated-button.with-icon.icon.color": "primary", + "md.comp.elevated-button.with-icon.icon.size": 18.0, + "md.comp.elevated-button.with-icon.pressed.icon.color": "primary" +} diff --git a/dev/tools/gen_defaults/data/button_filled.json b/dev/tools/gen_defaults/data/button_filled.json new file mode 100644 index 0000000000..691f85fa40 --- /dev/null +++ b/dev/tools/gen_defaults/data/button_filled.json @@ -0,0 +1,40 @@ +{ + "version": "v0_92", + + "md.comp.filled-button.container.color": "primary", + "md.comp.filled-button.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-button.container.height": 40.0, + "md.comp.filled-button.container.shadow-color": "shadow", + "md.comp.filled-button.container.shape": "md.sys.shape.corner.full", + "md.comp.filled-button.disabled.container.color": "onSurface", + "md.comp.filled-button.disabled.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-button.disabled.container.opacity": 0.12, + "md.comp.filled-button.disabled.label-text.color": "onSurface", + "md.comp.filled-button.disabled.label-text.opacity": 0.38, + "md.comp.filled-button.dragged.container.elevation": "md.sys.elevation.level3", + "md.comp.filled-button.dragged.label-text.color": "onPrimary", + "md.comp.filled-button.dragged.state-layer.color": "onPrimary", + "md.comp.filled-button.dragged.state-layer.opacity": "md.sys.state.dragged.state-layer-opacity", + "md.comp.filled-button.focus.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-button.focus.label-text.color": "onPrimary", + "md.comp.filled-button.focus.state-layer.color": "onPrimary", + "md.comp.filled-button.focus.state-layer.opacity": "md.sys.state.focus.state-layer-opacity", + "md.comp.filled-button.hover.container.elevation": "md.sys.elevation.level1", + "md.comp.filled-button.hover.label-text.color": "onPrimary", + "md.comp.filled-button.hover.state-layer.color": "onPrimary", + "md.comp.filled-button.hover.state-layer.opacity": "md.sys.state.hover.state-layer-opacity", + "md.comp.filled-button.label-text.color": "onPrimary", + "md.comp.filled-button.label-text.text-style": "labelLarge", + "md.comp.filled-button.pressed.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-button.pressed.label-text.color": "onPrimary", + "md.comp.filled-button.pressed.state-layer.color": "onPrimary", + "md.comp.filled-button.pressed.state-layer.opacity": "md.sys.state.pressed.state-layer-opacity", + "md.comp.filled-button.with-icon.disabled.icon.color": "onSurface", + "md.comp.filled-button.with-icon.disabled.icon.opacity": 0.38, + "md.comp.filled-button.with-icon.dragged.icon.color": "onPrimary", + "md.comp.filled-button.with-icon.focus.icon.color": "onPrimary", + "md.comp.filled-button.with-icon.hover.icon.color": "onPrimary", + "md.comp.filled-button.with-icon.icon.color": "onPrimary", + "md.comp.filled-button.with-icon.icon.size": 18.0, + "md.comp.filled-button.with-icon.pressed.icon.color": "onPrimary" +} diff --git a/dev/tools/gen_defaults/data/button_filled_tonal.json b/dev/tools/gen_defaults/data/button_filled_tonal.json new file mode 100644 index 0000000000..3b8fd7e3c9 --- /dev/null +++ b/dev/tools/gen_defaults/data/button_filled_tonal.json @@ -0,0 +1,35 @@ +{ + "version": "v0_92", + + "md.comp.filled-tonal-button.container.color": "secondaryContainer", + "md.comp.filled-tonal-button.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-tonal-button.container.height": 40.0, + "md.comp.filled-tonal-button.container.shadow-color": "shadow", + "md.comp.filled-tonal-button.container.shape": "md.sys.shape.corner.full", + "md.comp.filled-tonal-button.disabled.container.color": "onSurface", + "md.comp.filled-tonal-button.disabled.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-tonal-button.disabled.container.opacity": 0.12, + "md.comp.filled-tonal-button.disabled.label-text.color": "onSurface", + "md.comp.filled-tonal-button.disabled.label-text.opacity": 0.38, + "md.comp.filled-tonal-button.focus.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-tonal-button.focus.label-text.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.focus.state-layer.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.focus.state-layer.opacity": "md.sys.state.focus.state-layer-opacity", + "md.comp.filled-tonal-button.hover.container.elevation": "md.sys.elevation.level1", + "md.comp.filled-tonal-button.hover.label-text.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.hover.state-layer.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.hover.state-layer.opacity": "md.sys.state.hover.state-layer-opacity", + "md.comp.filled-tonal-button.label-text.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.label-text.text-style": "labelLarge", + "md.comp.filled-tonal-button.pressed.container.elevation": "md.sys.elevation.level0", + "md.comp.filled-tonal-button.pressed.label-text.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.pressed.state-layer.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.pressed.state-layer.opacity": "md.sys.state.pressed.state-layer-opacity", + "md.comp.filled-tonal-button.with-icon.disabled.icon.color": "onSurface", + "md.comp.filled-tonal-button.with-icon.disabled.icon.opacity": 0.38, + "md.comp.filled-tonal-button.with-icon.focus.icon.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.with-icon.hover.icon.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.with-icon.icon.color": "onSecondaryContainer", + "md.comp.filled-tonal-button.with-icon.icon.size": 18.0, + "md.comp.filled-tonal-button.with-icon.pressed.icon.color": "onSecondaryContainer" +} diff --git a/dev/tools/gen_defaults/data/button_outlined.json b/dev/tools/gen_defaults/data/button_outlined.json new file mode 100644 index 0000000000..b8de58511d --- /dev/null +++ b/dev/tools/gen_defaults/data/button_outlined.json @@ -0,0 +1,33 @@ +{ + "version": "v0_92", + + "md.comp.outlined-button.container.height": 40.0, + "md.comp.outlined-button.container.shape": "md.sys.shape.corner.full", + "md.comp.outlined-button.disabled.label-text.color": "onSurface", + "md.comp.outlined-button.disabled.label-text.opacity": 0.38, + "md.comp.outlined-button.disabled.outline.color": "onSurface", + "md.comp.outlined-button.disabled.outline.opacity": 0.12, + "md.comp.outlined-button.focus.label-text.color": "primary", + "md.comp.outlined-button.focus.outline.color": "primary", + "md.comp.outlined-button.focus.state-layer.color": "primary", + "md.comp.outlined-button.focus.state-layer.opacity": "md.sys.state.focus.state-layer-opacity", + "md.comp.outlined-button.hover.label-text.color": "primary", + "md.comp.outlined-button.hover.outline.color": "outline", + "md.comp.outlined-button.hover.state-layer.color": "primary", + "md.comp.outlined-button.hover.state-layer.opacity": "md.sys.state.hover.state-layer-opacity", + "md.comp.outlined-button.label-text.color": "primary", + "md.comp.outlined-button.label-text.text-style": "labelLarge", + "md.comp.outlined-button.outline.color": "outline", + "md.comp.outlined-button.outline.width": 1.0, + "md.comp.outlined-button.pressed.label-text.color": "primary", + "md.comp.outlined-button.pressed.outline.color": "outline", + "md.comp.outlined-button.pressed.state-layer.color": "primary", + "md.comp.outlined-button.pressed.state-layer.opacity": "md.sys.state.pressed.state-layer-opacity", + "md.comp.outlined-button.with-icon.disabled.icon.color": "onSurface", + "md.comp.outlined-button.with-icon.disabled.icon.opacity": 0.38, + "md.comp.outlined-button.with-icon.focus.icon.color": "primary", + "md.comp.outlined-button.with-icon.hover.icon.color": "primary", + "md.comp.outlined-button.with-icon.icon.color": "primary", + "md.comp.outlined-button.with-icon.icon.size": 18.0, + "md.comp.outlined-button.with-icon.pressed.icon.color": "primary" +} diff --git a/dev/tools/gen_defaults/data/button_text.json b/dev/tools/gen_defaults/data/button_text.json new file mode 100644 index 0000000000..1a1c2bdb29 --- /dev/null +++ b/dev/tools/gen_defaults/data/button_text.json @@ -0,0 +1,26 @@ +{ + "version": "v0_92", + + "md.comp.text-button.container.height": 40.0, + "md.comp.text-button.container.shape": "md.sys.shape.corner.full", + "md.comp.text-button.disabled.label-text.color": "onSurface", + "md.comp.text-button.disabled.label-text.opacity": 0.38, + "md.comp.text-button.focus.label-text.color": "primary", + "md.comp.text-button.focus.state-layer.color": "primary", + "md.comp.text-button.focus.state-layer.opacity": "md.sys.state.focus.state-layer-opacity", + "md.comp.text-button.hover.label-text.color": "primary", + "md.comp.text-button.hover.state-layer.color": "primary", + "md.comp.text-button.hover.state-layer.opacity": "md.sys.state.hover.state-layer-opacity", + "md.comp.text-button.label-text.color": "primary", + "md.comp.text-button.label-text.text-style": "labelLarge", + "md.comp.text-button.pressed.label-text.color": "primary", + "md.comp.text-button.pressed.state-layer.color": "primary", + "md.comp.text-button.pressed.state-layer.opacity": "md.sys.state.pressed.state-layer-opacity", + "md.comp.text-button.with-icon.disabled.icon.color": "onSurface", + "md.comp.text-button.with-icon.disabled.icon.opacity": 0.38, + "md.comp.text-button.with-icon.focus.icon.color": "primary", + "md.comp.text-button.with-icon.hover.icon.color": "primary", + "md.comp.text-button.with-icon.icon.color": "primary", + "md.comp.text-button.with-icon.icon.size": 18.0, + "md.comp.text-button.with-icon.pressed.icon.color": "primary" +} diff --git a/dev/tools/gen_defaults/data/elevated_card.json b/dev/tools/gen_defaults/data/card_elevated.json similarity index 98% rename from dev/tools/gen_defaults/data/elevated_card.json rename to dev/tools/gen_defaults/data/card_elevated.json index 7f1df66704..e5d31a07d7 100644 --- a/dev/tools/gen_defaults/data/elevated_card.json +++ b/dev/tools/gen_defaults/data/card_elevated.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.elevated-card.container.color": "surface", "md.comp.elevated-card.container.elevation": "md.sys.elevation.level1", diff --git a/dev/tools/gen_defaults/data/filled_card.json b/dev/tools/gen_defaults/data/card_filled.json similarity index 98% rename from dev/tools/gen_defaults/data/filled_card.json rename to dev/tools/gen_defaults/data/card_filled.json index fd4d6d2b3a..7f5bff68e5 100644 --- a/dev/tools/gen_defaults/data/filled_card.json +++ b/dev/tools/gen_defaults/data/card_filled.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.filled-card.container.color": "surfaceVariant", "md.comp.filled-card.container.elevation": "md.sys.elevation.level0", diff --git a/dev/tools/gen_defaults/data/outlined_card.json b/dev/tools/gen_defaults/data/card_outlined.json similarity index 98% rename from dev/tools/gen_defaults/data/outlined_card.json rename to dev/tools/gen_defaults/data/card_outlined.json index 763631c744..5409fc8ac6 100644 --- a/dev/tools/gen_defaults/data/outlined_card.json +++ b/dev/tools/gen_defaults/data/card_outlined.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.outlined-card.container.color": "surface", "md.comp.outlined-card.container.elevation": "md.sys.elevation.level0", diff --git a/dev/tools/gen_defaults/data/assist_chip.json b/dev/tools/gen_defaults/data/chip_assist.json similarity index 99% rename from dev/tools/gen_defaults/data/assist_chip.json rename to dev/tools/gen_defaults/data/chip_assist.json index 40339eda27..f481169339 100644 --- a/dev/tools/gen_defaults/data/assist_chip.json +++ b/dev/tools/gen_defaults/data/chip_assist.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.assist-chip.container.height": 32.0, "md.comp.assist-chip.container.shape": "md.sys.shape.corner.small", diff --git a/dev/tools/gen_defaults/data/filter_chip.json b/dev/tools/gen_defaults/data/chip_filter.json similarity index 99% rename from dev/tools/gen_defaults/data/filter_chip.json rename to dev/tools/gen_defaults/data/chip_filter.json index 9f6d78a49b..2a226e64fe 100644 --- a/dev/tools/gen_defaults/data/filter_chip.json +++ b/dev/tools/gen_defaults/data/chip_filter.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.filter-chip.container.height": 32.0, "md.comp.filter-chip.container.shadow-color": "shadow", diff --git a/dev/tools/gen_defaults/data/input_chip.json b/dev/tools/gen_defaults/data/chip_input.json similarity index 99% rename from dev/tools/gen_defaults/data/input_chip.json rename to dev/tools/gen_defaults/data/chip_input.json index 6c207ec2b3..9e8af707a7 100644 --- a/dev/tools/gen_defaults/data/input_chip.json +++ b/dev/tools/gen_defaults/data/chip_input.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.input-chip.container.elevation": "md.sys.elevation.level0", "md.comp.input-chip.container.height": 32.0, diff --git a/dev/tools/gen_defaults/data/suggestion_chip.json b/dev/tools/gen_defaults/data/chip_suggestion.json similarity index 99% rename from dev/tools/gen_defaults/data/suggestion_chip.json rename to dev/tools/gen_defaults/data/chip_suggestion.json index ca865e3797..ed025fda87 100644 --- a/dev/tools/gen_defaults/data/suggestion_chip.json +++ b/dev/tools/gen_defaults/data/chip_suggestion.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.suggestion-chip.container.height": 32.0, "md.comp.suggestion-chip.container.shape": "md.sys.shape.corner.small", diff --git a/dev/tools/gen_defaults/data/color_dark.json b/dev/tools/gen_defaults/data/color_dark.json index c7c616ee40..a8246a9d88 100644 --- a/dev/tools/gen_defaults/data/color_dark.json +++ b/dev/tools/gen_defaults/data/color_dark.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.color.background": "md.ref.palette.neutral10", "md.sys.color.error": "md.ref.palette.error80", diff --git a/dev/tools/gen_defaults/data/color_light.json b/dev/tools/gen_defaults/data/color_light.json index 4d6a333a89..2376cdf53f 100644 --- a/dev/tools/gen_defaults/data/color_light.json +++ b/dev/tools/gen_defaults/data/color_light.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.color.background": "md.ref.palette.neutral99", "md.sys.color.error": "md.ref.palette.error40", diff --git a/dev/tools/gen_defaults/data/dialog.json b/dev/tools/gen_defaults/data/dialog.json index 18b7249184..16eacc9078 100644 --- a/dev/tools/gen_defaults/data/dialog.json +++ b/dev/tools/gen_defaults/data/dialog.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.dialog.action.focus.label-text.color": "primary", "md.comp.dialog.action.focus.state-layer.color": "primary", diff --git a/dev/tools/gen_defaults/data/elevation.json b/dev/tools/gen_defaults/data/elevation.json index 8a420f842b..27d86be10e 100644 --- a/dev/tools/gen_defaults/data/elevation.json +++ b/dev/tools/gen_defaults/data/elevation.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.elevation.level0": 0.0, "md.sys.elevation.level1": 1.0, diff --git a/dev/tools/gen_defaults/data/fab_extended_primary.json b/dev/tools/gen_defaults/data/fab_extended_primary.json index 7b9989775d..a4acc70f8f 100644 --- a/dev/tools/gen_defaults/data/fab_extended_primary.json +++ b/dev/tools/gen_defaults/data/fab_extended_primary.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.extended-fab.primary.container.color": "primaryContainer", "md.comp.extended-fab.primary.container.elevation": "md.sys.elevation.level3", diff --git a/dev/tools/gen_defaults/data/fab_large_primary.json b/dev/tools/gen_defaults/data/fab_large_primary.json index 1391d90195..f623cb6016 100644 --- a/dev/tools/gen_defaults/data/fab_large_primary.json +++ b/dev/tools/gen_defaults/data/fab_large_primary.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.fab.primary.large.container.color": "primaryContainer", "md.comp.fab.primary.large.container.elevation": "md.sys.elevation.level3", diff --git a/dev/tools/gen_defaults/data/fab_primary.json b/dev/tools/gen_defaults/data/fab_primary.json index fb14d94c23..8e537d66a0 100644 --- a/dev/tools/gen_defaults/data/fab_primary.json +++ b/dev/tools/gen_defaults/data/fab_primary.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.fab.primary.container.color": "primaryContainer", "md.comp.fab.primary.container.elevation": "md.sys.elevation.level3", diff --git a/dev/tools/gen_defaults/data/fab_small_primary.json b/dev/tools/gen_defaults/data/fab_small_primary.json index 8fc9318e63..66620ff3e8 100644 --- a/dev/tools/gen_defaults/data/fab_small_primary.json +++ b/dev/tools/gen_defaults/data/fab_small_primary.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.fab.primary.small.container.color": "primaryContainer", "md.comp.fab.primary.small.container.elevation": "md.sys.elevation.level3", diff --git a/dev/tools/gen_defaults/data/motion.json b/dev/tools/gen_defaults/data/motion.json index e0aeb9c213..79dfd44a09 100644 --- a/dev/tools/gen_defaults/data/motion.json +++ b/dev/tools/gen_defaults/data/motion.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.motion.duration.100Ms": 100.0, "md.sys.motion.duration.1000Ms": 1000.0, diff --git a/dev/tools/gen_defaults/data/navigation_bar.json b/dev/tools/gen_defaults/data/navigation_bar.json index 18234ec261..fe3bec3a53 100644 --- a/dev/tools/gen_defaults/data/navigation_bar.json +++ b/dev/tools/gen_defaults/data/navigation_bar.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.navigation-bar.active.focus.icon.color": "onSecondaryContainer", "md.comp.navigation-bar.active.focus.label-text.color": "onSurface", diff --git a/dev/tools/gen_defaults/data/navigation_rail.json b/dev/tools/gen_defaults/data/navigation_rail.json index a9cb59e5ff..3aa4ace3aa 100644 --- a/dev/tools/gen_defaults/data/navigation_rail.json +++ b/dev/tools/gen_defaults/data/navigation_rail.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.navigation-rail.active.focus.icon.color": "onSecondaryContainer", "md.comp.navigation-rail.active.focus.label-text.color": "onSurface", diff --git a/dev/tools/gen_defaults/data/palette.json b/dev/tools/gen_defaults/data/palette.json index 7b11ea2bd4..d9fc41e0ba 100644 --- a/dev/tools/gen_defaults/data/palette.json +++ b/dev/tools/gen_defaults/data/palette.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.ref.palette.black": "0xFF000000", "md.ref.palette.error0": "0xFF000000", diff --git a/dev/tools/gen_defaults/data/shape.json b/dev/tools/gen_defaults/data/shape.json index 9521cf3e37..f8f3080c72 100644 --- a/dev/tools/gen_defaults/data/shape.json +++ b/dev/tools/gen_defaults/data/shape.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.shape.corner.extra-large": { "family": "SHAPE_FAMILY_ROUNDED_CORNERS", diff --git a/dev/tools/gen_defaults/data/slider.json b/dev/tools/gen_defaults/data/slider.json index c9acc4abaf..b976d0f492 100644 --- a/dev/tools/gen_defaults/data/slider.json +++ b/dev/tools/gen_defaults/data/slider.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.slider.active.track.color": "primary", "md.comp.slider.active.track.height": 6.0, diff --git a/dev/tools/gen_defaults/data/state.json b/dev/tools/gen_defaults/data/state.json index dcef3cf438..98d9b67276 100644 --- a/dev/tools/gen_defaults/data/state.json +++ b/dev/tools/gen_defaults/data/state.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.state.dragged.state-layer-opacity": 0.16, "md.sys.state.focus.state-layer-opacity": 0.12, diff --git a/dev/tools/gen_defaults/data/text_style.json b/dev/tools/gen_defaults/data/text_style.json index a8bb804a69..aaa0fe0d4b 100644 --- a/dev/tools/gen_defaults/data/text_style.json +++ b/dev/tools/gen_defaults/data/text_style.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.sys.typescale.body-large.font": "md.ref.typeface.plain", "md.sys.typescale.body-large.line-height": 24.0, diff --git a/dev/tools/gen_defaults/data/top_app_bar_large.json b/dev/tools/gen_defaults/data/top_app_bar_large.json index b4d8cf2886..29aa47318d 100644 --- a/dev/tools/gen_defaults/data/top_app_bar_large.json +++ b/dev/tools/gen_defaults/data/top_app_bar_large.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.top-app-bar.large.container.color": "surface", "md.comp.top-app-bar.large.container.elevation": "md.sys.elevation.level0", diff --git a/dev/tools/gen_defaults/data/top_app_bar_medium.json b/dev/tools/gen_defaults/data/top_app_bar_medium.json index 0819a66cf7..ad140cd837 100644 --- a/dev/tools/gen_defaults/data/top_app_bar_medium.json +++ b/dev/tools/gen_defaults/data/top_app_bar_medium.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.top-app-bar.medium.container.color": "surface", "md.comp.top-app-bar.medium.container.elevation": "md.sys.elevation.level0", diff --git a/dev/tools/gen_defaults/data/top_app_bar_small.json b/dev/tools/gen_defaults/data/top_app_bar_small.json index eb4ca9ab1e..3ddf1c3cf2 100644 --- a/dev/tools/gen_defaults/data/top_app_bar_small.json +++ b/dev/tools/gen_defaults/data/top_app_bar_small.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.comp.top-app-bar.small.container.color": "surface", "md.comp.top-app-bar.small.container.elevation": "md.sys.elevation.level0", diff --git a/dev/tools/gen_defaults/data/typeface.json b/dev/tools/gen_defaults/data/typeface.json index 65b433c804..d8b93cb6d6 100644 --- a/dev/tools/gen_defaults/data/typeface.json +++ b/dev/tools/gen_defaults/data/typeface.json @@ -1,5 +1,5 @@ { - "version": "v0_90", + "version": "v0_92", "md.ref.typeface.brand": "Roboto", "md.ref.typeface.plain": "Roboto", diff --git a/dev/tools/gen_defaults/lib/card_template.dart b/dev/tools/gen_defaults/lib/card_template.dart index 09f2284d85..b34b5517cf 100644 --- a/dev/tools/gen_defaults/lib/card_template.dart +++ b/dev/tools/gen_defaults/lib/card_template.dart @@ -22,13 +22,13 @@ class _TokenDefaultsM3 extends CardTheme { final BuildContext context; @override - Color? get color => Theme.of(context).colorScheme.${color("md.comp.elevated-card.container")}; + Color? get color => ${componentColor("md.comp.elevated-card.container")}; @override - Color? get shadowColor => Theme.of(context).colorScheme.${tokens["md.comp.elevated-card.container.shadow-color"]}; + Color? get shadowColor => ${color("md.comp.elevated-card.container.shadow-color")}; @override - Color? get surfaceTintColor => Theme.of(context).colorScheme.${tokens["md.comp.elevated-card.container.surface-tint-layer.color"]}; + Color? get surfaceTintColor => ${color("md.comp.elevated-card.container.surface-tint-layer.color")}; } '''; } diff --git a/dev/tools/gen_defaults/lib/dialog_template.dart b/dev/tools/gen_defaults/lib/dialog_template.dart index 68de194b28..acb67cf5fe 100644 --- a/dev/tools/gen_defaults/lib/dialog_template.dart +++ b/dev/tools/gen_defaults/lib/dialog_template.dart @@ -5,34 +5,36 @@ import 'template.dart'; class DialogTemplate extends TokenTemplate { - const DialogTemplate(String fileName, Map tokens) : super(fileName, tokens); + const DialogTemplate(String fileName, Map tokens) + : super(fileName, tokens, + colorSchemePrefix: '_colors.', + textThemePrefix: '_textTheme.' + ); @override String generate() => ''' // Generated version ${tokens["version"]} class _TokenDefaultsM3 extends DialogTheme { _TokenDefaultsM3(this.context) - : _colors = Theme.of(context).colorScheme, - _textTheme = Theme.of(context).textTheme, - super( + : super( alignment: Alignment.center, elevation: ${elevation("md.comp.dialog.container")}, shape: ${shape("md.comp.dialog.container")}, ); final BuildContext context; - final ColorScheme _colors; - final TextTheme _textTheme; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; // TODO(darrenaustin): overlay should be handled by Material widget: https://github.com/flutter/flutter/issues/9160 @override - Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.${color("md.comp.dialog.container")}, _colors.primary, ${elevation("md.comp.dialog.container")}); + Color? get backgroundColor => ElevationOverlay.colorWithOverlay(${componentColor("md.comp.dialog.container")}, _colors.primary, ${elevation("md.comp.dialog.container")}); @override - TextStyle? get titleTextStyle => _textTheme.${textStyle("md.comp.dialog.subhead")}; + TextStyle? get titleTextStyle => ${textStyle("md.comp.dialog.subhead")}; @override - TextStyle? get contentTextStyle => _textTheme.${textStyle("md.comp.dialog.supporting-text")}; + TextStyle? get contentTextStyle => ${textStyle("md.comp.dialog.supporting-text")}; } '''; } diff --git a/dev/tools/gen_defaults/lib/fab_template.dart b/dev/tools/gen_defaults/lib/fab_template.dart index 16b6de9eac..fea34dbab7 100644 --- a/dev/tools/gen_defaults/lib/fab_template.dart +++ b/dev/tools/gen_defaults/lib/fab_template.dart @@ -5,16 +5,18 @@ import 'template.dart'; class FABTemplate extends TokenTemplate { - const FABTemplate(String fileName, Map tokens) : super(fileName, tokens); + const FABTemplate(String fileName, Map tokens) + : super(fileName, tokens, + colorSchemePrefix: '_colors.', + textThemePrefix: '_textTheme.', + ); @override String generate() => ''' // Generated version ${tokens["version"]} class _M3Defaults extends FloatingActionButtonThemeData { _M3Defaults(this.context, this.type, this.hasChild) - : _colors = Theme.of(context).colorScheme, - _textTheme = Theme.of(context).textTheme, - super( + : super( elevation: ${elevation("md.comp.fab.primary.container")}, focusElevation: ${elevation("md.comp.fab.primary.focus.container")}, hoverElevation: ${elevation("md.comp.fab.primary.hover.container")}, @@ -41,16 +43,16 @@ class _M3Defaults extends FloatingActionButtonThemeData { final BuildContext context; final _FloatingActionButtonType type; final bool hasChild; - final ColorScheme _colors; - final TextTheme _textTheme; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; bool get _isExtended => type == _FloatingActionButtonType.extended; - @override Color? get foregroundColor => _colors.${color("md.comp.fab.primary.icon")}; - @override Color? get backgroundColor => _colors.${color("md.comp.fab.primary.container")}; - @override Color? get splashColor => _colors.${color("md.comp.fab.primary.pressed.state-layer")}; - @override Color? get focusColor => _colors.${color("md.comp.fab.primary.focus.state-layer")}; - @override Color? get hoverColor => _colors.${color("md.comp.fab.primary.hover.state-layer")}; + @override Color? get foregroundColor => ${componentColor("md.comp.fab.primary.icon")}; + @override Color? get backgroundColor => ${componentColor("md.comp.fab.primary.container")}; + @override Color? get splashColor => ${componentColor("md.comp.fab.primary.pressed.state-layer")}; + @override Color? get focusColor => ${componentColor("md.comp.fab.primary.focus.state-layer")}; + @override Color? get hoverColor => ${componentColor("md.comp.fab.primary.hover.state-layer")}; @override ShapeBorder? get shape { @@ -77,7 +79,7 @@ class _M3Defaults extends FloatingActionButtonThemeData { } @override EdgeInsetsGeometry? get extendedPadding => EdgeInsetsDirectional.only(start: hasChild && _isExtended ? 16.0 : 20.0, end: 20.0); - @override TextStyle? get extendedTextStyle => _textTheme.${textStyle("md.comp.extended-fab.primary.label-text")}; + @override TextStyle? get extendedTextStyle => ${textStyle("md.comp.extended-fab.primary.label-text")}; } '''; } diff --git a/dev/tools/gen_defaults/lib/navigation_bar_template.dart b/dev/tools/gen_defaults/lib/navigation_bar_template.dart index 9f538d6b61..2f9b3e8f9e 100644 --- a/dev/tools/gen_defaults/lib/navigation_bar_template.dart +++ b/dev/tools/gen_defaults/lib/navigation_bar_template.dart @@ -5,50 +5,53 @@ import 'template.dart'; class NavigationBarTemplate extends TokenTemplate { - const NavigationBarTemplate(String fileName, Map tokens) : super(fileName, tokens); + const NavigationBarTemplate(String fileName, Map tokens) + : super(fileName, tokens, + colorSchemePrefix: '_colors.', + textThemePrefix: '_textTheme.', + ); @override String generate() => ''' // Generated version ${tokens["version"]} class _TokenDefaultsM3 extends NavigationBarThemeData { - _TokenDefaultsM3(BuildContext context) - : _theme = Theme.of(context), - _colors = Theme.of(context).colorScheme, - super( + _TokenDefaultsM3(this.context) + : super( height: ${tokens["md.comp.navigation-bar.container.height"]}, elevation: ${elevation("md.comp.navigation-bar.container")}, labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, ); - final ThemeData _theme; - final ColorScheme _colors; + final BuildContext context; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; // With Material 3, the NavigationBar uses an overlay blend for the // default color regardless of light/dark mode. This should be handled // in the Material widget based off of elevation, but for now we will do // it here in the defaults. - @override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.${color("md.comp.navigation-bar.container")}, _colors.primary, ${elevation("md.comp.navigation-bar.container")}); + @override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(${componentColor("md.comp.navigation-bar.container")}, _colors.primary, ${elevation("md.comp.navigation-bar.container")}); @override MaterialStateProperty? get iconTheme { return MaterialStateProperty.resolveWith((Set states) { return IconThemeData( size: ${tokens["md.comp.navigation-bar.icon.size"]}, color: states.contains(MaterialState.selected) - ? _colors.${color("md.comp.navigation-bar.active.icon")} - : _colors.${color("md.comp.navigation-bar.inactive.icon")}, + ? ${componentColor("md.comp.navigation-bar.active.icon")} + : ${componentColor("md.comp.navigation-bar.inactive.icon")}, ); }); } - @override Color? get indicatorColor => _colors.${color("md.comp.navigation-bar.active-indicator")}; + @override Color? get indicatorColor => ${componentColor("md.comp.navigation-bar.active-indicator")}; @override ShapeBorder? get indicatorShape => ${shape("md.comp.navigation-bar.active-indicator")}; @override MaterialStateProperty? get labelTextStyle { return MaterialStateProperty.resolveWith((Set states) { - final TextStyle style = _theme.textTheme.${textStyle("md.comp.navigation-bar.label-text")}!; + final TextStyle style = ${textStyle("md.comp.navigation-bar.label-text")}!; return style.apply(color: states.contains(MaterialState.selected) - ? _colors.${color("md.comp.navigation-bar.active.label-text")} - : _colors.${color("md.comp.navigation-bar.inactive.label-text")} + ? ${componentColor("md.comp.navigation-bar.active.label-text")} + : ${componentColor("md.comp.navigation-bar.inactive.label-text")} ); }); } diff --git a/dev/tools/gen_defaults/lib/navigation_rail_template.dart b/dev/tools/gen_defaults/lib/navigation_rail_template.dart index 567fb55f54..d2ccc3ff28 100644 --- a/dev/tools/gen_defaults/lib/navigation_rail_template.dart +++ b/dev/tools/gen_defaults/lib/navigation_rail_template.dart @@ -5,16 +5,18 @@ import 'template.dart'; class NavigationRailTemplate extends TokenTemplate { - const NavigationRailTemplate(String fileName, Map tokens) : super(fileName, tokens); + const NavigationRailTemplate(String fileName, Map tokens) + : super(fileName, tokens, + colorSchemePrefix: '_colors.', + textThemePrefix: '_textTheme.', + ); @override String generate() => ''' // Generated version ${tokens["version"]} class _TokenDefaultsM3 extends NavigationRailThemeData { - _TokenDefaultsM3(BuildContext context) - : _theme = Theme.of(context), - _colors = Theme.of(context).colorScheme, - super( + _TokenDefaultsM3(this.context) + : super( elevation: ${elevation("md.comp.navigation-rail.container")}, groupAlignment: -1, labelType: NavigationRailLabelType.none, @@ -23,34 +25,35 @@ class _TokenDefaultsM3 extends NavigationRailThemeData { minExtendedWidth: 256, ); - final ThemeData _theme; - final ColorScheme _colors; + final BuildContext context; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; - @override Color? get backgroundColor => _colors.${color("md.comp.navigation-rail.container")}; + @override Color? get backgroundColor => ${componentColor("md.comp.navigation-rail.container")}; @override TextStyle? get unselectedLabelTextStyle { - return _theme.textTheme.${textStyle("md.comp.navigation-rail.label-text")}!.copyWith(color: _colors.${color("md.comp.navigation-rail.inactive.focus.label-text")}); + return ${textStyle("md.comp.navigation-rail.label-text")}!.copyWith(color: ${componentColor("md.comp.navigation-rail.inactive.focus.label-text")}); } @override TextStyle? get selectedLabelTextStyle { - return _theme.textTheme.${textStyle("md.comp.navigation-rail.label-text")}!.copyWith(color: _colors.${color("md.comp.navigation-rail.active.focus.label-text")}); + return ${textStyle("md.comp.navigation-rail.label-text")}!.copyWith(color: ${componentColor("md.comp.navigation-rail.active.focus.label-text")}); } @override IconThemeData? get unselectedIconTheme { return IconThemeData( size: ${tokens["md.comp.navigation-rail.icon.size"]}, - color: _colors.${color("md.comp.navigation-rail.inactive.icon")}, + color: ${componentColor("md.comp.navigation-rail.inactive.icon")}, ); } @override IconThemeData? get selectedIconTheme { return IconThemeData( size: ${tokens["md.comp.navigation-rail.icon.size"]}, - color: _colors.${color("md.comp.navigation-rail.active.icon")}, + color: ${componentColor("md.comp.navigation-rail.active.icon")}, ); } - @override Color? get indicatorColor => _colors.${color("md.comp.navigation-rail.active-indicator")}; + @override Color? get indicatorColor => ${componentColor("md.comp.navigation-rail.active-indicator")}; } '''; diff --git a/dev/tools/gen_defaults/lib/template.dart b/dev/tools/gen_defaults/lib/template.dart index 6ed992c512..f63bea0e35 100644 --- a/dev/tools/gen_defaults/lib/template.dart +++ b/dev/tools/gen_defaults/lib/template.dart @@ -5,7 +5,10 @@ import 'dart:io'; abstract class TokenTemplate { - const TokenTemplate(this.fileName, this.tokens); + const TokenTemplate(this.fileName, this.tokens, { + this.colorSchemePrefix = 'Theme.of(context).colorScheme.', + this.textThemePrefix = 'Theme.of(context).textTheme.' + }); static const String beginGeneratedComment = ''' @@ -27,6 +30,8 @@ abstract class TokenTemplate { final String fileName; final Map tokens; + final String colorSchemePrefix; + final String textThemePrefix; /// Replace or append the contents of the file with the text from [generate]. /// @@ -54,16 +59,44 @@ abstract class TokenTemplate { /// bottom of the file. String generate(); - /// Generate a [ColorScheme] color name for the given component token. + /// Generate a [ColorScheme] color name for the given token. /// - /// If there is an opacity specified for the given component, it will - /// apply that opacity to the component's color. - String color(String componentToken) { - final String tokenColor = '$componentToken.color'; + /// If there is a value for the given token, this will return + /// the value prepended with [colorSchemePrefix]. + /// + /// Otherwise it will return 'null'. + /// + /// See also: + /// * [componentColor], that provides support for an optional opacity. + String color(String colorToken) { + return tokens.containsKey(colorToken) + ? '$colorSchemePrefix${tokens[colorToken]}' + : 'null'; + } + + /// Generate a [ColorScheme] color name for the given component's color + /// with opacity if available. + /// + /// If there is a value for the given component's color, this will return + /// the value prepended with [colorSchemePrefix]. If there is also + /// an opacity specified for the component, then the returned value + /// will include this opacity calculation. + /// + /// If there is no value for the component's color, 'null' will be returned. + /// + /// See also: + /// * [color], that provides support for looking up a raw color token. + String componentColor(String componentToken) { + final String colorToken = '$componentToken.color'; + if (!tokens.containsKey(colorToken)) + return 'null'; + String value = color(colorToken); final String tokenOpacity = '$componentToken.opacity'; - String value = '${tokens[tokenColor]!}'; if (tokens.containsKey(tokenOpacity)) { - final String opacity = tokens[tokens[tokenOpacity]!]!.toString(); + final dynamic opacityValue = tokens[tokenOpacity]; + final String opacity = opacityValue is double + ? opacityValue.toString() + : tokens[tokens[tokenOpacity]!]!.toString(); value += '.withOpacity($opacity)'; } return value; @@ -96,8 +129,18 @@ abstract class TokenTemplate { return ''; } + /// Generate a [BorderSide] for the given component. + String border(String componentToken) { + if (!tokens.containsKey('$componentToken.color')) { + return 'null'; + } + final String borderColor = componentColor(componentToken); + final double width = tokens['$componentToken.width'] as double; + return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; + } + /// Generate a [TextTheme] text style name for the given component token. String textStyle(String componentToken) { - return tokens['$componentToken.text-style']!.toString(); + return '$textThemePrefix${tokens["$componentToken.text-style"]!.toString()}'; } } diff --git a/packages/flutter/lib/src/material/card.dart b/packages/flutter/lib/src/material/card.dart index 62afb9f775..32a3b715fc 100644 --- a/packages/flutter/lib/src/material/card.dart +++ b/packages/flutter/lib/src/material/card.dart @@ -212,7 +212,7 @@ class _DefaultsM2 extends CardTheme { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _TokenDefaultsM3 extends CardTheme { const _TokenDefaultsM3(this.context) : super( diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 9af6eaa08f..4b059780d5 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -1201,20 +1201,18 @@ class _DefaultsM2 extends DialogTheme { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _TokenDefaultsM3 extends DialogTheme { _TokenDefaultsM3(this.context) - : _colors = Theme.of(context).colorScheme, - _textTheme = Theme.of(context).textTheme, - super( + : super( alignment: Alignment.center, elevation: 6.0, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(28.0), topRight: Radius.circular(28.0), bottomLeft: Radius.circular(28.0), bottomRight: Radius.circular(28.0))), ); final BuildContext context; - final ColorScheme _colors; - final TextTheme _textTheme; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; // TODO(darrenaustin): overlay should be handled by Material widget: https://github.com/flutter/flutter/issues/9160 @override diff --git a/packages/flutter/lib/src/material/elevation_overlay.dart b/packages/flutter/lib/src/material/elevation_overlay.dart index 4876bf06d5..75457a511e 100644 --- a/packages/flutter/lib/src/material/elevation_overlay.dart +++ b/packages/flutter/lib/src/material/elevation_overlay.dart @@ -157,7 +157,7 @@ class _ElevationOpacity { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 // Surface tint opacities based on elevations according to the // Material Design 3 specification: diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index e4609f5e38..e6eab92249 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -773,12 +773,10 @@ class _M2Defaults extends FloatingActionButtonThemeData { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _M3Defaults extends FloatingActionButtonThemeData { _M3Defaults(this.context, this.type, this.hasChild) - : _colors = Theme.of(context).colorScheme, - _textTheme = Theme.of(context).textTheme, - super( + : super( elevation: 6.0, focusElevation: 6.0, hoverElevation: 8.0, @@ -805,8 +803,8 @@ class _M3Defaults extends FloatingActionButtonThemeData { final BuildContext context; final _FloatingActionButtonType type; final bool hasChild; - final ColorScheme _colors; - final TextTheme _textTheme; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; bool get _isExtended => type == _FloatingActionButtonType.extended; diff --git a/packages/flutter/lib/src/material/navigation_bar.dart b/packages/flutter/lib/src/material/navigation_bar.dart index aae46f138b..cc6a645b5f 100644 --- a/packages/flutter/lib/src/material/navigation_bar.dart +++ b/packages/flutter/lib/src/material/navigation_bar.dart @@ -12,6 +12,7 @@ import 'material.dart'; import 'material_localizations.dart'; import 'material_state.dart'; import 'navigation_bar_theme.dart'; +import 'text_theme.dart'; import 'theme.dart'; import 'tooltip.dart'; @@ -1216,19 +1217,18 @@ class _Defaults extends NavigationBarThemeData { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _TokenDefaultsM3 extends NavigationBarThemeData { - _TokenDefaultsM3(BuildContext context) - : _theme = Theme.of(context), - _colors = Theme.of(context).colorScheme, - super( + _TokenDefaultsM3(this.context) + : super( height: 80.0, elevation: 3.0, labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, ); - final ThemeData _theme; - final ColorScheme _colors; + final BuildContext context; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; // With Material 3, the NavigationBar uses an overlay blend for the // default color regardless of light/dark mode. This should be handled @@ -1252,7 +1252,7 @@ class _TokenDefaultsM3 extends NavigationBarThemeData { @override MaterialStateProperty? get labelTextStyle { return MaterialStateProperty.resolveWith((Set states) { - final TextStyle style = _theme.textTheme.labelMedium!; + final TextStyle style = _textTheme.labelMedium!; return style.apply(color: states.contains(MaterialState.selected) ? _colors.onSurface : _colors.onSurfaceVariant diff --git a/packages/flutter/lib/src/material/navigation_rail.dart b/packages/flutter/lib/src/material/navigation_rail.dart index c045c4d1b4..2d674869e3 100644 --- a/packages/flutter/lib/src/material/navigation_rail.dart +++ b/packages/flutter/lib/src/material/navigation_rail.dart @@ -12,6 +12,7 @@ import 'material.dart'; import 'material_localizations.dart'; import 'navigation_bar.dart'; import 'navigation_rail_theme.dart'; +import 'text_theme.dart'; import 'theme.dart'; /// A material widget that is meant to be displayed at the left or right of an @@ -951,12 +952,10 @@ class _DefaultsM2 extends NavigationRailThemeData { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _TokenDefaultsM3 extends NavigationRailThemeData { - _TokenDefaultsM3(BuildContext context) - : _theme = Theme.of(context), - _colors = Theme.of(context).colorScheme, - super( + _TokenDefaultsM3(this.context) + : super( elevation: 0.0, groupAlignment: -1, labelType: NavigationRailLabelType.none, @@ -965,17 +964,18 @@ class _TokenDefaultsM3 extends NavigationRailThemeData { minExtendedWidth: 256, ); - final ThemeData _theme; - final ColorScheme _colors; + final BuildContext context; + late final ColorScheme _colors = Theme.of(context).colorScheme; + late final TextTheme _textTheme = Theme.of(context).textTheme; @override Color? get backgroundColor => _colors.surface; @override TextStyle? get unselectedLabelTextStyle { - return _theme.textTheme.labelMedium!.copyWith(color: _colors.onSurface); + return _textTheme.labelMedium!.copyWith(color: _colors.onSurface); } @override TextStyle? get selectedLabelTextStyle { - return _theme.textTheme.labelMedium!.copyWith(color: _colors.onSurface); + return _textTheme.labelMedium!.copyWith(color: _colors.onSurface); } @override IconThemeData? get unselectedIconTheme { diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index 3c030bb644..35b91a9e5a 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -729,7 +729,7 @@ class Typography with Diagnosticable { // These defaults are generated from the Material Design Token // database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. -// Generated version v0_90 +// Generated version v0_92 class _M3Typography { _M3Typography._();