From 1a72596129330016735e793ae22663a1ad4f2348 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 10 Jul 2026 19:26:52 -0400 Subject: [PATCH 1/5] refactor: generate Mix styling layer with mix_generator Replace ~1,450 lines of hand-written Spec/Styler boilerplate (copyWith, lerp, resolve, merge, props, debugFillProperties) with mix_generator output, the same codegen Mix 2.x uses for its own specs. - Leaf specs (alert type, blockquote, checkbox, codeblock, list, table) are fully spec-driven: @MixableSpec generates the *Styler class. - Aggregators (slide, markdown_alert) nest same-package generated stylers, which @MixableField(setterType:) cannot reference during generation, so their stylers stay hand-written on the legacy @MixableStyler mixin path (fields + constructors only). - Canonical styler names follow the Mix idiom (*Styler); old *Style names remain as typedef aliases. - BREAKING: TextStyle-typed styler params are now TextStyleMix and gain Mix field-wise merge semantics. - Stylers gain generated fluent setters, field factories, and widget-state variant helpers (onHovered, onFocused, ...). - Drop vestigial custom_lint dev dep (no plugin configured; it pinned analyzer <9 and blocked mix_generator). - Changelog the MarkdownText* deprecation shipped in #97. Impacted packages: superdeck (styling, deck, markdown, tests), demo, playground, plugins/pdf (rename only), docs. Verified: melos run analyze (dart + DCM) green; superdeck 654 tests and pdf 27 tests pass incl. goldens; .g.dart output byte-identical when regenerated from a clean build cache. --- demo/lib/src/style.dart | 22 +- demo/lib/src/templates.dart | 6 +- docs/guides/markdown-authoring.mdx | 2 +- docs/guides/superdeck-overview.mdx | 8 +- docs/reference/deck-options.mdx | 20 +- .../stores/deck_customization_store.dart | 2 +- .../pdf/test/helpers/test_helpers.dart | 6 +- packages/superdeck/CHANGELOG.md | 16 + packages/superdeck/build.yaml | 39 ++ .../superdeck/lib/src/deck/deck_options.dart | 6 +- .../lib/src/deck/deck_options.mapper.dart | 24 +- .../lib/src/deck/slide_configuration.dart | 2 +- .../src/deck/slide_configuration.mapper.dart | 8 +- .../lib/src/deck/slide_template.dart | 6 +- .../lib/src/deck/slide_template.mapper.dart | 24 +- .../lib/src/deck/template_resolver.dart | 6 +- .../src/markdown/markdown_inline_spans.dart | 2 +- .../src/rendering/blocks/markdown_viewer.dart | 6 +- .../styling/components/markdown_alert.dart | 176 ++---- .../styling/components/markdown_alert.g.dart | 189 +++++++ .../components/markdown_alert_type.dart | 210 +------ .../components/markdown_alert_type.g.dart | 295 ++++++++++ .../components/markdown_blockquote.dart | 167 +----- .../components/markdown_blockquote.g.dart | 246 +++++++++ .../styling/components/markdown_checkbox.dart | 138 +---- .../components/markdown_checkbox.g.dart | 204 +++++++ .../components/markdown_codeblock.dart | 151 +---- .../components/markdown_codeblock.g.dart | 225 ++++++++ .../src/styling/components/markdown_list.dart | 180 +----- .../styling/components/markdown_list.g.dart | 262 +++++++++ .../styling/components/markdown_table.dart | 251 +-------- .../styling/components/markdown_table.g.dart | 366 ++++++++++++ .../lib/src/styling/components/slide.dart | 463 +++++----------- .../lib/src/styling/components/slide.g.dart | 519 ++++++++++++++++++ .../lib/src/styling/default_style.dart | 46 +- packages/superdeck/pubspec.yaml | 3 +- .../test/helpers/slide_test_harness.dart | 4 +- .../superdeck/test/helpers/test_helpers.dart | 6 +- .../src/builtins/dartpad_widget_test.dart | 2 +- .../src/builtins/webview_widget_test.dart | 4 +- .../thumbnail_capture_timing_test.dart | 6 +- .../test/src/deck/deck_options_test.dart | 14 +- .../slide_configuration_builder_test.dart | 18 +- .../src/deck/slide_configuration_test.dart | 8 +- .../test/src/deck/slide_template_test.dart | 38 +- .../test/src/deck/template_resolver_test.dart | 64 ++- .../builders/text_element_builder_test.dart | 2 +- .../text_element_builder_widget_test.dart | 2 +- .../markdown/image_cache_resolution_test.dart | 2 +- .../image_element_rendering_test.dart | 2 +- .../src/markdown/markdown_builders_test.dart | 2 +- .../test/src/rendering/block_widget_test.dart | 10 +- .../test/src/rendering/slide_view_test.dart | 4 +- .../thumbnail_integration_test.dart | 2 +- .../thumbnails/thumbnail_service_test.dart | 2 +- 55 files changed, 2851 insertions(+), 1637 deletions(-) create mode 100644 packages/superdeck/build.yaml create mode 100644 packages/superdeck/lib/src/styling/components/markdown_alert.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_alert_type.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_blockquote.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_checkbox.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_codeblock.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_list.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/markdown_table.g.dart create mode 100644 packages/superdeck/lib/src/styling/components/slide.g.dart diff --git a/demo/lib/src/style.dart b/demo/lib/src/style.dart index b8c31cd9..21473c58 100644 --- a/demo/lib/src/style.dart +++ b/demo/lib/src/style.dart @@ -5,8 +5,8 @@ import 'package:superdeck/superdeck.dart'; import 'google_font_helpers.dart'; -SlideStyle announcementStyle() { - return SlideStyle( +SlideStyler announcementStyle() { + return SlideStyler( h1: TextStyler().style( TextStyleMix( fontSize: 140, @@ -38,18 +38,20 @@ SlideStyle announcementStyle() { ); } -SlideStyle quoteStyle() { - return SlideStyle( +SlideStyler quoteStyle() { + return SlideStyler( h1: TextStyler().style( TextStyleMix( fontFamily: safeGoogleFontFamily(GoogleFonts.notoSerif), fontSize: 32, ), ), - blockquote: MarkdownBlockquoteStyle( - textStyle: safeGoogleFont( - () => GoogleFonts.notoSerif(fontSize: 32), - fallback: const TextStyle(fontSize: 32), + blockquote: MarkdownBlockquoteStyler( + textStyle: TextStyleMix.value( + safeGoogleFont( + () => GoogleFonts.notoSerif(fontSize: 32), + fallback: const TextStyle(fontSize: 32), + ), ), decoration: const BoxDecoration( border: Border(left: BorderSide(color: Colors.red, width: 4)), @@ -65,8 +67,8 @@ SlideStyle quoteStyle() { ); } -SlideStyle borderedStyle() { - return SlideStyle( +SlideStyler borderedStyle() { + return SlideStyler( modifier: WidgetModifierConfig( modifiers: [ BoxModifierMix( diff --git a/demo/lib/src/templates.dart b/demo/lib/src/templates.dart index 524dba50..ec395d81 100644 --- a/demo/lib/src/templates.dart +++ b/demo/lib/src/templates.dart @@ -8,7 +8,7 @@ import 'google_font_helpers.dart'; /// A corporate-style template with a branded header and subtle footer. SlideTemplate corporateTemplate() { return SlideTemplate( - baseStyle: SlideStyle( + baseStyle: SlideStyler( h1: TextStyler().style( TextStyleMix( fontFamily: safeGoogleFontFamily(GoogleFonts.poppins), @@ -31,7 +31,7 @@ SlideTemplate corporateTemplate() { ), ), styles: { - 'highlight': SlideStyle( + 'highlight': SlideStyler( h1: TextStyler().style( TextStyleMix( color: const Color(0xFF1A73E8), @@ -63,7 +63,7 @@ SlideTemplate corporateTemplate() { /// A minimal template with no chrome — just typography. SlideTemplate minimalTemplate() { return SlideTemplate( - baseStyle: SlideStyle( + baseStyle: SlideStyler( h1: TextStyler().style( TextStyleMix( fontFamily: safeGoogleFontFamily(GoogleFonts.notoSerif), diff --git a/docs/guides/markdown-authoring.mdx b/docs/guides/markdown-authoring.mdx index 1fbd7921..9dd9d7c4 100644 --- a/docs/guides/markdown-authoring.mdx +++ b/docs/guides/markdown-authoring.mdx @@ -234,7 +234,7 @@ Define styles in your app: ```dart DeckOptions( styles: { - 'recap': SlideStyle( + 'recap': SlideStyler( h1: TextStyler().style(TextStyleMix(fontSize: 64)), ), }, diff --git a/docs/guides/superdeck-overview.mdx b/docs/guides/superdeck-overview.mdx index 336385b2..6ddd3172 100644 --- a/docs/guides/superdeck-overview.mdx +++ b/docs/guides/superdeck-overview.mdx @@ -126,18 +126,18 @@ SuperDeck calls the `WidgetFactory` function with the block's arguments to rende ### Comprehensive styling API -Control every aspect of your presentation through the `SlideStyle` system: +Control every aspect of your presentation through the `SlideStyler` system: ```dart -final customStyle = SlideStyle( +final customStyle = SlideStyler( h1: TextStyler().style( TextStyleMix(fontSize: 48, color: Colors.purple), ), p: TextStyler().style( TextStyleMix(fontSize: 18, height: 1.5), ), - code: MarkdownCodeblockStyle( - textStyle: const TextStyle(fontFamily: 'Fira Code', color: Colors.white), + code: MarkdownCodeblockStyler( + textStyle: TextStyleMix(fontFamily: 'Fira Code', color: Colors.white), container: BoxStyler( decoration: BoxDecorationMix( color: const Color(0xFF1E1E1E), diff --git a/docs/reference/deck-options.mdx b/docs/reference/deck-options.mdx index d3abca04..4ebce1d7 100644 --- a/docs/reference/deck-options.mdx +++ b/docs/reference/deck-options.mdx @@ -11,8 +11,8 @@ description: Complete API reference for configuring SuperDeck presentations ```dart const DeckOptions({ - SlideStyle? baseStyle, - Map styles = const {}, + SlideStyler? baseStyle, + Map styles = const {}, Map widgets = const {}, SlideParts parts = const SlideParts(), bool debug = false, @@ -24,19 +24,19 @@ const DeckOptions({ ## Properties ### `baseStyle` -**Type:** `SlideStyle?` | **Default:** `null` +**Type:** `SlideStyler?` | **Default:** `null` Base style for all slides. ```dart DeckOptions( - baseStyle: SlideStyle(), + baseStyle: SlideStyler(), ) ``` #### Named widget block styles -Use `BlockVariant` in a `SlideStyle` stylesheet to target every named widget +Use `BlockVariant` in a `SlideStyler` stylesheet to target every named widget block with an exact, case-sensitive name. The selector applies to the block container and its complete widget subtree, so container spacing and descendant Mix styles resolve together. @@ -48,7 +48,7 @@ import 'package:superdeck/superdeck.dart'; const webviewBlock = BlockVariant('webview'); final options = DeckOptions( - baseStyle: SlideStyle( + baseStyle: SlideStyler( blockContainer: BoxStyler( padding: EdgeInsetsGeometryMix.all(40), ).variants([ @@ -86,7 +86,7 @@ normal and fullscreen WebView blocks; those two layouts cannot receive different rules based on `BlockVariant` alone. ### `styles` -**Type:** `Map` | **Default:** `{}` +**Type:** `Map` | **Default:** `{}` Named style variants for specific slides. @@ -96,7 +96,7 @@ and `DeckOptions.styles`. There is no separate `styles.yaml` file to load. ```dart DeckOptions( styles: { - 'title': SlideStyle(), + 'title': SlideStyler(), }, ) ``` @@ -197,7 +197,7 @@ DeckOptions( header: BrandHeader(), footer: BrandFooter(), ), - baseStyle: SlideStyle(), + baseStyle: SlideStyler(), ), }, ) @@ -302,5 +302,5 @@ class MyApp extends StatelessWidget { ### Development 1. Enable `debug: true` during development 2. Use `dart run superdeck_cli:main build --watch` in one terminal and `flutter run` in another -3. Version control your `SlideStyle` definitions alongside app code +3. Version control your `SlideStyler` definitions alongside app code 4. Document custom components diff --git a/packages/playground/lib/core/domain/stores/deck_customization_store.dart b/packages/playground/lib/core/domain/stores/deck_customization_store.dart index 5b428b62..453d7716 100644 --- a/packages/playground/lib/core/domain/stores/deck_customization_store.dart +++ b/packages/playground/lib/core/domain/stores/deck_customization_store.dart @@ -152,7 +152,7 @@ class DeckCustomizationStore extends ChangeNotifier { void _pushOptions() { _controller.options.value = DeckOptions( - baseStyle: SlideStyle( + baseStyle: SlideStyler( h1: _stylerFor(TextLevel.h1), h2: _stylerFor(TextLevel.h2), h3: _stylerFor(TextLevel.h3), diff --git a/packages/plugins/pdf/test/helpers/test_helpers.dart b/packages/plugins/pdf/test/helpers/test_helpers.dart index e80de594..898a7d8e 100644 --- a/packages/plugins/pdf/test/helpers/test_helpers.dart +++ b/packages/plugins/pdf/test/helpers/test_helpers.dart @@ -52,7 +52,7 @@ List createTestSlides(int count) { final slideKey = 'slide-$index'; return SlideConfiguration( slideIndex: index, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: slideKey, sections: [ @@ -80,7 +80,7 @@ List createTestSlidesPayload({List? slides}) { class SlideTestHarness { static SlideConfiguration createConfiguration( Slide slide, { - SlideStyle? style, + SlideStyler? style, Map widgets = const {}, bool debug = false, int slideIndex = 0, @@ -89,7 +89,7 @@ class SlideTestHarness { }) { return SlideConfiguration( slideIndex: slideIndex, - style: style ?? SlideStyle(), + style: style ?? SlideStyler(), slide: slide, thumbnailKey: 'test-thumbnail.png', debug: debug, diff --git a/packages/superdeck/CHANGELOG.md b/packages/superdeck/CHANGELOG.md index 1d3421a9..83d5f317 100644 --- a/packages/superdeck/CHANGELOG.md +++ b/packages/superdeck/CHANGELOG.md @@ -1,5 +1,21 @@ ## Unreleased +- **BREAKING**: Generate the Mix styling layer with `mix_generator` instead of + hand-writing it. Styler classes are now canonically named `*Styler` + (`SlideStyler`, `MarkdownAlertStyler`, ...) following the Mix 2.x convention; + the previous `*Style` names remain available as typedef aliases. +- **BREAKING**: Styler constructor parameters for `TextStyle`-typed fields now + take `TextStyleMix` (e.g. `SlideStyler(strong:)`, + `MarkdownCodeblockStyler(textStyle:)`). Wrap existing values with + `TextStyleMix.value(...)`. These fields also gain Mix merge semantics: + merging styles now combines text-style properties field-wise instead of + replacing the whole `TextStyle`. +- Stylers gain the full generated fluent API: per-field setter methods + (`SlideStyler().h1(...)`, `.strong(...)`), field factories, and widget-state + variant helpers (`onHovered`, `onFocused`, ...). +- Deprecate `MarkdownTextSpec`/`MarkdownTextStyle`: they are not wired into + rendering. Use `SlideStyler` / Mix `TextStyler` (`p`, `h1`–`h6`, `strong`, + `em`, `del`, `link`) instead. - Add `BlockVariant` for opt-in, name-based `WidgetBlock` styling in Dart stylesheets. - Render `@webview` blocks edge-to-edge (zero padding and margin) by default. diff --git a/packages/superdeck/build.yaml b/packages/superdeck/build.yaml new file mode 100644 index 00000000..c271c151 --- /dev/null +++ b/packages/superdeck/build.yaml @@ -0,0 +1,39 @@ +targets: + $default: + builders: + # Spec mixins (_$XSpec) for every annotated styling spec. + mix_generator:mix_generator: + enabled: true + generate_for: + - lib/src/styling/components/*.dart + # Full generated *Styler classes — LEAF specs only. A spec qualifies as a + # leaf when every nested StyleSpec field points at a mix built-in + # (TextSpec, BoxSpec, ...): @MixableField(setterType:) can only reference + # types that already resolve during generation, and same-package + # generated stylers never do (build phases hide later-phase outputs from + # the resolver), degrading silently to value semantics. Aggregators that + # nest SuperDeck's own specs (slide.dart, markdown_alert.dart) are + # excluded here and use hand-written stylers with the legacy mixin below. + mix_generator:spec_styler_generator: + enabled: true + generate_for: + - lib/src/styling/components/markdown_alert_type.dart + - lib/src/styling/components/markdown_blockquote.dart + - lib/src/styling/components/markdown_checkbox.dart + - lib/src/styling/components/markdown_codeblock.dart + - lib/src/styling/components/markdown_list.dart + - lib/src/styling/components/markdown_table.dart + # Legacy @MixableStyler mixins (_$XStyleMixin) for the hand-written + # aggregator stylers noted above. + mix_generator:styler_generator: + enabled: true + generate_for: + - lib/src/styling/components/slide.dart + - lib/src/styling/components/markdown_alert.dart + # Unused mix builders — keep them off superdeck sources. + mix_generator:mixable_generator: + enabled: false + mix_generator:mix_widget_generator: + enabled: false + mix_generator:modifier_generator: + enabled: false diff --git a/packages/superdeck/lib/src/deck/deck_options.dart b/packages/superdeck/lib/src/deck/deck_options.dart index 18e75840..6b12d6a1 100644 --- a/packages/superdeck/lib/src/deck/deck_options.dart +++ b/packages/superdeck/lib/src/deck/deck_options.dart @@ -10,8 +10,8 @@ part 'deck_options.mapper.dart'; @MappableClass() class DeckOptions with DeckOptionsMappable { - final SlideStyle? baseStyle; - final Map styles; + final SlideStyler? baseStyle; + final Map styles; final Map widgets; final SlideParts parts; final bool debug; @@ -27,7 +27,7 @@ class DeckOptions with DeckOptionsMappable { DeckOptions({ this.baseStyle, - Map styles = const {}, + Map styles = const {}, Map widgets = const {}, this.parts = const SlideParts(), this.debug = false, diff --git a/packages/superdeck/lib/src/deck/deck_options.mapper.dart b/packages/superdeck/lib/src/deck/deck_options.mapper.dart index 3548f179..7c073204 100644 --- a/packages/superdeck/lib/src/deck/deck_options.mapper.dart +++ b/packages/superdeck/lib/src/deck/deck_options.mapper.dart @@ -23,18 +23,18 @@ class DeckOptionsMapper extends ClassMapperBase { @override final String id = 'DeckOptions'; - static SlideStyle? _$baseStyle(DeckOptions v) => v.baseStyle; - static const Field _f$baseStyle = Field( + static SlideStyler? _$baseStyle(DeckOptions v) => v.baseStyle; + static const Field _f$baseStyle = Field( 'baseStyle', _$baseStyle, opt: true, ); - static Map _$styles(DeckOptions v) => v.styles; - static const Field> _f$styles = Field( + static Map _$styles(DeckOptions v) => v.styles; + static const Field> _f$styles = Field( 'styles', _$styles, opt: true, - def: const {}, + def: const {}, ); static Map)> _$widgets( DeckOptions v, @@ -164,8 +164,8 @@ abstract class DeckOptionsCopyWith<$R, $In extends DeckOptions, $Out> MapCopyWith< $R, String, - SlideStyle, - ObjectCopyWith<$R, SlideStyle, SlideStyle> + SlideStyler, + ObjectCopyWith<$R, SlideStyler, SlideStyler> > get styles; MapCopyWith< @@ -188,8 +188,8 @@ abstract class DeckOptionsCopyWith<$R, $In extends DeckOptions, $Out> get templates; SlideTemplateCopyWith<$R, SlideTemplate, SlideTemplate>? get defaultTemplate; $R call({ - SlideStyle? baseStyle, - Map? styles, + SlideStyler? baseStyle, + Map? styles, Map)>? widgets, SlideParts? parts, bool? debug, @@ -211,8 +211,8 @@ class _DeckOptionsCopyWithImpl<$R, $Out> MapCopyWith< $R, String, - SlideStyle, - ObjectCopyWith<$R, SlideStyle, SlideStyle> + SlideStyler, + ObjectCopyWith<$R, SlideStyler, SlideStyler> > get styles => MapCopyWith( $value.styles, @@ -254,7 +254,7 @@ class _DeckOptionsCopyWithImpl<$R, $Out> @override $R call({ Object? baseStyle = $none, - Map? styles, + Map? styles, Map)>? widgets, SlideParts? parts, bool? debug, diff --git a/packages/superdeck/lib/src/deck/slide_configuration.dart b/packages/superdeck/lib/src/deck/slide_configuration.dart index 6e862c7c..78f7b2ef 100644 --- a/packages/superdeck/lib/src/deck/slide_configuration.dart +++ b/packages/superdeck/lib/src/deck/slide_configuration.dart @@ -16,7 +16,7 @@ String buildThumbnailKey(String slideKey) { @MappableClass() class SlideConfiguration with SlideConfigurationMappable { final int slideIndex; - final SlideStyle style; + final SlideStyler style; final Slide slide; final bool debug; final SlideParts? parts; diff --git a/packages/superdeck/lib/src/deck/slide_configuration.mapper.dart b/packages/superdeck/lib/src/deck/slide_configuration.mapper.dart index 6f250c43..03009e83 100644 --- a/packages/superdeck/lib/src/deck/slide_configuration.mapper.dart +++ b/packages/superdeck/lib/src/deck/slide_configuration.mapper.dart @@ -28,8 +28,8 @@ class SlideConfigurationMapper extends ClassMapperBase { 'slideIndex', _$slideIndex, ); - static SlideStyle _$style(SlideConfiguration v) => v.style; - static const Field _f$style = Field( + static SlideStyler _$style(SlideConfiguration v) => v.style; + static const Field _f$style = Field( 'style', _$style, ); @@ -188,7 +188,7 @@ abstract class SlideConfigurationCopyWith< get widgets; $R call({ int? slideIndex, - SlideStyle? style, + SlideStyler? style, Slide? slide, bool? debug, SlideParts? parts, @@ -232,7 +232,7 @@ class _SlideConfigurationCopyWithImpl<$R, $Out> @override $R call({ int? slideIndex, - SlideStyle? style, + SlideStyler? style, Slide? slide, bool? debug, Object? parts = $none, diff --git a/packages/superdeck/lib/src/deck/slide_template.dart b/packages/superdeck/lib/src/deck/slide_template.dart index 8da2e574..b2884f98 100644 --- a/packages/superdeck/lib/src/deck/slide_template.dart +++ b/packages/superdeck/lib/src/deck/slide_template.dart @@ -16,15 +16,15 @@ final class SlideTemplate with SlideTemplateMappable { final SlideParts parts; /// Base style applied to all slides using this template. - final SlideStyle? baseStyle; + final SlideStyler? baseStyle; /// Named style variants available within this template. - final Map styles; + final Map styles; const SlideTemplate({ this.parts = const SlideParts(), this.baseStyle, - this.styles = const {}, + this.styles = const {}, }); @override diff --git a/packages/superdeck/lib/src/deck/slide_template.mapper.dart b/packages/superdeck/lib/src/deck/slide_template.mapper.dart index 9568e64d..9d9e2d16 100644 --- a/packages/superdeck/lib/src/deck/slide_template.mapper.dart +++ b/packages/superdeck/lib/src/deck/slide_template.mapper.dart @@ -29,18 +29,18 @@ class SlideTemplateMapper extends ClassMapperBase { opt: true, def: const SlideParts(), ); - static SlideStyle? _$baseStyle(SlideTemplate v) => v.baseStyle; - static const Field _f$baseStyle = Field( + static SlideStyler? _$baseStyle(SlideTemplate v) => v.baseStyle; + static const Field _f$baseStyle = Field( 'baseStyle', _$baseStyle, opt: true, ); - static Map _$styles(SlideTemplate v) => v.styles; - static const Field> _f$styles = Field( + static Map _$styles(SlideTemplate v) => v.styles; + static const Field> _f$styles = Field( 'styles', _$styles, opt: true, - def: const {}, + def: const {}, ); @override @@ -123,14 +123,14 @@ abstract class SlideTemplateCopyWith<$R, $In extends SlideTemplate, $Out> MapCopyWith< $R, String, - SlideStyle, - ObjectCopyWith<$R, SlideStyle, SlideStyle> + SlideStyler, + ObjectCopyWith<$R, SlideStyler, SlideStyler> > get styles; $R call({ SlideParts? parts, - SlideStyle? baseStyle, - Map? styles, + SlideStyler? baseStyle, + Map? styles, }); SlideTemplateCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); } @@ -147,8 +147,8 @@ class _SlideTemplateCopyWithImpl<$R, $Out> MapCopyWith< $R, String, - SlideStyle, - ObjectCopyWith<$R, SlideStyle, SlideStyle> + SlideStyler, + ObjectCopyWith<$R, SlideStyler, SlideStyler> > get styles => MapCopyWith( $value.styles, @@ -159,7 +159,7 @@ class _SlideTemplateCopyWithImpl<$R, $Out> $R call({ SlideParts? parts, Object? baseStyle = $none, - Map? styles, + Map? styles, }) => $apply( FieldCopyWithData({ if (parts != null) #parts: parts, diff --git a/packages/superdeck/lib/src/deck/template_resolver.dart b/packages/superdeck/lib/src/deck/template_resolver.dart index 445cf80c..848013c9 100644 --- a/packages/superdeck/lib/src/deck/template_resolver.dart +++ b/packages/superdeck/lib/src/deck/template_resolver.dart @@ -9,7 +9,7 @@ import 'slide_template.dart'; /// Result of resolving a slide's template and style configuration. class TemplateResolutionResult { /// The fully merged style for the slide. - final SlideStyle style; + final SlideStyler style; /// The chrome parts (header, footer, background) for the slide. final SlideParts parts; @@ -107,7 +107,7 @@ class TemplateResolver { String? styleName, SlideLayout? layout, ) { - SlideStyle? styleOverride; + SlideStyler? styleOverride; if (styleName != null) { styleOverride = template.styles[styleName]; if (styleOverride == null) { @@ -133,7 +133,7 @@ class TemplateResolver { String? styleName, SlideLayout? layout, ) { - SlideStyle? styleOverride; + SlideStyler? styleOverride; if (styleName != null) { styleOverride = _options.styles[styleName]; if (styleOverride == null) { diff --git a/packages/superdeck/lib/src/markdown/markdown_inline_spans.dart b/packages/superdeck/lib/src/markdown/markdown_inline_spans.dart index 217df8b6..930cb585 100644 --- a/packages/superdeck/lib/src/markdown/markdown_inline_spans.dart +++ b/packages/superdeck/lib/src/markdown/markdown_inline_spans.dart @@ -10,7 +10,7 @@ import '../styling/components/slide.dart'; /// Default inline styles applied when [SlideSpec] omits a field. /// /// Markdown semantics still need bold/italic/strike even without an explicit -/// [SlideStyle] override; user styles merge on top via [TextStyle.merge]. +/// [SlideStyler] override; user styles merge on top via [TextStyle.merge]. const TextStyle kDefaultStrongStyle = TextStyle(fontWeight: FontWeight.bold); const TextStyle kDefaultEmStyle = TextStyle(fontStyle: FontStyle.italic); const TextStyle kDefaultDelStyle = TextStyle( diff --git a/packages/superdeck/lib/src/rendering/blocks/markdown_viewer.dart b/packages/superdeck/lib/src/rendering/blocks/markdown_viewer.dart index 861287d2..a4c8f52d 100644 --- a/packages/superdeck/lib/src/rendering/blocks/markdown_viewer.dart +++ b/packages/superdeck/lib/src/rendering/blocks/markdown_viewer.dart @@ -7,7 +7,11 @@ import '../../markdown/markdown_element_builders_registry.dart'; import '../../styling/components/slide.dart'; import 'markdown_render_scope.dart'; -/// Tween for interpolating between SlideSpec values +/// Tween for interpolating between SlideSpec values. +/// +/// Deliberately not mix's `SpecTween`: that is a `Tween`, and +/// this widget's `forEachTween` path needs a non-nullable `SlideSpec` out of +/// `lerp` without null-coalescing at every evaluate site. class SlideSpecTween extends Tween { SlideSpecTween({super.begin, super.end}); diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert.dart b/packages/superdeck/lib/src/styling/components/markdown_alert.dart index 18f32da0..a480db23 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert.dart @@ -1,18 +1,35 @@ +// The styler below stays hand-written on the legacy @MixableStyler mixin +// path: its fields nest same-package generated stylers +// (MarkdownAlertTypeStyler), which @MixableSpec's spec_styler_generator can +// only wire up through @MixableField(setterType:) — and annotation type +// arguments cannot reference same-package generated classes (build phases +// hide them from the resolver, degrading silently to value semantics). +// ignore_for_file: deprecated_member_use + import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; import 'markdown_alert_type.dart'; +part 'markdown_alert.g.dart'; + /// Specification for markdown alert container with all alert types. /// /// Defines styling for different alert types: note, tip, important, warning, and caution. -final class MarkdownAlertSpec extends Spec - with Diagnosticable { +@MixableSpec() +@immutable +final class MarkdownAlertSpec with _$MarkdownAlertSpec { + @override final StyleSpec note; + @override final StyleSpec tip; + @override final StyleSpec important; + @override final StyleSpec warning; + @override final StyleSpec caution; const MarkdownAlertSpec({ @@ -26,66 +43,30 @@ final class MarkdownAlertSpec extends Spec important = important ?? const StyleSpec(spec: MarkdownAlertTypeSpec()), warning = warning ?? const StyleSpec(spec: MarkdownAlertTypeSpec()), caution = caution ?? const StyleSpec(spec: MarkdownAlertTypeSpec()); - - @override - MarkdownAlertSpec copyWith({ - StyleSpec? note, - StyleSpec? tip, - StyleSpec? important, - StyleSpec? warning, - StyleSpec? caution, - }) { - return MarkdownAlertSpec( - note: note ?? this.note, - tip: tip ?? this.tip, - important: important ?? this.important, - warning: warning ?? this.warning, - caution: caution ?? this.caution, - ); - } - - @override - MarkdownAlertSpec lerp(MarkdownAlertSpec? other, double t) { - if (other == null) return this; - - return MarkdownAlertSpec( - note: MixOps.lerp(note, other.note, t)!, - tip: MixOps.lerp(tip, other.tip, t)!, - important: MixOps.lerp(important, other.important, t)!, - warning: MixOps.lerp(warning, other.warning, t)!, - caution: MixOps.lerp(caution, other.caution, t)!, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('note', note)) - ..add(DiagnosticsProperty('tip', tip)) - ..add(DiagnosticsProperty('important', important)) - ..add(DiagnosticsProperty('warning', warning)) - ..add(DiagnosticsProperty('caution', caution)); - } - - @override - List get props => [note, tip, important, warning, caution]; } /// Style class for configuring [MarkdownAlertSpec] properties. -final class MarkdownAlertStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { +@MixableStyler() +final class MarkdownAlertStyler + extends MixStyler + with _$MarkdownAlertStylerMixin { + @override + @MixableField(ignoreSetter: true) final Prop>? $note; + @override + @MixableField(ignoreSetter: true) final Prop>? $tip; + @override + @MixableField(ignoreSetter: true) final Prop>? $important; + @override + @MixableField(ignoreSetter: true) final Prop>? $warning; + @override + @MixableField(ignoreSetter: true) final Prop>? $caution; - const MarkdownAlertStyle.create({ + const MarkdownAlertStyler.create({ Prop>? note, Prop>? tip, Prop>? important, @@ -100,12 +81,12 @@ final class MarkdownAlertStyle extends Style $warning = warning, $caution = caution; - MarkdownAlertStyle({ - MarkdownAlertTypeStyle? note, - MarkdownAlertTypeStyle? tip, - MarkdownAlertTypeStyle? important, - MarkdownAlertTypeStyle? warning, - MarkdownAlertTypeStyle? caution, + MarkdownAlertStyler({ + MarkdownAlertTypeStyler? note, + MarkdownAlertTypeStyler? tip, + MarkdownAlertTypeStyler? important, + MarkdownAlertTypeStyler? warning, + MarkdownAlertTypeStyler? caution, AnimationConfig? animation, List>? variants, WidgetModifierConfig? modifier, @@ -120,72 +101,31 @@ final class MarkdownAlertStyle extends Style modifier: modifier, ); - @override - MarkdownAlertStyle variants(List> value) { - return merge(MarkdownAlertStyle(variants: value)); - } - - @override - MarkdownAlertStyle animate(AnimationConfig value) { - return merge(MarkdownAlertStyle(animation: value)); + /// Sets the note alert style. + MarkdownAlertStyler note(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(note: value)); } - @override - MarkdownAlertStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownAlertStyle(modifier: value)); + /// Sets the tip alert style. + MarkdownAlertStyler tip(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(tip: value)); } - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownAlertSpec( - note: MixOps.resolve(context, $note), - tip: MixOps.resolve(context, $tip), - important: MixOps.resolve(context, $important), - warning: MixOps.resolve(context, $warning), - caution: MixOps.resolve(context, $caution), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); + /// Sets the important alert style. + MarkdownAlertStyler important(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(important: value)); } - @override - MarkdownAlertStyle merge(MarkdownAlertStyle? other) { - if (other == null) return this; - - return MarkdownAlertStyle.create( - note: MixOps.merge($note, other.$note), - tip: MixOps.merge($tip, other.$tip), - important: MixOps.merge($important, other.$important), - warning: MixOps.merge($warning, other.$warning), - caution: MixOps.merge($caution, other.$caution), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); + /// Sets the warning alert style. + MarkdownAlertStyler warning(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(warning: value)); } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('note', $note)) - ..add(DiagnosticsProperty('tip', $tip)) - ..add(DiagnosticsProperty('important', $important)) - ..add(DiagnosticsProperty('warning', $warning)) - ..add(DiagnosticsProperty('caution', $caution)); + /// Sets the caution alert style. + MarkdownAlertStyler caution(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(caution: value)); } - - @override - List get props => [ - $note, - $tip, - $important, - $warning, - $caution, - $animation, - $variants, - $modifier, - ]; } + +/// Legacy alias for [MarkdownAlertStyler] (the pre-codegen class name). +typedef MarkdownAlertStyle = MarkdownAlertStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart b/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart new file mode 100644 index 00000000..5819aee9 --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart @@ -0,0 +1,189 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_alert.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownAlertSpec implements Spec, Diagnosticable { + StyleSpec get note; + StyleSpec get tip; + StyleSpec get important; + StyleSpec get warning; + StyleSpec get caution; + + @override + Type get type => MarkdownAlertSpec; + + @override + MarkdownAlertSpec copyWith({ + StyleSpec? note, + StyleSpec? tip, + StyleSpec? important, + StyleSpec? warning, + StyleSpec? caution, + }) { + return MarkdownAlertSpec( + note: note ?? this.note, + tip: tip ?? this.tip, + important: important ?? this.important, + warning: warning ?? this.warning, + caution: caution ?? this.caution, + ); + } + + @override + MarkdownAlertSpec lerp(MarkdownAlertSpec? other, double t) { + return MarkdownAlertSpec( + note: note.lerp(other?.note, t), + tip: tip.lerp(other?.tip, t), + important: important.lerp(other?.important, t), + warning: warning.lerp(other?.warning, t), + caution: caution.lerp(other?.caution, t), + ); + } + + @override + List get props => [note, tip, important, warning, caution]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownAlertSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('note', note)) + ..add(DiagnosticsProperty('tip', tip)) + ..add(DiagnosticsProperty('important', important)) + ..add(DiagnosticsProperty('warning', warning)) + ..add(DiagnosticsProperty('caution', caution)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownAlertSpec` and migrate the class declaration to `class MarkdownAlertSpec with _\$MarkdownAlertSpec`. The `_\$MarkdownAlertSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownAlertSpecMethods = _$MarkdownAlertSpec; // ignore: unused_element + +// ************************************************************************** +// StylerGenerator +// ************************************************************************** + +mixin _$MarkdownAlertStylerMixin on Style, Diagnosticable { + Prop>? get $note; + Prop>? get $tip; + Prop>? get $important; + Prop>? get $warning; + Prop>? get $caution; + + /// Sets the animation configuration. + MarkdownAlertStyler animate(AnimationConfig value) { + return merge(MarkdownAlertStyler(animation: value)); + } + + /// Sets the style variants. + MarkdownAlertStyler variants(List> value) { + return merge(MarkdownAlertStyler(variants: value)); + } + + /// Wraps with a widget modifier. + MarkdownAlertStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownAlertStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownAlertStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownAlertStyler(modifier: value)); + } + + /// Merges with another [MarkdownAlertStyler]. + @override + MarkdownAlertStyler merge(MarkdownAlertStyler? other) { + return MarkdownAlertStyler.create( + note: MixOps.merge($note, other?.$note), + tip: MixOps.merge($tip, other?.$tip), + important: MixOps.merge($important, other?.$important), + warning: MixOps.merge($warning, other?.$warning), + caution: MixOps.merge($caution, other?.$caution), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownAlertSpec( + note: MixOps.resolve(context, $note), + tip: MixOps.resolve(context, $tip), + important: MixOps.resolve(context, $important), + warning: MixOps.resolve(context, $warning), + caution: MixOps.resolve(context, $caution), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('note', $note)) + ..add(DiagnosticsProperty('tip', $tip)) + ..add(DiagnosticsProperty('important', $important)) + ..add(DiagnosticsProperty('warning', $warning)) + ..add(DiagnosticsProperty('caution', $caution)); + } + + @override + List get props => [ + $note, + $tip, + $important, + $warning, + $caution, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart index d632be2a..5a9d4696 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart @@ -1,18 +1,39 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_alert_type.g.dart'; /// Specification for individual markdown alert type styling. /// /// Defines the complete styling for a single alert type (note, tip, important, etc.) /// including heading, description, icon, container, and flex layout properties. -final class MarkdownAlertTypeSpec extends Spec - with Diagnosticable { +@MixableSpec() +@immutable +final class MarkdownAlertTypeSpec with _$MarkdownAlertTypeSpec { + @override + @MixableField(setterType: TextStyler) final StyleSpec heading; + + @override + @MixableField(setterType: TextStyler) final StyleSpec description; + + @override + @MixableField(setterType: IconStyler) final StyleSpec icon; + + @override + @MixableField(setterType: BoxStyler) final StyleSpec container; + + @override + @MixableField(setterType: FlexBoxStyler) final StyleSpec containerFlex; + + @override + @MixableField(setterType: FlexBoxStyler) final StyleSpec headingFlex; const MarkdownAlertTypeSpec({ @@ -28,188 +49,7 @@ final class MarkdownAlertTypeSpec extends Spec container = container ?? const StyleSpec(spec: BoxSpec()), containerFlex = containerFlex ?? const StyleSpec(spec: FlexBoxSpec()), headingFlex = headingFlex ?? const StyleSpec(spec: FlexBoxSpec()); - - @override - MarkdownAlertTypeSpec copyWith({ - StyleSpec? heading, - StyleSpec? description, - StyleSpec? icon, - StyleSpec? container, - StyleSpec? containerFlex, - StyleSpec? headingFlex, - }) { - return MarkdownAlertTypeSpec( - heading: heading ?? this.heading, - description: description ?? this.description, - icon: icon ?? this.icon, - container: container ?? this.container, - containerFlex: containerFlex ?? this.containerFlex, - headingFlex: headingFlex ?? this.headingFlex, - ); - } - - @override - MarkdownAlertTypeSpec lerp(MarkdownAlertTypeSpec? other, double t) { - if (other == null) return this; - - return MarkdownAlertTypeSpec( - heading: MixOps.lerp(heading, other.heading, t)!, - description: MixOps.lerp(description, other.description, t)!, - icon: MixOps.lerp(icon, other.icon, t)!, - container: MixOps.lerp(container, other.container, t)!, - containerFlex: MixOps.lerp(containerFlex, other.containerFlex, t)!, - headingFlex: MixOps.lerp(headingFlex, other.headingFlex, t)!, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('heading', heading)) - ..add(DiagnosticsProperty('description', description)) - ..add(DiagnosticsProperty('icon', icon)) - ..add(DiagnosticsProperty('container', container)) - ..add(DiagnosticsProperty('containerFlex', containerFlex)) - ..add(DiagnosticsProperty('headingFlex', headingFlex)); - } - - @override - List get props => [ - heading, - description, - icon, - container, - containerFlex, - headingFlex, - ]; } -/// Style class for configuring [MarkdownAlertTypeSpec] properties. -final class MarkdownAlertTypeStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop>? $heading; - final Prop>? $description; - final Prop>? $icon; - final Prop>? $container; - final Prop>? $containerFlex; - final Prop>? $headingFlex; - - const MarkdownAlertTypeStyle.create({ - Prop>? heading, - Prop>? description, - Prop>? icon, - Prop>? container, - Prop>? containerFlex, - Prop>? headingFlex, - required super.variants, - required super.animation, - required super.modifier, - }) : $heading = heading, - $description = description, - $icon = icon, - $container = container, - $containerFlex = containerFlex, - $headingFlex = headingFlex; - - MarkdownAlertTypeStyle({ - TextStyler? heading, - TextStyler? description, - IconStyler? icon, - BoxStyler? container, - FlexBoxStyler? containerFlex, - FlexBoxStyler? headingFlex, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - heading: Prop.maybeMix(heading), - description: Prop.maybeMix(description), - icon: Prop.maybeMix(icon), - container: Prop.maybeMix(container), - containerFlex: Prop.maybeMix(containerFlex), - headingFlex: Prop.maybeMix(headingFlex), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownAlertTypeStyle variants( - List> value, - ) { - return merge(MarkdownAlertTypeStyle(variants: value)); - } - - @override - MarkdownAlertTypeStyle animate(AnimationConfig value) { - return merge(MarkdownAlertTypeStyle(animation: value)); - } - - @override - MarkdownAlertTypeStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownAlertTypeStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownAlertTypeSpec( - heading: MixOps.resolve(context, $heading), - description: MixOps.resolve(context, $description), - icon: MixOps.resolve(context, $icon), - container: MixOps.resolve(context, $container), - containerFlex: MixOps.resolve(context, $containerFlex), - headingFlex: MixOps.resolve(context, $headingFlex), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownAlertTypeStyle merge(MarkdownAlertTypeStyle? other) { - if (other == null) return this; - - return MarkdownAlertTypeStyle.create( - heading: MixOps.merge($heading, other.$heading), - description: MixOps.merge($description, other.$description), - icon: MixOps.merge($icon, other.$icon), - container: MixOps.merge($container, other.$container), - containerFlex: MixOps.merge($containerFlex, other.$containerFlex), - headingFlex: MixOps.merge($headingFlex, other.$headingFlex), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('heading', $heading)) - ..add(DiagnosticsProperty('description', $description)) - ..add(DiagnosticsProperty('icon', $icon)) - ..add(DiagnosticsProperty('container', $container)) - ..add(DiagnosticsProperty('containerFlex', $containerFlex)) - ..add(DiagnosticsProperty('headingFlex', $headingFlex)); - } - - @override - List get props => [ - $heading, - $description, - $icon, - $container, - $containerFlex, - $headingFlex, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownAlertTypeStyler] (the pre-codegen class name). +typedef MarkdownAlertTypeStyle = MarkdownAlertTypeStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert_type.g.dart b/packages/superdeck/lib/src/styling/components/markdown_alert_type.g.dart new file mode 100644 index 00000000..28af380a --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_alert_type.g.dart @@ -0,0 +1,295 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_alert_type.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownAlertTypeSpec + implements Spec, Diagnosticable { + StyleSpec get heading; + StyleSpec get description; + StyleSpec get icon; + StyleSpec get container; + StyleSpec get containerFlex; + StyleSpec get headingFlex; + + @override + Type get type => MarkdownAlertTypeSpec; + + @override + MarkdownAlertTypeSpec copyWith({ + StyleSpec? heading, + StyleSpec? description, + StyleSpec? icon, + StyleSpec? container, + StyleSpec? containerFlex, + StyleSpec? headingFlex, + }) { + return MarkdownAlertTypeSpec( + heading: heading ?? this.heading, + description: description ?? this.description, + icon: icon ?? this.icon, + container: container ?? this.container, + containerFlex: containerFlex ?? this.containerFlex, + headingFlex: headingFlex ?? this.headingFlex, + ); + } + + @override + MarkdownAlertTypeSpec lerp(MarkdownAlertTypeSpec? other, double t) { + return MarkdownAlertTypeSpec( + heading: heading.lerp(other?.heading, t), + description: description.lerp(other?.description, t), + icon: icon.lerp(other?.icon, t), + container: container.lerp(other?.container, t), + containerFlex: containerFlex.lerp(other?.containerFlex, t), + headingFlex: headingFlex.lerp(other?.headingFlex, t), + ); + } + + @override + List get props => [ + heading, + description, + icon, + container, + containerFlex, + headingFlex, + ]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownAlertTypeSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('heading', heading)) + ..add(DiagnosticsProperty('description', description)) + ..add(DiagnosticsProperty('icon', icon)) + ..add(DiagnosticsProperty('container', container)) + ..add(DiagnosticsProperty('containerFlex', containerFlex)) + ..add(DiagnosticsProperty('headingFlex', headingFlex)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownAlertTypeSpec` and migrate the class declaration to `class MarkdownAlertTypeSpec with _\$MarkdownAlertTypeSpec`. The `_\$MarkdownAlertTypeSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownAlertTypeSpecMethods = _$MarkdownAlertTypeSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownAlertTypeStyler + extends MixStyler { + final Prop>? $heading; + final Prop>? $description; + final Prop>? $icon; + final Prop>? $container; + final Prop>? $containerFlex; + final Prop>? $headingFlex; + + const MarkdownAlertTypeStyler.create({ + Prop>? heading, + Prop>? description, + Prop>? icon, + Prop>? container, + Prop>? containerFlex, + Prop>? headingFlex, + super.variants, + super.modifier, + super.animation, + }) : $heading = heading, + $description = description, + $icon = icon, + $container = container, + $containerFlex = containerFlex, + $headingFlex = headingFlex; + + MarkdownAlertTypeStyler({ + TextStyler? heading, + TextStyler? description, + IconStyler? icon, + BoxStyler? container, + FlexBoxStyler? containerFlex, + FlexBoxStyler? headingFlex, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + heading: Prop.maybeMix(heading), + description: Prop.maybeMix(description), + icon: Prop.maybeMix(icon), + container: Prop.maybeMix(container), + containerFlex: Prop.maybeMix(containerFlex), + headingFlex: Prop.maybeMix(headingFlex), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownAlertTypeStyler.heading(TextStyler value) => + MarkdownAlertTypeStyler().heading(value); + factory MarkdownAlertTypeStyler.description(TextStyler value) => + MarkdownAlertTypeStyler().description(value); + factory MarkdownAlertTypeStyler.icon(IconStyler value) => + MarkdownAlertTypeStyler().icon(value); + factory MarkdownAlertTypeStyler.container(BoxStyler value) => + MarkdownAlertTypeStyler().container(value); + factory MarkdownAlertTypeStyler.containerFlex(FlexBoxStyler value) => + MarkdownAlertTypeStyler().containerFlex(value); + factory MarkdownAlertTypeStyler.headingFlex(FlexBoxStyler value) => + MarkdownAlertTypeStyler().headingFlex(value); + + /// Sets the heading. + MarkdownAlertTypeStyler heading(TextStyler value) { + return merge(MarkdownAlertTypeStyler(heading: value)); + } + + /// Sets the description. + MarkdownAlertTypeStyler description(TextStyler value) { + return merge(MarkdownAlertTypeStyler(description: value)); + } + + /// Sets the icon. + MarkdownAlertTypeStyler icon(IconStyler value) { + return merge(MarkdownAlertTypeStyler(icon: value)); + } + + /// Sets the container. + MarkdownAlertTypeStyler container(BoxStyler value) { + return merge(MarkdownAlertTypeStyler(container: value)); + } + + /// Sets the containerFlex. + MarkdownAlertTypeStyler containerFlex(FlexBoxStyler value) { + return merge(MarkdownAlertTypeStyler(containerFlex: value)); + } + + /// Sets the headingFlex. + MarkdownAlertTypeStyler headingFlex(FlexBoxStyler value) { + return merge(MarkdownAlertTypeStyler(headingFlex: value)); + } + + /// Sets the animation configuration. + @override + MarkdownAlertTypeStyler animate(AnimationConfig value) { + return merge(MarkdownAlertTypeStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownAlertTypeStyler variants( + List> value, + ) { + return merge(MarkdownAlertTypeStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownAlertTypeStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownAlertTypeStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownAlertTypeStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownAlertTypeStyler(modifier: value)); + } + + /// Merges with another [MarkdownAlertTypeStyler]. + @override + MarkdownAlertTypeStyler merge(MarkdownAlertTypeStyler? other) { + return MarkdownAlertTypeStyler.create( + heading: MixOps.merge($heading, other?.$heading), + description: MixOps.merge($description, other?.$description), + icon: MixOps.merge($icon, other?.$icon), + container: MixOps.merge($container, other?.$container), + containerFlex: MixOps.merge($containerFlex, other?.$containerFlex), + headingFlex: MixOps.merge($headingFlex, other?.$headingFlex), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownAlertTypeSpec( + heading: MixOps.resolve(context, $heading), + description: MixOps.resolve(context, $description), + icon: MixOps.resolve(context, $icon), + container: MixOps.resolve(context, $container), + containerFlex: MixOps.resolve(context, $containerFlex), + headingFlex: MixOps.resolve(context, $headingFlex), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('heading', $heading)) + ..add(DiagnosticsProperty('description', $description)) + ..add(DiagnosticsProperty('icon', $icon)) + ..add(DiagnosticsProperty('container', $container)) + ..add(DiagnosticsProperty('containerFlex', $containerFlex)) + ..add(DiagnosticsProperty('headingFlex', $headingFlex)); + } + + @override + List get props => [ + $heading, + $description, + $icon, + $container, + $containerFlex, + $headingFlex, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart b/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart index 518e6a99..9c309d8b 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart @@ -1,16 +1,24 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_blockquote.g.dart'; /// Specification for markdown blockquote styling properties. /// /// Defines styling for blockquotes including text style, padding, /// decoration, and alignment. -final class MarkdownBlockquoteSpec extends Spec - with Diagnosticable { +@MixableSpec() +@immutable +final class MarkdownBlockquoteSpec with _$MarkdownBlockquoteSpec { + @override final TextStyle? textStyle; + @override final EdgeInsets? padding; + @override final BoxDecoration? decoration; + @override final WrapAlignment? alignment; const MarkdownBlockquoteSpec({ @@ -19,158 +27,7 @@ final class MarkdownBlockquoteSpec extends Spec this.decoration, this.alignment, }); - - @override - MarkdownBlockquoteSpec copyWith({ - TextStyle? textStyle, - EdgeInsets? padding, - BoxDecoration? decoration, - WrapAlignment? alignment, - }) { - return MarkdownBlockquoteSpec( - textStyle: textStyle ?? this.textStyle, - padding: padding ?? this.padding, - decoration: decoration ?? this.decoration, - alignment: alignment ?? this.alignment, - ); - } - - @override - MarkdownBlockquoteSpec lerp(MarkdownBlockquoteSpec? other, double t) { - if (other == null) return this; - - return MarkdownBlockquoteSpec( - textStyle: TextStyle.lerp(textStyle, other.textStyle, t), - padding: EdgeInsets.lerp(padding, other.padding, t), - decoration: BoxDecoration.lerp(decoration, other.decoration, t), - alignment: t < 0.5 ? alignment : other.alignment, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', textStyle)) - ..add(DiagnosticsProperty('padding', padding)) - ..add(DiagnosticsProperty('decoration', decoration)) - ..add(EnumProperty('alignment', alignment)); - } - - @override - List get props => [textStyle, padding, decoration, alignment]; } -/// Style class for configuring [MarkdownBlockquoteSpec] properties. -final class MarkdownBlockquoteStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin< - MarkdownBlockquoteStyle, - MarkdownBlockquoteSpec - >, - VariantStyleMixin, - AnimationStyleMixin { - final Prop? $textStyle; - final Prop? $padding; - final Prop? $decoration; - final Prop? $alignment; - - const MarkdownBlockquoteStyle.create({ - Prop? textStyle, - Prop? padding, - Prop? decoration, - Prop? alignment, - required super.variants, - required super.animation, - required super.modifier, - }) : $textStyle = textStyle, - $padding = padding, - $decoration = decoration, - $alignment = alignment; - - MarkdownBlockquoteStyle({ - TextStyle? textStyle, - EdgeInsets? padding, - BoxDecoration? decoration, - WrapAlignment? alignment, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - textStyle: Prop.maybe(textStyle), - padding: Prop.maybe(padding), - decoration: Prop.maybe(decoration), - alignment: Prop.maybe(alignment), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownBlockquoteStyle variants( - List> value, - ) { - return merge(MarkdownBlockquoteStyle(variants: value)); - } - - @override - MarkdownBlockquoteStyle animate(AnimationConfig value) { - return merge(MarkdownBlockquoteStyle(animation: value)); - } - - @override - MarkdownBlockquoteStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownBlockquoteStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownBlockquoteSpec( - textStyle: MixOps.resolve(context, $textStyle), - padding: MixOps.resolve(context, $padding), - decoration: MixOps.resolve(context, $decoration), - alignment: MixOps.resolve(context, $alignment), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownBlockquoteStyle merge(MarkdownBlockquoteStyle? other) { - if (other == null) return this; - - return MarkdownBlockquoteStyle.create( - textStyle: MixOps.merge($textStyle, other.$textStyle), - padding: MixOps.merge($padding, other.$padding), - decoration: MixOps.merge($decoration, other.$decoration), - alignment: MixOps.merge($alignment, other.$alignment), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', $textStyle)) - ..add(DiagnosticsProperty('padding', $padding)) - ..add(DiagnosticsProperty('decoration', $decoration)) - ..add(DiagnosticsProperty('alignment', $alignment)); - } - - @override - List get props => [ - $textStyle, - $padding, - $decoration, - $alignment, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownBlockquoteStyler] (the pre-codegen class name). +typedef MarkdownBlockquoteStyle = MarkdownBlockquoteStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_blockquote.g.dart b/packages/superdeck/lib/src/styling/components/markdown_blockquote.g.dart new file mode 100644 index 00000000..dae072f9 --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_blockquote.g.dart @@ -0,0 +1,246 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_blockquote.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownBlockquoteSpec + implements Spec, Diagnosticable { + TextStyle? get textStyle; + EdgeInsets? get padding; + BoxDecoration? get decoration; + WrapAlignment? get alignment; + + @override + Type get type => MarkdownBlockquoteSpec; + + @override + MarkdownBlockquoteSpec copyWith({ + TextStyle? textStyle, + EdgeInsets? padding, + BoxDecoration? decoration, + WrapAlignment? alignment, + }) { + return MarkdownBlockquoteSpec( + textStyle: textStyle ?? this.textStyle, + padding: padding ?? this.padding, + decoration: decoration ?? this.decoration, + alignment: alignment ?? this.alignment, + ); + } + + @override + MarkdownBlockquoteSpec lerp(MarkdownBlockquoteSpec? other, double t) { + return MarkdownBlockquoteSpec( + textStyle: MixOps.lerp(textStyle, other?.textStyle, t), + padding: MixOps.lerp(padding, other?.padding, t), + decoration: MixOps.lerp(decoration, other?.decoration, t), + alignment: MixOps.lerpSnap(alignment, other?.alignment, t), + ); + } + + @override + List get props => [textStyle, padding, decoration, alignment]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownBlockquoteSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('textStyle', textStyle)) + ..add(DiagnosticsProperty('padding', padding)) + ..add(DiagnosticsProperty('decoration', decoration)) + ..add(DiagnosticsProperty('alignment', alignment)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownBlockquoteSpec` and migrate the class declaration to `class MarkdownBlockquoteSpec with _\$MarkdownBlockquoteSpec`. The `_\$MarkdownBlockquoteSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownBlockquoteSpecMethods = _$MarkdownBlockquoteSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownBlockquoteStyler + extends MixStyler { + final Prop? $textStyle; + final Prop? $padding; + final Prop? $decoration; + final Prop? $alignment; + + const MarkdownBlockquoteStyler.create({ + Prop? textStyle, + Prop? padding, + Prop? decoration, + Prop? alignment, + super.variants, + super.modifier, + super.animation, + }) : $textStyle = textStyle, + $padding = padding, + $decoration = decoration, + $alignment = alignment; + + MarkdownBlockquoteStyler({ + TextStyleMix? textStyle, + EdgeInsets? padding, + BoxDecoration? decoration, + WrapAlignment? alignment, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + textStyle: Prop.maybeMix(textStyle), + padding: Prop.maybe(padding), + decoration: Prop.maybe(decoration), + alignment: Prop.maybe(alignment), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownBlockquoteStyler.textStyle(TextStyleMix value) => + MarkdownBlockquoteStyler().textStyle(value); + factory MarkdownBlockquoteStyler.padding(EdgeInsets value) => + MarkdownBlockquoteStyler().padding(value); + factory MarkdownBlockquoteStyler.decoration(BoxDecoration value) => + MarkdownBlockquoteStyler().decoration(value); + factory MarkdownBlockquoteStyler.alignment(WrapAlignment value) => + MarkdownBlockquoteStyler().alignment(value); + + /// Sets the textStyle. + MarkdownBlockquoteStyler textStyle(TextStyleMix value) { + return merge(MarkdownBlockquoteStyler(textStyle: value)); + } + + /// Sets the padding. + MarkdownBlockquoteStyler padding(EdgeInsets value) { + return merge(MarkdownBlockquoteStyler(padding: value)); + } + + /// Sets the decoration. + MarkdownBlockquoteStyler decoration(BoxDecoration value) { + return merge(MarkdownBlockquoteStyler(decoration: value)); + } + + /// Sets the alignment. + MarkdownBlockquoteStyler alignment(WrapAlignment value) { + return merge(MarkdownBlockquoteStyler(alignment: value)); + } + + /// Sets the animation configuration. + @override + MarkdownBlockquoteStyler animate(AnimationConfig value) { + return merge(MarkdownBlockquoteStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownBlockquoteStyler variants( + List> value, + ) { + return merge(MarkdownBlockquoteStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownBlockquoteStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownBlockquoteStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownBlockquoteStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownBlockquoteStyler(modifier: value)); + } + + /// Merges with another [MarkdownBlockquoteStyler]. + @override + MarkdownBlockquoteStyler merge(MarkdownBlockquoteStyler? other) { + return MarkdownBlockquoteStyler.create( + textStyle: MixOps.merge($textStyle, other?.$textStyle), + padding: MixOps.merge($padding, other?.$padding), + decoration: MixOps.merge($decoration, other?.$decoration), + alignment: MixOps.merge($alignment, other?.$alignment), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownBlockquoteSpec( + textStyle: MixOps.resolve(context, $textStyle), + padding: MixOps.resolve(context, $padding), + decoration: MixOps.resolve(context, $decoration), + alignment: MixOps.resolve(context, $alignment), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('textStyle', $textStyle)) + ..add(DiagnosticsProperty('padding', $padding)) + ..add(DiagnosticsProperty('decoration', $decoration)) + ..add(DiagnosticsProperty('alignment', $alignment)); + } + + @override + List get props => [ + $textStyle, + $padding, + $decoration, + $alignment, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart index 6e93ca6f..7549506c 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart @@ -1,139 +1,25 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_checkbox.g.dart'; /// Specification for markdown checkbox styling properties. /// /// Defines styling for checkbox elements including text style and icon. -final class MarkdownCheckboxSpec extends Spec - with Diagnosticable { - final TextStyle? textStyle; - final StyleSpec? icon; - - const MarkdownCheckboxSpec({this.textStyle, this.icon}); - - @override - MarkdownCheckboxSpec copyWith({ - TextStyle? textStyle, - StyleSpec? icon, - }) { - return MarkdownCheckboxSpec( - textStyle: textStyle ?? this.textStyle, - icon: icon ?? this.icon, - ); - } - +@MixableSpec() +@immutable +final class MarkdownCheckboxSpec with _$MarkdownCheckboxSpec { @override - MarkdownCheckboxSpec lerp(MarkdownCheckboxSpec? other, double t) { - if (other == null) return this; - - return MarkdownCheckboxSpec( - textStyle: TextStyle.lerp(textStyle, other.textStyle, t), - icon: MixOps.lerp(icon, other.icon, t), - ); - } + final TextStyle? textStyle; @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', textStyle)) - ..add(DiagnosticsProperty('icon', icon)); - } + @MixableField(setterType: IconStyler) + final StyleSpec? icon; - @override - List get props => [textStyle, icon]; + const MarkdownCheckboxSpec({this.textStyle, this.icon}); } -/// Style class for configuring [MarkdownCheckboxSpec] properties. -final class MarkdownCheckboxStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop? $textStyle; - final Prop>? $icon; - - const MarkdownCheckboxStyle.create({ - Prop? textStyle, - Prop>? icon, - required super.variants, - required super.animation, - required super.modifier, - }) : $textStyle = textStyle, - $icon = icon; - - MarkdownCheckboxStyle({ - TextStyle? textStyle, - IconStyler? icon, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - textStyle: Prop.maybe(textStyle), - icon: Prop.maybeMix(icon), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownCheckboxStyle variants( - List> value, - ) { - return merge(MarkdownCheckboxStyle(variants: value)); - } - - @override - MarkdownCheckboxStyle animate(AnimationConfig value) { - return merge(MarkdownCheckboxStyle(animation: value)); - } - - @override - MarkdownCheckboxStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownCheckboxStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownCheckboxSpec( - textStyle: MixOps.resolve(context, $textStyle), - icon: MixOps.resolve(context, $icon), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownCheckboxStyle merge(MarkdownCheckboxStyle? other) { - if (other == null) return this; - - return MarkdownCheckboxStyle.create( - textStyle: MixOps.merge($textStyle, other.$textStyle), - icon: MixOps.merge($icon, other.$icon), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', $textStyle)) - ..add(DiagnosticsProperty('icon', $icon)); - } - - @override - List get props => [ - $textStyle, - $icon, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownCheckboxStyler] (the pre-codegen class name). +typedef MarkdownCheckboxStyle = MarkdownCheckboxStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_checkbox.g.dart b/packages/superdeck/lib/src/styling/components/markdown_checkbox.g.dart new file mode 100644 index 00000000..54a136c9 --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_checkbox.g.dart @@ -0,0 +1,204 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_checkbox.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownCheckboxSpec + implements Spec, Diagnosticable { + TextStyle? get textStyle; + StyleSpec? get icon; + + @override + Type get type => MarkdownCheckboxSpec; + + @override + MarkdownCheckboxSpec copyWith({ + TextStyle? textStyle, + StyleSpec? icon, + }) { + return MarkdownCheckboxSpec( + textStyle: textStyle ?? this.textStyle, + icon: icon ?? this.icon, + ); + } + + @override + MarkdownCheckboxSpec lerp(MarkdownCheckboxSpec? other, double t) { + return MarkdownCheckboxSpec( + textStyle: MixOps.lerp(textStyle, other?.textStyle, t), + icon: icon?.lerp(other?.icon, t), + ); + } + + @override + List get props => [textStyle, icon]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownCheckboxSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('textStyle', textStyle)) + ..add(DiagnosticsProperty('icon', icon)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownCheckboxSpec` and migrate the class declaration to `class MarkdownCheckboxSpec with _\$MarkdownCheckboxSpec`. The `_\$MarkdownCheckboxSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownCheckboxSpecMethods = _$MarkdownCheckboxSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownCheckboxStyler + extends MixStyler { + final Prop? $textStyle; + final Prop>? $icon; + + const MarkdownCheckboxStyler.create({ + Prop? textStyle, + Prop>? icon, + super.variants, + super.modifier, + super.animation, + }) : $textStyle = textStyle, + $icon = icon; + + MarkdownCheckboxStyler({ + TextStyleMix? textStyle, + IconStyler? icon, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + textStyle: Prop.maybeMix(textStyle), + icon: Prop.maybeMix(icon), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownCheckboxStyler.textStyle(TextStyleMix value) => + MarkdownCheckboxStyler().textStyle(value); + factory MarkdownCheckboxStyler.icon(IconStyler value) => + MarkdownCheckboxStyler().icon(value); + + /// Sets the textStyle. + MarkdownCheckboxStyler textStyle(TextStyleMix value) { + return merge(MarkdownCheckboxStyler(textStyle: value)); + } + + /// Sets the icon. + MarkdownCheckboxStyler icon(IconStyler value) { + return merge(MarkdownCheckboxStyler(icon: value)); + } + + /// Sets the animation configuration. + @override + MarkdownCheckboxStyler animate(AnimationConfig value) { + return merge(MarkdownCheckboxStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownCheckboxStyler variants( + List> value, + ) { + return merge(MarkdownCheckboxStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownCheckboxStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownCheckboxStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownCheckboxStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownCheckboxStyler(modifier: value)); + } + + /// Merges with another [MarkdownCheckboxStyler]. + @override + MarkdownCheckboxStyler merge(MarkdownCheckboxStyler? other) { + return MarkdownCheckboxStyler.create( + textStyle: MixOps.merge($textStyle, other?.$textStyle), + icon: MixOps.merge($icon, other?.$icon), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownCheckboxSpec( + textStyle: MixOps.resolve(context, $textStyle), + icon: MixOps.resolve(context, $icon), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('textStyle', $textStyle)) + ..add(DiagnosticsProperty('icon', $icon)); + } + + @override + List get props => [ + $textStyle, + $icon, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart index 75fcfd08..99bede09 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart @@ -1,153 +1,28 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_codeblock.g.dart'; /// Specification for markdown code block styling properties. /// /// Defines styling for code blocks including text style, container, and alignment. -final class MarkdownCodeblockSpec extends Spec - with Diagnosticable { - final TextStyle? textStyle; - final StyleSpec? container; - final WrapAlignment? alignment; - - const MarkdownCodeblockSpec({this.textStyle, this.container, this.alignment}); - +@MixableSpec() +@immutable +final class MarkdownCodeblockSpec with _$MarkdownCodeblockSpec { @override - MarkdownCodeblockSpec copyWith({ - TextStyle? textStyle, - StyleSpec? container, - WrapAlignment? alignment, - }) { - return MarkdownCodeblockSpec( - textStyle: textStyle ?? this.textStyle, - container: container ?? this.container, - alignment: alignment ?? this.alignment, - ); - } + final TextStyle? textStyle; @override - MarkdownCodeblockSpec lerp(MarkdownCodeblockSpec? other, double t) { - if (other == null) return this; - - return MarkdownCodeblockSpec( - textStyle: TextStyle.lerp(textStyle, other.textStyle, t), - container: MixOps.lerp(container, other.container, t), - alignment: t < 0.5 ? alignment : other.alignment, - ); - } + @MixableField(setterType: BoxStyler) + final StyleSpec? container; @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', textStyle)) - ..add(DiagnosticsProperty('container', container)) - ..add(EnumProperty('alignment', alignment)); - } + final WrapAlignment? alignment; - @override - List get props => [textStyle, container, alignment]; + const MarkdownCodeblockSpec({this.textStyle, this.container, this.alignment}); } -/// Style class for configuring [MarkdownCodeblockSpec] properties. -final class MarkdownCodeblockStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop? $textStyle; - final Prop>? $container; - final Prop? $alignment; - - const MarkdownCodeblockStyle.create({ - Prop? textStyle, - Prop>? container, - Prop? alignment, - required super.variants, - required super.animation, - required super.modifier, - }) : $textStyle = textStyle, - $container = container, - $alignment = alignment; - - MarkdownCodeblockStyle({ - TextStyle? textStyle, - BoxStyler? container, - WrapAlignment? alignment, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - textStyle: Prop.maybe(textStyle), - container: Prop.maybeMix(container), - alignment: Prop.maybe(alignment), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownCodeblockStyle variants( - List> value, - ) { - return merge(MarkdownCodeblockStyle(variants: value)); - } - - @override - MarkdownCodeblockStyle animate(AnimationConfig value) { - return merge(MarkdownCodeblockStyle(animation: value)); - } - - @override - MarkdownCodeblockStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownCodeblockStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownCodeblockSpec( - textStyle: MixOps.resolve(context, $textStyle), - container: MixOps.resolve(context, $container), - alignment: MixOps.resolve(context, $alignment), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownCodeblockStyle merge(MarkdownCodeblockStyle? other) { - if (other == null) return this; - - return MarkdownCodeblockStyle.create( - textStyle: MixOps.merge($textStyle, other.$textStyle), - container: MixOps.merge($container, other.$container), - alignment: MixOps.merge($alignment, other.$alignment), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', $textStyle)) - ..add(DiagnosticsProperty('container', $container)) - ..add(DiagnosticsProperty('alignment', $alignment)); - } - - @override - List get props => [ - $textStyle, - $container, - $alignment, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownCodeblockStyler] (the pre-codegen class name). +typedef MarkdownCodeblockStyle = MarkdownCodeblockStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_codeblock.g.dart b/packages/superdeck/lib/src/styling/components/markdown_codeblock.g.dart new file mode 100644 index 00000000..78ac63ba --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_codeblock.g.dart @@ -0,0 +1,225 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_codeblock.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownCodeblockSpec + implements Spec, Diagnosticable { + TextStyle? get textStyle; + StyleSpec? get container; + WrapAlignment? get alignment; + + @override + Type get type => MarkdownCodeblockSpec; + + @override + MarkdownCodeblockSpec copyWith({ + TextStyle? textStyle, + StyleSpec? container, + WrapAlignment? alignment, + }) { + return MarkdownCodeblockSpec( + textStyle: textStyle ?? this.textStyle, + container: container ?? this.container, + alignment: alignment ?? this.alignment, + ); + } + + @override + MarkdownCodeblockSpec lerp(MarkdownCodeblockSpec? other, double t) { + return MarkdownCodeblockSpec( + textStyle: MixOps.lerp(textStyle, other?.textStyle, t), + container: container?.lerp(other?.container, t), + alignment: MixOps.lerpSnap(alignment, other?.alignment, t), + ); + } + + @override + List get props => [textStyle, container, alignment]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownCodeblockSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('textStyle', textStyle)) + ..add(DiagnosticsProperty('container', container)) + ..add(DiagnosticsProperty('alignment', alignment)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownCodeblockSpec` and migrate the class declaration to `class MarkdownCodeblockSpec with _\$MarkdownCodeblockSpec`. The `_\$MarkdownCodeblockSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownCodeblockSpecMethods = _$MarkdownCodeblockSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownCodeblockStyler + extends MixStyler { + final Prop? $textStyle; + final Prop>? $container; + final Prop? $alignment; + + const MarkdownCodeblockStyler.create({ + Prop? textStyle, + Prop>? container, + Prop? alignment, + super.variants, + super.modifier, + super.animation, + }) : $textStyle = textStyle, + $container = container, + $alignment = alignment; + + MarkdownCodeblockStyler({ + TextStyleMix? textStyle, + BoxStyler? container, + WrapAlignment? alignment, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + textStyle: Prop.maybeMix(textStyle), + container: Prop.maybeMix(container), + alignment: Prop.maybe(alignment), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownCodeblockStyler.textStyle(TextStyleMix value) => + MarkdownCodeblockStyler().textStyle(value); + factory MarkdownCodeblockStyler.container(BoxStyler value) => + MarkdownCodeblockStyler().container(value); + factory MarkdownCodeblockStyler.alignment(WrapAlignment value) => + MarkdownCodeblockStyler().alignment(value); + + /// Sets the textStyle. + MarkdownCodeblockStyler textStyle(TextStyleMix value) { + return merge(MarkdownCodeblockStyler(textStyle: value)); + } + + /// Sets the container. + MarkdownCodeblockStyler container(BoxStyler value) { + return merge(MarkdownCodeblockStyler(container: value)); + } + + /// Sets the alignment. + MarkdownCodeblockStyler alignment(WrapAlignment value) { + return merge(MarkdownCodeblockStyler(alignment: value)); + } + + /// Sets the animation configuration. + @override + MarkdownCodeblockStyler animate(AnimationConfig value) { + return merge(MarkdownCodeblockStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownCodeblockStyler variants( + List> value, + ) { + return merge(MarkdownCodeblockStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownCodeblockStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownCodeblockStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownCodeblockStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownCodeblockStyler(modifier: value)); + } + + /// Merges with another [MarkdownCodeblockStyler]. + @override + MarkdownCodeblockStyler merge(MarkdownCodeblockStyler? other) { + return MarkdownCodeblockStyler.create( + textStyle: MixOps.merge($textStyle, other?.$textStyle), + container: MixOps.merge($container, other?.$container), + alignment: MixOps.merge($alignment, other?.$alignment), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownCodeblockSpec( + textStyle: MixOps.resolve(context, $textStyle), + container: MixOps.resolve(context, $container), + alignment: MixOps.resolve(context, $alignment), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('textStyle', $textStyle)) + ..add(DiagnosticsProperty('container', $container)) + ..add(DiagnosticsProperty('alignment', $alignment)); + } + + @override + List get props => [ + $textStyle, + $container, + $alignment, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_list.dart b/packages/superdeck/lib/src/styling/components/markdown_list.dart index 5129d03e..6140439d 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_list.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_list.dart @@ -1,15 +1,28 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_list.g.dart'; /// Specification for markdown list styling properties. /// /// Defines styling for ordered and unordered lists including bullet and text styles. -final class MarkdownListSpec extends Spec - with Diagnosticable { +@MixableSpec() +@immutable +final class MarkdownListSpec with _$MarkdownListSpec { + @override + @MixableField(setterType: TextStyler) final StyleSpec? bullet; + + @override + @MixableField(setterType: TextStyler) final StyleSpec? text; + + @override final WrapAlignment? orderedAlignment; + + @override final WrapAlignment? unorderedAlignment; const MarkdownListSpec({ @@ -18,166 +31,7 @@ final class MarkdownListSpec extends Spec this.orderedAlignment, this.unorderedAlignment, }); - - @override - MarkdownListSpec copyWith({ - StyleSpec? bullet, - StyleSpec? text, - WrapAlignment? orderedAlignment, - WrapAlignment? unorderedAlignment, - }) { - return MarkdownListSpec( - bullet: bullet ?? this.bullet, - text: text ?? this.text, - orderedAlignment: orderedAlignment ?? this.orderedAlignment, - unorderedAlignment: unorderedAlignment ?? this.unorderedAlignment, - ); - } - - @override - MarkdownListSpec lerp(MarkdownListSpec? other, double t) { - if (other == null) return this; - - return MarkdownListSpec( - bullet: MixOps.lerp(bullet, other.bullet, t), - text: MixOps.lerp(text, other.text, t), - orderedAlignment: t < 0.5 ? orderedAlignment : other.orderedAlignment, - unorderedAlignment: t < 0.5 - ? unorderedAlignment - : other.unorderedAlignment, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('bullet', bullet)) - ..add(DiagnosticsProperty('text', text)) - ..add(EnumProperty('orderedAlignment', orderedAlignment)) - ..add(EnumProperty('unorderedAlignment', unorderedAlignment)); - } - - @override - List get props => [ - bullet, - text, - orderedAlignment, - unorderedAlignment, - ]; } -/// Style class for configuring [MarkdownListSpec] properties. -final class MarkdownListStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop>? $bullet; - final Prop>? $text; - final Prop? $orderedAlignment; - final Prop? $unorderedAlignment; - - const MarkdownListStyle.create({ - Prop>? bullet, - Prop>? text, - Prop? orderedAlignment, - Prop? unorderedAlignment, - required super.variants, - required super.animation, - required super.modifier, - }) : $bullet = bullet, - $text = text, - $orderedAlignment = orderedAlignment, - $unorderedAlignment = unorderedAlignment; - - MarkdownListStyle({ - TextStyler? bullet, - TextStyler? text, - WrapAlignment? orderedAlignment, - WrapAlignment? unorderedAlignment, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - bullet: Prop.maybeMix(bullet), - text: Prop.maybeMix(text), - orderedAlignment: Prop.maybe(orderedAlignment), - unorderedAlignment: Prop.maybe(unorderedAlignment), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownListStyle variants(List> value) { - return merge(MarkdownListStyle(variants: value)); - } - - @override - MarkdownListStyle animate(AnimationConfig value) { - return merge(MarkdownListStyle(animation: value)); - } - - @override - MarkdownListStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownListStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownListSpec( - bullet: MixOps.resolve(context, $bullet), - text: MixOps.resolve(context, $text), - orderedAlignment: MixOps.resolve(context, $orderedAlignment), - unorderedAlignment: MixOps.resolve(context, $unorderedAlignment), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownListStyle merge(MarkdownListStyle? other) { - if (other == null) return this; - - return MarkdownListStyle.create( - bullet: MixOps.merge($bullet, other.$bullet), - text: MixOps.merge($text, other.$text), - orderedAlignment: MixOps.merge( - $orderedAlignment, - other.$orderedAlignment, - ), - unorderedAlignment: MixOps.merge( - $unorderedAlignment, - other.$unorderedAlignment, - ), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('bullet', $bullet)) - ..add(DiagnosticsProperty('text', $text)) - ..add(DiagnosticsProperty('orderedAlignment', $orderedAlignment)) - ..add(DiagnosticsProperty('unorderedAlignment', $unorderedAlignment)); - } - - @override - List get props => [ - $bullet, - $text, - $orderedAlignment, - $unorderedAlignment, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownListStyler] (the pre-codegen class name). +typedef MarkdownListStyle = MarkdownListStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_list.g.dart b/packages/superdeck/lib/src/styling/components/markdown_list.g.dart new file mode 100644 index 00000000..9dcab241 --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_list.g.dart @@ -0,0 +1,262 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_list.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownListSpec implements Spec, Diagnosticable { + StyleSpec? get bullet; + StyleSpec? get text; + WrapAlignment? get orderedAlignment; + WrapAlignment? get unorderedAlignment; + + @override + Type get type => MarkdownListSpec; + + @override + MarkdownListSpec copyWith({ + StyleSpec? bullet, + StyleSpec? text, + WrapAlignment? orderedAlignment, + WrapAlignment? unorderedAlignment, + }) { + return MarkdownListSpec( + bullet: bullet ?? this.bullet, + text: text ?? this.text, + orderedAlignment: orderedAlignment ?? this.orderedAlignment, + unorderedAlignment: unorderedAlignment ?? this.unorderedAlignment, + ); + } + + @override + MarkdownListSpec lerp(MarkdownListSpec? other, double t) { + return MarkdownListSpec( + bullet: bullet?.lerp(other?.bullet, t), + text: text?.lerp(other?.text, t), + orderedAlignment: MixOps.lerpSnap( + orderedAlignment, + other?.orderedAlignment, + t, + ), + unorderedAlignment: MixOps.lerpSnap( + unorderedAlignment, + other?.unorderedAlignment, + t, + ), + ); + } + + @override + List get props => [ + bullet, + text, + orderedAlignment, + unorderedAlignment, + ]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownListSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('bullet', bullet)) + ..add(DiagnosticsProperty('text', text)) + ..add(DiagnosticsProperty('orderedAlignment', orderedAlignment)) + ..add(DiagnosticsProperty('unorderedAlignment', unorderedAlignment)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownListSpec` and migrate the class declaration to `class MarkdownListSpec with _\$MarkdownListSpec`. The `_\$MarkdownListSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownListSpecMethods = _$MarkdownListSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownListStyler + extends MixStyler { + final Prop>? $bullet; + final Prop>? $text; + final Prop? $orderedAlignment; + final Prop? $unorderedAlignment; + + const MarkdownListStyler.create({ + Prop>? bullet, + Prop>? text, + Prop? orderedAlignment, + Prop? unorderedAlignment, + super.variants, + super.modifier, + super.animation, + }) : $bullet = bullet, + $text = text, + $orderedAlignment = orderedAlignment, + $unorderedAlignment = unorderedAlignment; + + MarkdownListStyler({ + TextStyler? bullet, + TextStyler? text, + WrapAlignment? orderedAlignment, + WrapAlignment? unorderedAlignment, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + bullet: Prop.maybeMix(bullet), + text: Prop.maybeMix(text), + orderedAlignment: Prop.maybe(orderedAlignment), + unorderedAlignment: Prop.maybe(unorderedAlignment), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownListStyler.bullet(TextStyler value) => + MarkdownListStyler().bullet(value); + factory MarkdownListStyler.text(TextStyler value) => + MarkdownListStyler().text(value); + factory MarkdownListStyler.orderedAlignment(WrapAlignment value) => + MarkdownListStyler().orderedAlignment(value); + factory MarkdownListStyler.unorderedAlignment(WrapAlignment value) => + MarkdownListStyler().unorderedAlignment(value); + + /// Sets the bullet. + MarkdownListStyler bullet(TextStyler value) { + return merge(MarkdownListStyler(bullet: value)); + } + + /// Sets the text. + MarkdownListStyler text(TextStyler value) { + return merge(MarkdownListStyler(text: value)); + } + + /// Sets the orderedAlignment. + MarkdownListStyler orderedAlignment(WrapAlignment value) { + return merge(MarkdownListStyler(orderedAlignment: value)); + } + + /// Sets the unorderedAlignment. + MarkdownListStyler unorderedAlignment(WrapAlignment value) { + return merge(MarkdownListStyler(unorderedAlignment: value)); + } + + /// Sets the animation configuration. + @override + MarkdownListStyler animate(AnimationConfig value) { + return merge(MarkdownListStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownListStyler variants(List> value) { + return merge(MarkdownListStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownListStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownListStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownListStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownListStyler(modifier: value)); + } + + /// Merges with another [MarkdownListStyler]. + @override + MarkdownListStyler merge(MarkdownListStyler? other) { + return MarkdownListStyler.create( + bullet: MixOps.merge($bullet, other?.$bullet), + text: MixOps.merge($text, other?.$text), + orderedAlignment: MixOps.merge( + $orderedAlignment, + other?.$orderedAlignment, + ), + unorderedAlignment: MixOps.merge( + $unorderedAlignment, + other?.$unorderedAlignment, + ), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownListSpec( + bullet: MixOps.resolve(context, $bullet), + text: MixOps.resolve(context, $text), + orderedAlignment: MixOps.resolve(context, $orderedAlignment), + unorderedAlignment: MixOps.resolve(context, $unorderedAlignment), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('bullet', $bullet)) + ..add(DiagnosticsProperty('text', $text)) + ..add(DiagnosticsProperty('orderedAlignment', $orderedAlignment)) + ..add(DiagnosticsProperty('unorderedAlignment', $unorderedAlignment)); + } + + @override + List get props => [ + $bullet, + $text, + $orderedAlignment, + $unorderedAlignment, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/markdown_table.dart b/packages/superdeck/lib/src/styling/components/markdown_table.dart index 9e74fb1d..96710b63 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_table.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_table.dart @@ -2,21 +2,34 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'markdown_table.g.dart'; /// Specification for markdown table styling properties. /// /// Defines styling for tables including head/body text styles, alignment, /// borders, padding, and cell decorations. -final class MarkdownTableSpec extends Spec - with Diagnosticable { +@MixableSpec() +@immutable +final class MarkdownTableSpec with _$MarkdownTableSpec { + @override final TextStyle? headStyle; + @override final TextStyle? bodyStyle; + @override final TextAlign? headAlignment; + @override final EdgeInsets? padding; + @override final TableBorder? border; + @override final TableColumnWidth? columnWidth; + @override final EdgeInsets? cellPadding; + @override final BoxDecoration? cellDecoration; + @override final TableCellVerticalAlignment? verticalAlignment; const MarkdownTableSpec({ @@ -30,237 +43,7 @@ final class MarkdownTableSpec extends Spec this.cellDecoration, this.verticalAlignment, }); - - @override - MarkdownTableSpec copyWith({ - TextStyle? headStyle, - TextStyle? bodyStyle, - TextAlign? headAlignment, - EdgeInsets? padding, - TableBorder? border, - TableColumnWidth? columnWidth, - EdgeInsets? cellPadding, - BoxDecoration? cellDecoration, - TableCellVerticalAlignment? verticalAlignment, - }) { - return MarkdownTableSpec( - headStyle: headStyle ?? this.headStyle, - bodyStyle: bodyStyle ?? this.bodyStyle, - headAlignment: headAlignment ?? this.headAlignment, - padding: padding ?? this.padding, - border: border ?? this.border, - columnWidth: columnWidth ?? this.columnWidth, - cellPadding: cellPadding ?? this.cellPadding, - cellDecoration: cellDecoration ?? this.cellDecoration, - verticalAlignment: verticalAlignment ?? this.verticalAlignment, - ); - } - - @override - MarkdownTableSpec lerp(MarkdownTableSpec? other, double t) { - if (other == null) return this; - - return MarkdownTableSpec( - headStyle: TextStyle.lerp(headStyle, other.headStyle, t), - bodyStyle: TextStyle.lerp(bodyStyle, other.bodyStyle, t), - headAlignment: t < 0.5 ? headAlignment : other.headAlignment, - padding: EdgeInsets.lerp(padding, other.padding, t), - border: t < 0.5 ? border : other.border, - columnWidth: t < 0.5 ? columnWidth : other.columnWidth, - cellPadding: EdgeInsets.lerp(cellPadding, other.cellPadding, t), - cellDecoration: BoxDecoration.lerp( - cellDecoration, - other.cellDecoration, - t, - ), - verticalAlignment: t < 0.5 ? verticalAlignment : other.verticalAlignment, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('headStyle', headStyle)) - ..add(DiagnosticsProperty('bodyStyle', bodyStyle)) - ..add(EnumProperty('headAlignment', headAlignment)) - ..add(DiagnosticsProperty('padding', padding)) - ..add(DiagnosticsProperty('border', border)) - ..add(DiagnosticsProperty('columnWidth', columnWidth)) - ..add(DiagnosticsProperty('cellPadding', cellPadding)) - ..add(DiagnosticsProperty('cellDecoration', cellDecoration)) - ..add(EnumProperty('verticalAlignment', verticalAlignment)); - } - - @override - List get props => [ - headStyle, - bodyStyle, - headAlignment, - padding, - border, - columnWidth, - cellPadding, - cellDecoration, - verticalAlignment, - ]; } -/// Style class for configuring [MarkdownTableSpec] properties. -/// -/// Provides a fluent API for building markdown table styles. -final class MarkdownTableStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop? $headStyle; - final Prop? $bodyStyle; - final Prop? $headAlignment; - final Prop? $padding; - final Prop? $border; - final Prop? $columnWidth; - final Prop? $cellPadding; - final Prop? $cellDecoration; - final Prop? $verticalAlignment; - - const MarkdownTableStyle.create({ - Prop? headStyle, - Prop? bodyStyle, - Prop? headAlignment, - Prop? padding, - Prop? border, - Prop? columnWidth, - Prop? cellPadding, - Prop? cellDecoration, - Prop? verticalAlignment, - required super.variants, - required super.animation, - required super.modifier, - }) : $headStyle = headStyle, - $bodyStyle = bodyStyle, - $headAlignment = headAlignment, - $padding = padding, - $border = border, - $columnWidth = columnWidth, - $cellPadding = cellPadding, - $cellDecoration = cellDecoration, - $verticalAlignment = verticalAlignment; - - MarkdownTableStyle({ - TextStyle? headStyle, - TextStyle? bodyStyle, - TextAlign? headAlignment, - EdgeInsets? padding, - TableBorder? border, - TableColumnWidth? columnWidth, - EdgeInsets? cellPadding, - BoxDecoration? cellDecoration, - TableCellVerticalAlignment? verticalAlignment, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - headStyle: Prop.maybe(headStyle), - bodyStyle: Prop.maybe(bodyStyle), - headAlignment: Prop.maybe(headAlignment), - padding: Prop.maybe(padding), - border: Prop.maybe(border), - columnWidth: Prop.maybe(columnWidth), - cellPadding: Prop.maybe(cellPadding), - cellDecoration: Prop.maybe(cellDecoration), - verticalAlignment: Prop.maybe(verticalAlignment), - animation: animation, - variants: variants, - modifier: modifier, - ); - - @override - MarkdownTableStyle variants(List> value) { - return merge(MarkdownTableStyle(variants: value)); - } - - @override - MarkdownTableStyle animate(AnimationConfig value) { - return merge(MarkdownTableStyle(animation: value)); - } - - @override - MarkdownTableStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownTableStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownTableSpec( - headStyle: MixOps.resolve(context, $headStyle), - bodyStyle: MixOps.resolve(context, $bodyStyle), - headAlignment: MixOps.resolve(context, $headAlignment), - padding: MixOps.resolve(context, $padding), - border: MixOps.resolve(context, $border), - columnWidth: MixOps.resolve(context, $columnWidth), - cellPadding: MixOps.resolve(context, $cellPadding), - cellDecoration: MixOps.resolve(context, $cellDecoration), - verticalAlignment: MixOps.resolve(context, $verticalAlignment), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownTableStyle merge(MarkdownTableStyle? other) { - if (other == null) return this; - - return MarkdownTableStyle.create( - headStyle: MixOps.merge($headStyle, other.$headStyle), - bodyStyle: MixOps.merge($bodyStyle, other.$bodyStyle), - headAlignment: MixOps.merge($headAlignment, other.$headAlignment), - padding: MixOps.merge($padding, other.$padding), - border: MixOps.merge($border, other.$border), - columnWidth: MixOps.merge($columnWidth, other.$columnWidth), - cellPadding: MixOps.merge($cellPadding, other.$cellPadding), - cellDecoration: MixOps.merge($cellDecoration, other.$cellDecoration), - verticalAlignment: MixOps.merge( - $verticalAlignment, - other.$verticalAlignment, - ), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('headStyle', $headStyle)) - ..add(DiagnosticsProperty('bodyStyle', $bodyStyle)) - ..add(DiagnosticsProperty('headAlignment', $headAlignment)) - ..add(DiagnosticsProperty('padding', $padding)) - ..add(DiagnosticsProperty('border', $border)) - ..add(DiagnosticsProperty('columnWidth', $columnWidth)) - ..add(DiagnosticsProperty('cellPadding', $cellPadding)) - ..add(DiagnosticsProperty('cellDecoration', $cellDecoration)) - ..add(DiagnosticsProperty('verticalAlignment', $verticalAlignment)); - } - - @override - List get props => [ - $headStyle, - $bodyStyle, - $headAlignment, - $padding, - $border, - $columnWidth, - $cellPadding, - $cellDecoration, - $verticalAlignment, - $animation, - $variants, - $modifier, - ]; -} +/// Legacy alias for [MarkdownTableStyler] (the pre-codegen class name). +typedef MarkdownTableStyle = MarkdownTableStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_table.g.dart b/packages/superdeck/lib/src/styling/components/markdown_table.g.dart new file mode 100644 index 00000000..1850606e --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/markdown_table.g.dart @@ -0,0 +1,366 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'markdown_table.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$MarkdownTableSpec implements Spec, Diagnosticable { + TextStyle? get headStyle; + TextStyle? get bodyStyle; + TextAlign? get headAlignment; + EdgeInsets? get padding; + TableBorder? get border; + TableColumnWidth? get columnWidth; + EdgeInsets? get cellPadding; + BoxDecoration? get cellDecoration; + TableCellVerticalAlignment? get verticalAlignment; + + @override + Type get type => MarkdownTableSpec; + + @override + MarkdownTableSpec copyWith({ + TextStyle? headStyle, + TextStyle? bodyStyle, + TextAlign? headAlignment, + EdgeInsets? padding, + TableBorder? border, + TableColumnWidth? columnWidth, + EdgeInsets? cellPadding, + BoxDecoration? cellDecoration, + TableCellVerticalAlignment? verticalAlignment, + }) { + return MarkdownTableSpec( + headStyle: headStyle ?? this.headStyle, + bodyStyle: bodyStyle ?? this.bodyStyle, + headAlignment: headAlignment ?? this.headAlignment, + padding: padding ?? this.padding, + border: border ?? this.border, + columnWidth: columnWidth ?? this.columnWidth, + cellPadding: cellPadding ?? this.cellPadding, + cellDecoration: cellDecoration ?? this.cellDecoration, + verticalAlignment: verticalAlignment ?? this.verticalAlignment, + ); + } + + @override + MarkdownTableSpec lerp(MarkdownTableSpec? other, double t) { + return MarkdownTableSpec( + headStyle: MixOps.lerp(headStyle, other?.headStyle, t), + bodyStyle: MixOps.lerp(bodyStyle, other?.bodyStyle, t), + headAlignment: MixOps.lerpSnap(headAlignment, other?.headAlignment, t), + padding: MixOps.lerp(padding, other?.padding, t), + border: MixOps.lerpSnap(border, other?.border, t), + columnWidth: MixOps.lerpSnap(columnWidth, other?.columnWidth, t), + cellPadding: MixOps.lerp(cellPadding, other?.cellPadding, t), + cellDecoration: MixOps.lerp(cellDecoration, other?.cellDecoration, t), + verticalAlignment: MixOps.lerpSnap( + verticalAlignment, + other?.verticalAlignment, + t, + ), + ); + } + + @override + List get props => [ + headStyle, + bodyStyle, + headAlignment, + padding, + border, + columnWidth, + cellPadding, + cellDecoration, + verticalAlignment, + ]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is MarkdownTableSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('headStyle', headStyle)) + ..add(DiagnosticsProperty('bodyStyle', bodyStyle)) + ..add(EnumProperty('headAlignment', headAlignment)) + ..add(DiagnosticsProperty('padding', padding)) + ..add(DiagnosticsProperty('border', border)) + ..add(DiagnosticsProperty('columnWidth', columnWidth)) + ..add(DiagnosticsProperty('cellPadding', cellPadding)) + ..add(DiagnosticsProperty('cellDecoration', cellDecoration)) + ..add(DiagnosticsProperty('verticalAlignment', verticalAlignment)); + } +} + +@Deprecated( + 'Rename to `_\$MarkdownTableSpec` and migrate the class declaration to `class MarkdownTableSpec with _\$MarkdownTableSpec`. The `_\$MarkdownTableSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$MarkdownTableSpecMethods = _$MarkdownTableSpec; // ignore: unused_element + +// ************************************************************************** +// SpecStylerGenerator +// ************************************************************************** + +class MarkdownTableStyler + extends MixStyler { + final Prop? $headStyle; + final Prop? $bodyStyle; + final Prop? $headAlignment; + final Prop? $padding; + final Prop? $border; + final Prop? $columnWidth; + final Prop? $cellPadding; + final Prop? $cellDecoration; + final Prop? $verticalAlignment; + + const MarkdownTableStyler.create({ + Prop? headStyle, + Prop? bodyStyle, + Prop? headAlignment, + Prop? padding, + Prop? border, + Prop? columnWidth, + Prop? cellPadding, + Prop? cellDecoration, + Prop? verticalAlignment, + super.variants, + super.modifier, + super.animation, + }) : $headStyle = headStyle, + $bodyStyle = bodyStyle, + $headAlignment = headAlignment, + $padding = padding, + $border = border, + $columnWidth = columnWidth, + $cellPadding = cellPadding, + $cellDecoration = cellDecoration, + $verticalAlignment = verticalAlignment; + + MarkdownTableStyler({ + TextStyleMix? headStyle, + TextStyleMix? bodyStyle, + TextAlign? headAlignment, + EdgeInsets? padding, + TableBorder? border, + TableColumnWidth? columnWidth, + EdgeInsets? cellPadding, + BoxDecoration? cellDecoration, + TableCellVerticalAlignment? verticalAlignment, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + headStyle: Prop.maybeMix(headStyle), + bodyStyle: Prop.maybeMix(bodyStyle), + headAlignment: Prop.maybe(headAlignment), + padding: Prop.maybe(padding), + border: Prop.maybe(border), + columnWidth: Prop.maybe(columnWidth), + cellPadding: Prop.maybe(cellPadding), + cellDecoration: Prop.maybe(cellDecoration), + verticalAlignment: Prop.maybe(verticalAlignment), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownTableStyler.headStyle(TextStyleMix value) => + MarkdownTableStyler().headStyle(value); + factory MarkdownTableStyler.bodyStyle(TextStyleMix value) => + MarkdownTableStyler().bodyStyle(value); + factory MarkdownTableStyler.headAlignment(TextAlign value) => + MarkdownTableStyler().headAlignment(value); + factory MarkdownTableStyler.padding(EdgeInsets value) => + MarkdownTableStyler().padding(value); + factory MarkdownTableStyler.border(TableBorder value) => + MarkdownTableStyler().border(value); + factory MarkdownTableStyler.columnWidth(TableColumnWidth value) => + MarkdownTableStyler().columnWidth(value); + factory MarkdownTableStyler.cellPadding(EdgeInsets value) => + MarkdownTableStyler().cellPadding(value); + factory MarkdownTableStyler.cellDecoration(BoxDecoration value) => + MarkdownTableStyler().cellDecoration(value); + factory MarkdownTableStyler.verticalAlignment( + TableCellVerticalAlignment value, + ) => MarkdownTableStyler().verticalAlignment(value); + + /// Sets the headStyle. + MarkdownTableStyler headStyle(TextStyleMix value) { + return merge(MarkdownTableStyler(headStyle: value)); + } + + /// Sets the bodyStyle. + MarkdownTableStyler bodyStyle(TextStyleMix value) { + return merge(MarkdownTableStyler(bodyStyle: value)); + } + + /// Sets the headAlignment. + MarkdownTableStyler headAlignment(TextAlign value) { + return merge(MarkdownTableStyler(headAlignment: value)); + } + + /// Sets the padding. + MarkdownTableStyler padding(EdgeInsets value) { + return merge(MarkdownTableStyler(padding: value)); + } + + /// Sets the border. + MarkdownTableStyler border(TableBorder value) { + return merge(MarkdownTableStyler(border: value)); + } + + /// Sets the columnWidth. + MarkdownTableStyler columnWidth(TableColumnWidth value) { + return merge(MarkdownTableStyler(columnWidth: value)); + } + + /// Sets the cellPadding. + MarkdownTableStyler cellPadding(EdgeInsets value) { + return merge(MarkdownTableStyler(cellPadding: value)); + } + + /// Sets the cellDecoration. + MarkdownTableStyler cellDecoration(BoxDecoration value) { + return merge(MarkdownTableStyler(cellDecoration: value)); + } + + /// Sets the verticalAlignment. + MarkdownTableStyler verticalAlignment(TableCellVerticalAlignment value) { + return merge(MarkdownTableStyler(verticalAlignment: value)); + } + + /// Sets the animation configuration. + @override + MarkdownTableStyler animate(AnimationConfig value) { + return merge(MarkdownTableStyler(animation: value)); + } + + /// Sets the style variants. + @override + MarkdownTableStyler variants(List> value) { + return merge(MarkdownTableStyler(variants: value)); + } + + /// Wraps with a widget modifier. + @override + MarkdownTableStyler wrap(WidgetModifierConfig value) { + return merge(MarkdownTableStyler(modifier: value)); + } + + /// Sets the widget modifier. + MarkdownTableStyler modifier(WidgetModifierConfig value) { + return merge(MarkdownTableStyler(modifier: value)); + } + + /// Merges with another [MarkdownTableStyler]. + @override + MarkdownTableStyler merge(MarkdownTableStyler? other) { + return MarkdownTableStyler.create( + headStyle: MixOps.merge($headStyle, other?.$headStyle), + bodyStyle: MixOps.merge($bodyStyle, other?.$bodyStyle), + headAlignment: MixOps.merge($headAlignment, other?.$headAlignment), + padding: MixOps.merge($padding, other?.$padding), + border: MixOps.merge($border, other?.$border), + columnWidth: MixOps.merge($columnWidth, other?.$columnWidth), + cellPadding: MixOps.merge($cellPadding, other?.$cellPadding), + cellDecoration: MixOps.merge($cellDecoration, other?.$cellDecoration), + verticalAlignment: MixOps.merge( + $verticalAlignment, + other?.$verticalAlignment, + ), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = MarkdownTableSpec( + headStyle: MixOps.resolve(context, $headStyle), + bodyStyle: MixOps.resolve(context, $bodyStyle), + headAlignment: MixOps.resolve(context, $headAlignment), + padding: MixOps.resolve(context, $padding), + border: MixOps.resolve(context, $border), + columnWidth: MixOps.resolve(context, $columnWidth), + cellPadding: MixOps.resolve(context, $cellPadding), + cellDecoration: MixOps.resolve(context, $cellDecoration), + verticalAlignment: MixOps.resolve(context, $verticalAlignment), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('headStyle', $headStyle)) + ..add(DiagnosticsProperty('bodyStyle', $bodyStyle)) + ..add(DiagnosticsProperty('headAlignment', $headAlignment)) + ..add(DiagnosticsProperty('padding', $padding)) + ..add(DiagnosticsProperty('border', $border)) + ..add(DiagnosticsProperty('columnWidth', $columnWidth)) + ..add(DiagnosticsProperty('cellPadding', $cellPadding)) + ..add(DiagnosticsProperty('cellDecoration', $cellDecoration)) + ..add(DiagnosticsProperty('verticalAlignment', $verticalAlignment)); + } + + @override + List get props => [ + $headStyle, + $bodyStyle, + $headAlignment, + $padding, + $border, + $columnWidth, + $cellPadding, + $cellDecoration, + $verticalAlignment, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/components/slide.dart b/packages/superdeck/lib/src/styling/components/slide.dart index 9b4e4ab9..93e8783f 100644 --- a/packages/superdeck/lib/src/styling/components/slide.dart +++ b/packages/superdeck/lib/src/styling/components/slide.dart @@ -1,7 +1,17 @@ +// The styler below stays hand-written on the legacy @MixableStyler mixin +// path: several fields nest same-package generated stylers +// (MarkdownAlertStyler, MarkdownCodeblockStyler, ...), which @MixableSpec's +// spec_styler_generator can only wire up through @MixableField(setterType:) — +// and annotation type arguments cannot reference same-package generated +// classes (build phases hide them from the resolver, degrading silently to +// value semantics). +// ignore_for_file: deprecated_member_use + import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_markdown_plus/flutter_markdown_plus.dart'; import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; import 'markdown_alert.dart'; import 'markdown_blockquote.dart'; @@ -10,6 +20,8 @@ import 'markdown_codeblock.dart'; import 'markdown_list.dart'; import 'markdown_table.dart'; +part 'slide.g.dart'; + /// Root specification for slide styling containing all markdown element styles. /// /// This is the main spec that aggregates all markdown styling including headings, @@ -19,39 +31,75 @@ import 'markdown_table.dart'; /// for base typography; inline markdown (`strong`, `em`, `del`, `a`/`link`, /// inline `code` via [code].textStyle) and [textScaleFactor] are applied when /// rendering paragraphs, headings, and list items. Prefer configuring these -/// through [SlideStyle] / Mix [TextStyler] — not [MarkdownTextStyle]. -final class SlideSpec extends Spec with Diagnosticable { +/// through [SlideStyler] / Mix [TextStyler]. +@MixableSpec() +@immutable +final class SlideSpec with _$SlideSpec { + @override + @MixableField(setterType: TextStyler) final StyleSpec? h1; + @override + @MixableField(setterType: TextStyler) final StyleSpec? h2; + @override + @MixableField(setterType: TextStyler) final StyleSpec? h3; + @override + @MixableField(setterType: TextStyler) final StyleSpec? h4; + @override + @MixableField(setterType: TextStyler) final StyleSpec? h5; + @override + @MixableField(setterType: TextStyler) final StyleSpec? h6; + @override + @MixableField(setterType: TextStyler) final StyleSpec? p; /// Anchor style; [link] takes precedence when both are set. + @override final TextStyle? a; + @override final TextStyle? em; + @override final TextStyle? strong; + @override final TextStyle? del; + @override final TextStyle? img; /// Preferred link style (used for `a` tags; overrides [a] when set). + @override final TextStyle? link; /// Scales markdown text in block builders when set. + @override final TextScaler? textScaleFactor; + @override final StyleSpec alert; + @override final BoxDecoration? horizontalRuleDecoration; + @override final StyleSpec? blockquote; + @override final StyleSpec? list; + @override final StyleSpec? table; + @override final StyleSpec? code; + @override final StyleSpec? checkbox; + @override + @MixableField(setterType: BoxStyler) final StyleSpec blockContainer; + @override + @MixableField(setterType: BoxStyler) final StyleSpec slideContainer; + @override + @MixableField(setterType: ImageStyler) final StyleSpec image; /// Static helper for context access @@ -90,98 +138,6 @@ final class SlideSpec extends Spec with Diagnosticable { slideContainer = slideContainer ?? const StyleSpec(spec: BoxSpec()), image = image ?? const StyleSpec(spec: ImageSpec()); - @override - SlideSpec copyWith({ - StyleSpec? h1, - StyleSpec? h2, - StyleSpec? h3, - StyleSpec? h4, - StyleSpec? h5, - StyleSpec? h6, - StyleSpec? p, - TextStyle? a, - TextStyle? em, - TextStyle? strong, - TextStyle? del, - TextStyle? img, - TextStyle? link, - TextScaler? textScaleFactor, - StyleSpec? alert, - BoxDecoration? horizontalRuleDecoration, - StyleSpec? blockquote, - StyleSpec? list, - StyleSpec? table, - StyleSpec? code, - StyleSpec? checkbox, - StyleSpec? blockContainer, - StyleSpec? slideContainer, - StyleSpec? image, - }) { - return SlideSpec( - h1: h1 ?? this.h1, - h2: h2 ?? this.h2, - h3: h3 ?? this.h3, - h4: h4 ?? this.h4, - h5: h5 ?? this.h5, - h6: h6 ?? this.h6, - p: p ?? this.p, - a: a ?? this.a, - em: em ?? this.em, - strong: strong ?? this.strong, - del: del ?? this.del, - img: img ?? this.img, - link: link ?? this.link, - textScaleFactor: textScaleFactor ?? this.textScaleFactor, - alert: alert ?? this.alert, - horizontalRuleDecoration: - horizontalRuleDecoration ?? this.horizontalRuleDecoration, - blockquote: blockquote ?? this.blockquote, - list: list ?? this.list, - table: table ?? this.table, - code: code ?? this.code, - checkbox: checkbox ?? this.checkbox, - blockContainer: blockContainer ?? this.blockContainer, - slideContainer: slideContainer ?? this.slideContainer, - image: image ?? this.image, - ); - } - - @override - SlideSpec lerp(SlideSpec? other, double t) { - if (other == null) return this; - - return SlideSpec( - h1: MixOps.lerp(h1, other.h1, t), - h2: MixOps.lerp(h2, other.h2, t), - h3: MixOps.lerp(h3, other.h3, t), - h4: MixOps.lerp(h4, other.h4, t), - h5: MixOps.lerp(h5, other.h5, t), - h6: MixOps.lerp(h6, other.h6, t), - p: MixOps.lerp(p, other.p, t), - a: TextStyle.lerp(a, other.a, t), - em: TextStyle.lerp(em, other.em, t), - strong: TextStyle.lerp(strong, other.strong, t), - del: TextStyle.lerp(del, other.del, t), - img: TextStyle.lerp(img, other.img, t), - link: TextStyle.lerp(link, other.link, t), - textScaleFactor: t < 0.5 ? textScaleFactor : other.textScaleFactor, - alert: MixOps.lerp(alert, other.alert, t)!, - horizontalRuleDecoration: BoxDecoration.lerp( - horizontalRuleDecoration, - other.horizontalRuleDecoration, - t, - ), - blockquote: MixOps.lerp(blockquote, other.blockquote, t), - list: MixOps.lerp(list, other.list, t), - table: MixOps.lerp(table, other.table, t), - code: MixOps.lerp(code, other.code, t), - checkbox: MixOps.lerp(checkbox, other.checkbox, t), - blockContainer: MixOps.lerp(blockContainer, other.blockContainer, t)!, - slideContainer: MixOps.lerp(slideContainer, other.slideContainer, t)!, - image: MixOps.lerp(image, other.image, t)!, - ); - } - /// Converts this SlideSpec to a MarkdownStyleSheet for flutter_markdown. /// /// Block tags (`p`, `h1`–`h6`, `li`) are rendered by custom builders that @@ -223,100 +179,85 @@ final class SlideSpec extends Spec with Diagnosticable { checkbox: checkbox?.spec.textStyle, ); } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('h1', h1)) - ..add(DiagnosticsProperty('h2', h2)) - ..add(DiagnosticsProperty('h3', h3)) - ..add(DiagnosticsProperty('h4', h4)) - ..add(DiagnosticsProperty('h5', h5)) - ..add(DiagnosticsProperty('h6', h6)) - ..add(DiagnosticsProperty('p', p)) - ..add(DiagnosticsProperty('a', a)) - ..add(DiagnosticsProperty('link', link)) - ..add(DiagnosticsProperty('alert', alert)) - ..add(DiagnosticsProperty('blockquote', blockquote)) - ..add(DiagnosticsProperty('list', list)) - ..add(DiagnosticsProperty('table', table)) - ..add(DiagnosticsProperty('code', code)) - ..add(DiagnosticsProperty('checkbox', checkbox)) - ..add(DiagnosticsProperty('blockContainer', blockContainer)) - ..add(DiagnosticsProperty('slideContainer', slideContainer)) - ..add(DiagnosticsProperty('image', image)); - } - - @override - List get props => [ - h1, - h2, - h3, - h4, - h5, - h6, - p, - a, - em, - strong, - del, - img, - link, - textScaleFactor, - alert, - horizontalRuleDecoration, - blockquote, - list, - table, - code, - checkbox, - blockContainer, - slideContainer, - image, - ]; } /// Root style class for configuring [SlideSpec] properties. /// /// This is the main style that controls all markdown element styling /// including headings, text, alerts, lists, tables, code blocks, and more. -final class SlideStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { +@MixableStyler() +final class SlideStyler extends MixStyler + with _$SlideStylerMixin { + @override + @MixableField(setterType: TextStyler) final Prop>? $h1; + @override + @MixableField(setterType: TextStyler) final Prop>? $h2; + @override + @MixableField(setterType: TextStyler) final Prop>? $h3; + @override + @MixableField(setterType: TextStyler) final Prop>? $h4; + @override + @MixableField(setterType: TextStyler) final Prop>? $h5; + @override + @MixableField(setterType: TextStyler) final Prop>? $h6; + @override + @MixableField(setterType: TextStyler) final Prop>? $p; + @override final Prop? $a; + @override final Prop? $em; + @override final Prop? $strong; + @override final Prop? $del; + @override final Prop? $img; + @override final Prop? $link; + @override final Prop? $textScaleFactor; + @override + @MixableField(ignoreSetter: true) final Prop>? $alert; + @override final Prop? $horizontalRuleDecoration; + @override + @MixableField(ignoreSetter: true) final Prop>? $blockquote; + @override + @MixableField(ignoreSetter: true) final Prop>? $list; + @override + @MixableField(ignoreSetter: true) final Prop>? $table; + @override + @MixableField(ignoreSetter: true) final Prop>? $code; + @override + @MixableField(ignoreSetter: true) final Prop>? $checkbox; + @override + @MixableField(setterType: BoxStyler) final Prop>? $blockContainer; + @override + @MixableField(setterType: BoxStyler) final Prop>? $slideContainer; + @override + @MixableField(setterType: ImageStyler) final Prop>? $image; - const SlideStyle.create({ + const SlideStyler.create({ Prop>? h1, Prop>? h2, Prop>? h3, @@ -369,7 +310,7 @@ final class SlideStyle extends Style $slideContainer = slideContainer, $image = image; - SlideStyle({ + SlideStyler({ TextStyler? h1, TextStyler? h2, TextStyler? h3, @@ -377,20 +318,20 @@ final class SlideStyle extends Style TextStyler? h5, TextStyler? h6, TextStyler? p, - TextStyle? a, - TextStyle? em, - TextStyle? strong, - TextStyle? del, - TextStyle? img, - TextStyle? link, + TextStyleMix? a, + TextStyleMix? em, + TextStyleMix? strong, + TextStyleMix? del, + TextStyleMix? img, + TextStyleMix? link, TextScaler? textScaleFactor, - MarkdownAlertStyle? alert, + MarkdownAlertStyler? alert, BoxDecoration? horizontalRuleDecoration, - MarkdownBlockquoteStyle? blockquote, - MarkdownListStyle? list, - MarkdownTableStyle? table, - MarkdownCodeblockStyle? code, - MarkdownCheckboxStyle? checkbox, + MarkdownBlockquoteStyler? blockquote, + MarkdownListStyler? list, + MarkdownTableStyler? table, + MarkdownCodeblockStyler? code, + MarkdownCheckboxStyler? checkbox, BoxStyler? blockContainer, BoxStyler? slideContainer, ImageStyler? image, @@ -405,12 +346,12 @@ final class SlideStyle extends Style h5: Prop.maybeMix(h5), h6: Prop.maybeMix(h6), p: Prop.maybeMix(p), - a: Prop.maybe(a), - em: Prop.maybe(em), - strong: Prop.maybe(strong), - del: Prop.maybe(del), - img: Prop.maybe(img), - link: Prop.maybe(link), + a: Prop.maybeMix(a), + em: Prop.maybeMix(em), + strong: Prop.maybeMix(strong), + del: Prop.maybeMix(del), + img: Prop.maybeMix(img), + link: Prop.maybeMix(link), textScaleFactor: Prop.maybe(textScaleFactor), alert: Prop.maybeMix(alert), horizontalRuleDecoration: Prop.maybe(horizontalRuleDecoration), @@ -427,172 +368,36 @@ final class SlideStyle extends Style modifier: modifier, ); - @override - SlideStyle variants(List> value) { - return merge(SlideStyle(variants: value)); + /// Sets the alert styles. + SlideStyler alert(MarkdownAlertStyler value) { + return merge(SlideStyler(alert: value)); } - @override - SlideStyle animate(AnimationConfig value) { - return merge(SlideStyle(animation: value)); + /// Sets the blockquote style. + SlideStyler blockquote(MarkdownBlockquoteStyler value) { + return merge(SlideStyler(blockquote: value)); } - @override - SlideStyle wrap(WidgetModifierConfig value) { - return merge(SlideStyle(modifier: value)); + /// Sets the list style. + SlideStyler list(MarkdownListStyler value) { + return merge(SlideStyler(list: value)); } - @override - StyleSpec resolve(BuildContext context) { - // [SlideSpec] requires concrete defaults for these non-nullable fields. - final resolvedAlert = - MixOps.resolve(context, $alert) ?? - const StyleSpec(spec: MarkdownAlertSpec()); - final resolvedBlockContainer = - MixOps.resolve(context, $blockContainer) ?? - const StyleSpec(spec: BoxSpec()); - final resolvedSlideContainer = - MixOps.resolve(context, $slideContainer) ?? - const StyleSpec(spec: BoxSpec()); - final resolvedImage = - MixOps.resolve(context, $image) ?? const StyleSpec(spec: ImageSpec()); - - return StyleSpec( - spec: SlideSpec( - h1: MixOps.resolve(context, $h1), - h2: MixOps.resolve(context, $h2), - h3: MixOps.resolve(context, $h3), - h4: MixOps.resolve(context, $h4), - h5: MixOps.resolve(context, $h5), - h6: MixOps.resolve(context, $h6), - p: MixOps.resolve(context, $p), - a: MixOps.resolve(context, $a), - em: MixOps.resolve(context, $em), - strong: MixOps.resolve(context, $strong), - del: MixOps.resolve(context, $del), - img: MixOps.resolve(context, $img), - link: MixOps.resolve(context, $link), - textScaleFactor: MixOps.resolve(context, $textScaleFactor), - alert: resolvedAlert, - horizontalRuleDecoration: MixOps.resolve( - context, - $horizontalRuleDecoration, - ), - blockquote: MixOps.resolve(context, $blockquote), - list: MixOps.resolve(context, $list), - table: MixOps.resolve(context, $table), - code: MixOps.resolve(context, $code), - checkbox: MixOps.resolve(context, $checkbox), - blockContainer: resolvedBlockContainer, - slideContainer: resolvedSlideContainer, - image: resolvedImage, - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); + /// Sets the table style. + SlideStyler table(MarkdownTableStyler value) { + return merge(SlideStyler(table: value)); } - @override - SlideStyle merge(SlideStyle? other) { - if (other == null) return this; - - return SlideStyle.create( - h1: MixOps.merge($h1, other.$h1), - h2: MixOps.merge($h2, other.$h2), - h3: MixOps.merge($h3, other.$h3), - h4: MixOps.merge($h4, other.$h4), - h5: MixOps.merge($h5, other.$h5), - h6: MixOps.merge($h6, other.$h6), - p: MixOps.merge($p, other.$p), - a: MixOps.merge($a, other.$a), - em: MixOps.merge($em, other.$em), - strong: MixOps.merge($strong, other.$strong), - del: MixOps.merge($del, other.$del), - img: MixOps.merge($img, other.$img), - link: MixOps.merge($link, other.$link), - textScaleFactor: MixOps.merge($textScaleFactor, other.$textScaleFactor), - alert: MixOps.merge($alert, other.$alert), - horizontalRuleDecoration: MixOps.merge( - $horizontalRuleDecoration, - other.$horizontalRuleDecoration, - ), - blockquote: MixOps.merge($blockquote, other.$blockquote), - list: MixOps.merge($list, other.$list), - table: MixOps.merge($table, other.$table), - code: MixOps.merge($code, other.$code), - checkbox: MixOps.merge($checkbox, other.$checkbox), - blockContainer: MixOps.merge($blockContainer, other.$blockContainer), - slideContainer: MixOps.merge($slideContainer, other.$slideContainer), - image: MixOps.merge($image, other.$image), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); + /// Sets the code block style. + SlideStyler code(MarkdownCodeblockStyler value) { + return merge(SlideStyler(code: value)); } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('h1', $h1)) - ..add(DiagnosticsProperty('h2', $h2)) - ..add(DiagnosticsProperty('h3', $h3)) - ..add(DiagnosticsProperty('h4', $h4)) - ..add(DiagnosticsProperty('h5', $h5)) - ..add(DiagnosticsProperty('h6', $h6)) - ..add(DiagnosticsProperty('p', $p)) - ..add(DiagnosticsProperty('a', $a)) - ..add(DiagnosticsProperty('em', $em)) - ..add(DiagnosticsProperty('strong', $strong)) - ..add(DiagnosticsProperty('del', $del)) - ..add(DiagnosticsProperty('img', $img)) - ..add(DiagnosticsProperty('link', $link)) - ..add(DiagnosticsProperty('textScaleFactor', $textScaleFactor)) - ..add(DiagnosticsProperty('alert', $alert)) - ..add( - DiagnosticsProperty( - 'horizontalRuleDecoration', - $horizontalRuleDecoration, - ), - ) - ..add(DiagnosticsProperty('blockquote', $blockquote)) - ..add(DiagnosticsProperty('list', $list)) - ..add(DiagnosticsProperty('table', $table)) - ..add(DiagnosticsProperty('code', $code)) - ..add(DiagnosticsProperty('checkbox', $checkbox)) - ..add(DiagnosticsProperty('blockContainer', $blockContainer)) - ..add(DiagnosticsProperty('slideContainer', $slideContainer)) - ..add(DiagnosticsProperty('image', $image)); + /// Sets the checkbox style. + SlideStyler checkbox(MarkdownCheckboxStyler value) { + return merge(SlideStyler(checkbox: value)); } - - @override - List get props => [ - $h1, - $h2, - $h3, - $h4, - $h5, - $h6, - $p, - $a, - $em, - $strong, - $del, - $img, - $link, - $textScaleFactor, - $alert, - $horizontalRuleDecoration, - $blockquote, - $list, - $table, - $code, - $checkbox, - $blockContainer, - $slideContainer, - $image, - $animation, - $variants, - $modifier, - ]; } + +/// Legacy alias for [SlideStyler] (the pre-codegen class name). +typedef SlideStyle = SlideStyler; diff --git a/packages/superdeck/lib/src/styling/components/slide.g.dart b/packages/superdeck/lib/src/styling/components/slide.g.dart new file mode 100644 index 00000000..bb0b8ead --- /dev/null +++ b/packages/superdeck/lib/src/styling/components/slide.g.dart @@ -0,0 +1,519 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'slide.dart'; + +// ************************************************************************** +// SpecGenerator +// ************************************************************************** + +mixin _$SlideSpec implements Spec, Diagnosticable { + StyleSpec? get h1; + StyleSpec? get h2; + StyleSpec? get h3; + StyleSpec? get h4; + StyleSpec? get h5; + StyleSpec? get h6; + StyleSpec? get p; + TextStyle? get a; + TextStyle? get em; + TextStyle? get strong; + TextStyle? get del; + TextStyle? get img; + TextStyle? get link; + TextScaler? get textScaleFactor; + StyleSpec get alert; + BoxDecoration? get horizontalRuleDecoration; + StyleSpec? get blockquote; + StyleSpec? get list; + StyleSpec? get table; + StyleSpec? get code; + StyleSpec? get checkbox; + StyleSpec get blockContainer; + StyleSpec get slideContainer; + StyleSpec get image; + + @override + Type get type => SlideSpec; + + @override + SlideSpec copyWith({ + StyleSpec? h1, + StyleSpec? h2, + StyleSpec? h3, + StyleSpec? h4, + StyleSpec? h5, + StyleSpec? h6, + StyleSpec? p, + TextStyle? a, + TextStyle? em, + TextStyle? strong, + TextStyle? del, + TextStyle? img, + TextStyle? link, + TextScaler? textScaleFactor, + StyleSpec? alert, + BoxDecoration? horizontalRuleDecoration, + StyleSpec? blockquote, + StyleSpec? list, + StyleSpec? table, + StyleSpec? code, + StyleSpec? checkbox, + StyleSpec? blockContainer, + StyleSpec? slideContainer, + StyleSpec? image, + }) { + return SlideSpec( + h1: h1 ?? this.h1, + h2: h2 ?? this.h2, + h3: h3 ?? this.h3, + h4: h4 ?? this.h4, + h5: h5 ?? this.h5, + h6: h6 ?? this.h6, + p: p ?? this.p, + a: a ?? this.a, + em: em ?? this.em, + strong: strong ?? this.strong, + del: del ?? this.del, + img: img ?? this.img, + link: link ?? this.link, + textScaleFactor: textScaleFactor ?? this.textScaleFactor, + alert: alert ?? this.alert, + horizontalRuleDecoration: + horizontalRuleDecoration ?? this.horizontalRuleDecoration, + blockquote: blockquote ?? this.blockquote, + list: list ?? this.list, + table: table ?? this.table, + code: code ?? this.code, + checkbox: checkbox ?? this.checkbox, + blockContainer: blockContainer ?? this.blockContainer, + slideContainer: slideContainer ?? this.slideContainer, + image: image ?? this.image, + ); + } + + @override + SlideSpec lerp(SlideSpec? other, double t) { + return SlideSpec( + h1: h1?.lerp(other?.h1, t), + h2: h2?.lerp(other?.h2, t), + h3: h3?.lerp(other?.h3, t), + h4: h4?.lerp(other?.h4, t), + h5: h5?.lerp(other?.h5, t), + h6: h6?.lerp(other?.h6, t), + p: p?.lerp(other?.p, t), + a: MixOps.lerp(a, other?.a, t), + em: MixOps.lerp(em, other?.em, t), + strong: MixOps.lerp(strong, other?.strong, t), + del: MixOps.lerp(del, other?.del, t), + img: MixOps.lerp(img, other?.img, t), + link: MixOps.lerp(link, other?.link, t), + textScaleFactor: MixOps.lerpSnap( + textScaleFactor, + other?.textScaleFactor, + t, + ), + alert: alert.lerp(other?.alert, t), + horizontalRuleDecoration: MixOps.lerp( + horizontalRuleDecoration, + other?.horizontalRuleDecoration, + t, + ), + blockquote: blockquote?.lerp(other?.blockquote, t), + list: list?.lerp(other?.list, t), + table: table?.lerp(other?.table, t), + code: code?.lerp(other?.code, t), + checkbox: checkbox?.lerp(other?.checkbox, t), + blockContainer: blockContainer.lerp(other?.blockContainer, t), + slideContainer: slideContainer.lerp(other?.slideContainer, t), + image: image.lerp(other?.image, t), + ); + } + + @override + List get props => [ + h1, + h2, + h3, + h4, + h5, + h6, + p, + a, + em, + strong, + del, + img, + link, + textScaleFactor, + alert, + horizontalRuleDecoration, + blockquote, + list, + table, + code, + checkbox, + blockContainer, + slideContainer, + image, + ]; + + @override + bool operator ==(Object other) { + return identical(this, other) || + other is SlideSpec && + runtimeType == other.runtimeType && + propsEquals(props, other.props); + } + + @override + int get hashCode => propsHash(runtimeType, props); + + @override + bool get stringify => true; + + @override + Map getDiff(Equatable other) { + if (this == other) return const {}; + + return propsDiff(props, other.props); + } + + @override + String toStringShort() => '$runtimeType'; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => + toDiagnosticsNode( + style: DiagnosticsTreeStyle.singleLine, + ).toString(minLevel: minLevel); + + @override + DiagnosticsNode toDiagnosticsNode({ + String? name, + DiagnosticsTreeStyle? style, + }) => + DiagnosticableNode(name: name, value: this, style: style); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('h1', h1)) + ..add(DiagnosticsProperty('h2', h2)) + ..add(DiagnosticsProperty('h3', h3)) + ..add(DiagnosticsProperty('h4', h4)) + ..add(DiagnosticsProperty('h5', h5)) + ..add(DiagnosticsProperty('h6', h6)) + ..add(DiagnosticsProperty('p', p)) + ..add(DiagnosticsProperty('a', a)) + ..add(DiagnosticsProperty('em', em)) + ..add(DiagnosticsProperty('strong', strong)) + ..add(DiagnosticsProperty('del', del)) + ..add(DiagnosticsProperty('img', img)) + ..add(DiagnosticsProperty('link', link)) + ..add(DiagnosticsProperty('textScaleFactor', textScaleFactor)) + ..add(DiagnosticsProperty('alert', alert)) + ..add( + DiagnosticsProperty( + 'horizontalRuleDecoration', + horizontalRuleDecoration, + ), + ) + ..add(DiagnosticsProperty('blockquote', blockquote)) + ..add(DiagnosticsProperty('list', list)) + ..add(DiagnosticsProperty('table', table)) + ..add(DiagnosticsProperty('code', code)) + ..add(DiagnosticsProperty('checkbox', checkbox)) + ..add(DiagnosticsProperty('blockContainer', blockContainer)) + ..add(DiagnosticsProperty('slideContainer', slideContainer)) + ..add(DiagnosticsProperty('image', image)); + } +} + +@Deprecated( + 'Rename to `_\$SlideSpec` and migrate the class declaration to `class SlideSpec with _\$SlideSpec`. The `_\$SlideSpecMethods` alias will be removed in mix_generator 3.0.', +) +typedef _$SlideSpecMethods = _$SlideSpec; // ignore: unused_element + +// ************************************************************************** +// StylerGenerator +// ************************************************************************** + +mixin _$SlideStylerMixin on Style, Diagnosticable { + Prop>? get $h1; + Prop>? get $h2; + Prop>? get $h3; + Prop>? get $h4; + Prop>? get $h5; + Prop>? get $h6; + Prop>? get $p; + Prop? get $a; + Prop? get $em; + Prop? get $strong; + Prop? get $del; + Prop? get $img; + Prop? get $link; + Prop? get $textScaleFactor; + Prop>? get $alert; + Prop? get $horizontalRuleDecoration; + Prop>? get $blockquote; + Prop>? get $list; + Prop>? get $table; + Prop>? get $code; + Prop>? get $checkbox; + Prop>? get $blockContainer; + Prop>? get $slideContainer; + Prop>? get $image; + + /// Sets the h1. + SlideStyler h1(TextStyler value) { + return merge(SlideStyler(h1: value)); + } + + /// Sets the h2. + SlideStyler h2(TextStyler value) { + return merge(SlideStyler(h2: value)); + } + + /// Sets the h3. + SlideStyler h3(TextStyler value) { + return merge(SlideStyler(h3: value)); + } + + /// Sets the h4. + SlideStyler h4(TextStyler value) { + return merge(SlideStyler(h4: value)); + } + + /// Sets the h5. + SlideStyler h5(TextStyler value) { + return merge(SlideStyler(h5: value)); + } + + /// Sets the h6. + SlideStyler h6(TextStyler value) { + return merge(SlideStyler(h6: value)); + } + + /// Sets the p. + SlideStyler p(TextStyler value) { + return merge(SlideStyler(p: value)); + } + + /// Sets the a. + SlideStyler a(TextStyleMix value) { + return merge(SlideStyler(a: value)); + } + + /// Sets the em. + SlideStyler em(TextStyleMix value) { + return merge(SlideStyler(em: value)); + } + + /// Sets the strong. + SlideStyler strong(TextStyleMix value) { + return merge(SlideStyler(strong: value)); + } + + /// Sets the del. + SlideStyler del(TextStyleMix value) { + return merge(SlideStyler(del: value)); + } + + /// Sets the img. + SlideStyler img(TextStyleMix value) { + return merge(SlideStyler(img: value)); + } + + /// Sets the link. + SlideStyler link(TextStyleMix value) { + return merge(SlideStyler(link: value)); + } + + /// Sets the textScaleFactor. + SlideStyler textScaleFactor(TextScaler value) { + return merge(SlideStyler(textScaleFactor: value)); + } + + /// Sets the horizontalRuleDecoration. + SlideStyler horizontalRuleDecoration(BoxDecoration value) { + return merge(SlideStyler(horizontalRuleDecoration: value)); + } + + /// Sets the blockContainer. + SlideStyler blockContainer(BoxStyler value) { + return merge(SlideStyler(blockContainer: value)); + } + + /// Sets the slideContainer. + SlideStyler slideContainer(BoxStyler value) { + return merge(SlideStyler(slideContainer: value)); + } + + /// Sets the image. + SlideStyler image(ImageStyler value) { + return merge(SlideStyler(image: value)); + } + + /// Sets the animation configuration. + SlideStyler animate(AnimationConfig value) { + return merge(SlideStyler(animation: value)); + } + + /// Sets the style variants. + SlideStyler variants(List> value) { + return merge(SlideStyler(variants: value)); + } + + /// Wraps with a widget modifier. + SlideStyler wrap(WidgetModifierConfig value) { + return merge(SlideStyler(modifier: value)); + } + + /// Sets the widget modifier. + SlideStyler modifier(WidgetModifierConfig value) { + return merge(SlideStyler(modifier: value)); + } + + /// Merges with another [SlideStyler]. + @override + SlideStyler merge(SlideStyler? other) { + return SlideStyler.create( + h1: MixOps.merge($h1, other?.$h1), + h2: MixOps.merge($h2, other?.$h2), + h3: MixOps.merge($h3, other?.$h3), + h4: MixOps.merge($h4, other?.$h4), + h5: MixOps.merge($h5, other?.$h5), + h6: MixOps.merge($h6, other?.$h6), + p: MixOps.merge($p, other?.$p), + a: MixOps.merge($a, other?.$a), + em: MixOps.merge($em, other?.$em), + strong: MixOps.merge($strong, other?.$strong), + del: MixOps.merge($del, other?.$del), + img: MixOps.merge($img, other?.$img), + link: MixOps.merge($link, other?.$link), + textScaleFactor: MixOps.merge($textScaleFactor, other?.$textScaleFactor), + alert: MixOps.merge($alert, other?.$alert), + horizontalRuleDecoration: MixOps.merge( + $horizontalRuleDecoration, + other?.$horizontalRuleDecoration, + ), + blockquote: MixOps.merge($blockquote, other?.$blockquote), + list: MixOps.merge($list, other?.$list), + table: MixOps.merge($table, other?.$table), + code: MixOps.merge($code, other?.$code), + checkbox: MixOps.merge($checkbox, other?.$checkbox), + blockContainer: MixOps.merge($blockContainer, other?.$blockContainer), + slideContainer: MixOps.merge($slideContainer, other?.$slideContainer), + image: MixOps.merge($image, other?.$image), + variants: MixOps.mergeVariants($variants, other?.$variants), + modifier: MixOps.mergeModifier($modifier, other?.$modifier), + animation: MixOps.mergeAnimation($animation, other?.$animation), + ); + } + + /// Resolves to [StyleSpec] using [context]. + @override + StyleSpec resolve(BuildContext context) { + final spec = SlideSpec( + h1: MixOps.resolve(context, $h1), + h2: MixOps.resolve(context, $h2), + h3: MixOps.resolve(context, $h3), + h4: MixOps.resolve(context, $h4), + h5: MixOps.resolve(context, $h5), + h6: MixOps.resolve(context, $h6), + p: MixOps.resolve(context, $p), + a: MixOps.resolve(context, $a), + em: MixOps.resolve(context, $em), + strong: MixOps.resolve(context, $strong), + del: MixOps.resolve(context, $del), + img: MixOps.resolve(context, $img), + link: MixOps.resolve(context, $link), + textScaleFactor: MixOps.resolve(context, $textScaleFactor), + alert: MixOps.resolve(context, $alert), + horizontalRuleDecoration: MixOps.resolve( + context, + $horizontalRuleDecoration, + ), + blockquote: MixOps.resolve(context, $blockquote), + list: MixOps.resolve(context, $list), + table: MixOps.resolve(context, $table), + code: MixOps.resolve(context, $code), + checkbox: MixOps.resolve(context, $checkbox), + blockContainer: MixOps.resolve(context, $blockContainer), + slideContainer: MixOps.resolve(context, $slideContainer), + image: MixOps.resolve(context, $image), + ); + + return StyleSpec( + spec: spec, + animation: $animation, + widgetModifiers: $modifier?.resolve(context), + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('h1', $h1)) + ..add(DiagnosticsProperty('h2', $h2)) + ..add(DiagnosticsProperty('h3', $h3)) + ..add(DiagnosticsProperty('h4', $h4)) + ..add(DiagnosticsProperty('h5', $h5)) + ..add(DiagnosticsProperty('h6', $h6)) + ..add(DiagnosticsProperty('p', $p)) + ..add(DiagnosticsProperty('a', $a)) + ..add(DiagnosticsProperty('em', $em)) + ..add(DiagnosticsProperty('strong', $strong)) + ..add(DiagnosticsProperty('del', $del)) + ..add(DiagnosticsProperty('img', $img)) + ..add(DiagnosticsProperty('link', $link)) + ..add(DiagnosticsProperty('textScaleFactor', $textScaleFactor)) + ..add(DiagnosticsProperty('alert', $alert)) + ..add( + DiagnosticsProperty( + 'horizontalRuleDecoration', + $horizontalRuleDecoration, + ), + ) + ..add(DiagnosticsProperty('blockquote', $blockquote)) + ..add(DiagnosticsProperty('list', $list)) + ..add(DiagnosticsProperty('table', $table)) + ..add(DiagnosticsProperty('code', $code)) + ..add(DiagnosticsProperty('checkbox', $checkbox)) + ..add(DiagnosticsProperty('blockContainer', $blockContainer)) + ..add(DiagnosticsProperty('slideContainer', $slideContainer)) + ..add(DiagnosticsProperty('image', $image)); + } + + @override + List get props => [ + $h1, + $h2, + $h3, + $h4, + $h5, + $h6, + $p, + $a, + $em, + $strong, + $del, + $img, + $link, + $textScaleFactor, + $alert, + $horizontalRuleDecoration, + $blockquote, + $list, + $table, + $code, + $checkbox, + $blockContainer, + $slideContainer, + $image, + $animation, + $modifier, + $variants, + ]; +} diff --git a/packages/superdeck/lib/src/styling/default_style.dart b/packages/superdeck/lib/src/styling/default_style.dart index 97cda36e..79f55a5d 100644 --- a/packages/superdeck/lib/src/styling/default_style.dart +++ b/packages/superdeck/lib/src/styling/default_style.dart @@ -39,10 +39,10 @@ const onWebview = BlockVariant('webview'); WidgetModifierConfig _pad(EdgeInsetsGeometryMix value) => WidgetModifierConfig.padding(value); -/// Creates the base [SlideStyle] used before user overrides are applied. -SlideStyle _createDefaultSlideStyle() { - MarkdownAlertTypeStyle createAlertType(Color color) { - return MarkdownAlertTypeStyle( +/// Creates the base [SlideStyler] used before user overrides are applied. +SlideStyler _createDefaultSlideStyle() { + MarkdownAlertTypeStyler createAlertType(Color color) { + return MarkdownAlertTypeStyler( heading: TextStyler() .style( TextStyleMix( @@ -78,7 +78,7 @@ SlideStyle _createDefaultSlideStyle() { ); } - return SlideStyle( + return SlideStyler( h1: TextStyler() .style( TextStyleMix( @@ -162,9 +162,11 @@ SlideStyle _createDefaultSlideStyle() { ) .wrap(_pad(EdgeInsetsGeometryMix.only(bottom: 12))), - link: _baseTextStyle.copyWith(color: const Color.fromARGB(255, 66, 82, 96)), + link: TextStyleMix.value( + _baseTextStyle.copyWith(color: const Color.fromARGB(255, 66, 82, 96)), + ), - alert: MarkdownAlertStyle( + alert: MarkdownAlertStyler( note: createAlertType(Colors.blue), tip: createAlertType(Colors.green), important: createAlertType(Colors.deepPurpleAccent), @@ -172,10 +174,12 @@ SlideStyle _createDefaultSlideStyle() { caution: createAlertType(Colors.redAccent), ), - code: MarkdownCodeblockStyle( - textStyle: _safeGoogleFont( - () => GoogleFonts.jetBrainsMono(fontSize: 18), - ).copyWith(height: 1.8), + code: MarkdownCodeblockStyler( + textStyle: TextStyleMix.value( + _safeGoogleFont( + () => GoogleFonts.jetBrainsMono(fontSize: 18), + ).copyWith(height: 1.8), + ), container: BoxStyler( padding: EdgeInsetsMix.all(32), decoration: BoxDecorationMix( @@ -185,9 +189,11 @@ SlideStyle _createDefaultSlideStyle() { ), ), - table: MarkdownTableStyle( - headStyle: _baseTextStyle.copyWith(fontWeight: FontWeight.bold), - bodyStyle: _baseTextStyle, + table: MarkdownTableStyler( + headStyle: TextStyleMix.value( + _baseTextStyle.copyWith(fontWeight: FontWeight.bold), + ), + bodyStyle: TextStyleMix.value(_baseTextStyle), cellPadding: const EdgeInsets.all(12), border: TableBorder.all(color: _baseTextStyle.color!, width: 2), cellDecoration: BoxDecoration( @@ -195,8 +201,8 @@ SlideStyle _createDefaultSlideStyle() { ), ), - blockquote: MarkdownBlockquoteStyle( - textStyle: _baseTextStyle.copyWith(fontSize: 32), + blockquote: MarkdownBlockquoteStyler( + textStyle: TextStyleMix.value(_baseTextStyle.copyWith(fontSize: 32)), padding: const EdgeInsets.only(bottom: 12, left: 30), decoration: BoxDecoration( border: Border( @@ -205,7 +211,7 @@ SlideStyle _createDefaultSlideStyle() { ), ), - list: MarkdownListStyle( + list: MarkdownListStyler( bullet: TextStyler().style( TextStyleMix( fontSize: _baseTextStyle.fontSize, @@ -225,7 +231,9 @@ SlideStyle _createDefaultSlideStyle() { .wrap(_pad(EdgeInsetsGeometryMix.only(bottom: 8))), ), - checkbox: MarkdownCheckboxStyle(textStyle: _baseTextStyle), + checkbox: MarkdownCheckboxStyler( + textStyle: TextStyleMix.value(_baseTextStyle), + ), blockContainer: BoxStyler(padding: EdgeInsetsGeometryMix.all(40)).variants([ VariantStyle(onImage, BoxStyler(padding: EdgeInsetsGeometryMix.all(0))), @@ -255,5 +263,5 @@ SlideStyle _createDefaultSlideStyle() { ); } -/// The shared base [SlideStyle] applied before user overrides. +/// The shared base [SlideStyler] applied before user overrides. final defaultSlideStyle = _createDefaultSlideStyle(); diff --git a/packages/superdeck/pubspec.yaml b/packages/superdeck/pubspec.yaml index a92fb710..92577c0b 100644 --- a/packages/superdeck/pubspec.yaml +++ b/packages/superdeck/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: go_router: ^17.3.0 path_provider: ^2.1.4 mix: ^2.1.0 + mix_annotations: ^2.1.1 remix: ^0.2.0 flutter_markdown_plus: ^1.0.5 superdeck_core: ^1.0.0 @@ -40,10 +41,10 @@ dev_dependencies: sdk: flutter mocktail: ^1.0.4 flutter_lints: ^6.0.0 - custom_lint: ^0.8.1 dart_code_metrics_presets: ^2.19.0 build_runner: ^2.5.4 dart_mappable_builder: ^4.7.0 + mix_generator: ^2.1.1 path_provider_platform_interface: ^2.1.2 superdeck_builder: path: ../builder diff --git a/packages/superdeck/test/helpers/slide_test_harness.dart b/packages/superdeck/test/helpers/slide_test_harness.dart index 708de4e2..6c57bf68 100644 --- a/packages/superdeck/test/helpers/slide_test_harness.dart +++ b/packages/superdeck/test/helpers/slide_test_harness.dart @@ -14,7 +14,7 @@ class SlideTestHarness { static Future pumpSlide( WidgetTester tester, Slide slide, { - SlideStyle? style, + SlideStyler? style, Map widgets = const {}, bool debug = false, Size? resolution, @@ -52,7 +52,7 @@ class SlideTestHarness { /// Creates a [SlideConfiguration] with sensible defaults. static SlideConfiguration createConfiguration( Slide slide, { - SlideStyle? style, + SlideStyler? style, Map widgets = const {}, bool debug = false, int slideIndex = 0, diff --git a/packages/superdeck/test/helpers/test_helpers.dart b/packages/superdeck/test/helpers/test_helpers.dart index 056306a1..a0499dec 100644 --- a/packages/superdeck/test/helpers/test_helpers.dart +++ b/packages/superdeck/test/helpers/test_helpers.dart @@ -23,7 +23,7 @@ List createTestSlides(int count) { count, (index) => SlideConfiguration( slideIndex: index, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: 'slide-$index', sections: [ @@ -39,13 +39,13 @@ List createTestSlides(int count) { SlideConfiguration createTestSlide({ required int index, String? content, - SlideStyle? style, + SlideStyler? style, String? thumbnailKey, }) { final slideKey = 'slide-$index'; return SlideConfiguration( slideIndex: index, - style: style ?? SlideStyle(), + style: style ?? SlideStyler(), slide: Slide( key: slideKey, sections: [ diff --git a/packages/superdeck/test/src/builtins/dartpad_widget_test.dart b/packages/superdeck/test/src/builtins/dartpad_widget_test.dart index a23b6123..8aefb2f6 100644 --- a/packages/superdeck/test/src/builtins/dartpad_widget_test.dart +++ b/packages/superdeck/test/src/builtins/dartpad_widget_test.dart @@ -417,7 +417,7 @@ class _DartPadHarness extends StatelessWidget { Widget build(BuildContext context) { final slide = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: 'slide-0', sections: [ diff --git a/packages/superdeck/test/src/builtins/webview_widget_test.dart b/packages/superdeck/test/src/builtins/webview_widget_test.dart index 73a9d399..33665812 100644 --- a/packages/superdeck/test/src/builtins/webview_widget_test.dart +++ b/packages/superdeck/test/src/builtins/webview_widget_test.dart @@ -699,7 +699,7 @@ class _TwoWebViewsHarness extends StatelessWidget { Widget build(BuildContext context) { final slide = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: 'slide-0', sections: [ @@ -756,7 +756,7 @@ class _WebViewHarness extends StatelessWidget { Widget build(BuildContext context) { final slide = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: 'slide-0', sections: [ diff --git a/packages/superdeck/test/src/capture/thumbnail_capture_timing_test.dart b/packages/superdeck/test/src/capture/thumbnail_capture_timing_test.dart index 6a908b7a..7ddd98b5 100644 --- a/packages/superdeck/test/src/capture/thumbnail_capture_timing_test.dart +++ b/packages/superdeck/test/src/capture/thumbnail_capture_timing_test.dart @@ -73,7 +73,7 @@ class _DelayedWidgetState extends State<_DelayedWidget> { SlideConfiguration _slide(String key, String content) { return SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: key, sections: [ @@ -87,7 +87,7 @@ SlideConfiguration _slide(String key, String content) { SlideConfiguration _slideWithParts(String key, String content) { return SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), parts: const SlideParts(), slide: Slide( key: key, @@ -105,7 +105,7 @@ SlideConfiguration _delayedSlide({ }) { return SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide( key: 'delayed', sections: [ diff --git a/packages/superdeck/test/src/deck/deck_options_test.dart b/packages/superdeck/test/src/deck/deck_options_test.dart index 70d682ba..bd2e9311 100644 --- a/packages/superdeck/test/src/deck/deck_options_test.dart +++ b/packages/superdeck/test/src/deck/deck_options_test.dart @@ -6,7 +6,7 @@ void main() { group('DeckOptions', () { group('equality', () { test('two instances with same-content maps are equal', () { - final style = SlideStyle(); + final style = SlideStyler(); final a = DeckOptions( styles: {'s': style}, widgets: {}, @@ -27,10 +27,10 @@ void main() { test( 'modifying original map after construction does not affect stored map', () { - final styles = {'a': SlideStyle()}; + final styles = {'a': SlideStyler()}; final options = DeckOptions(styles: styles); - styles['b'] = SlideStyle(); + styles['b'] = SlideStyler(); expect(options.styles.length, 1); expect(options.styles.containsKey('b'), isFalse); @@ -38,10 +38,10 @@ void main() { ); test('mutation attempt on styles throws UnsupportedError', () { - final options = DeckOptions(styles: {'a': SlideStyle()}); + final options = DeckOptions(styles: {'a': SlideStyler()}); expect( - () => options.styles['b'] = SlideStyle(), + () => options.styles['b'] = SlideStyler(), throwsUnsupportedError, ); }); @@ -67,7 +67,7 @@ void main() { group('copyWith sentinel', () { test('copyWith() with no args preserves existing baseStyle', () { - final style = SlideStyle(); + final style = SlideStyler(); final options = DeckOptions(baseStyle: style); final copy = options.copyWith(); @@ -75,7 +75,7 @@ void main() { }); test('copyWith(baseStyle: null) clears a previously set baseStyle', () { - final style = SlideStyle(); + final style = SlideStyler(); final options = DeckOptions(baseStyle: style); final copy = options.copyWith(baseStyle: null); diff --git a/packages/superdeck/test/src/deck/slide_configuration_builder_test.dart b/packages/superdeck/test/src/deck/slide_configuration_builder_test.dart index b85bfbbd..6f0703bc 100644 --- a/packages/superdeck/test/src/deck/slide_configuration_builder_test.dart +++ b/packages/superdeck/test/src/deck/slide_configuration_builder_test.dart @@ -13,7 +13,7 @@ void main() { }); test('when no template is set, applies deck styles', () { - final baseStyle = SlideStyle(); + final baseStyle = SlideStyler(); final options = DeckOptions(baseStyle: baseStyle); final slides = [Slide(key: 'slide-1')]; @@ -25,7 +25,7 @@ void main() { }); test('slide with named style resolves from deck styles', () { - final namedStyle = SlideStyle(); + final namedStyle = SlideStyler(); final options = DeckOptions(styles: {'dark': namedStyle}); final slides = [ Slide( @@ -40,7 +40,7 @@ void main() { }); test('slide with template uses template parts and style', () { - final templateBase = SlideStyle(); + final templateBase = SlideStyler(); final templateParts = SlideParts(); final template = SlideTemplate( baseStyle: templateBase, @@ -64,7 +64,7 @@ void main() { }); test('slide with template + style uses template style variants', () { - final variant = SlideStyle(); + final variant = SlideStyler(); final template = SlideTemplate(styles: {'highlight': variant}); final options = DeckOptions(templates: {'t': template}); final slides = [ @@ -80,7 +80,7 @@ void main() { }); test('defaultTemplate applies to slides without explicit template', () { - final defaultTemplate = SlideTemplate(baseStyle: SlideStyle()); + final defaultTemplate = SlideTemplate(baseStyle: SlideStyler()); final options = DeckOptions(defaultTemplate: defaultTemplate); final slides = [Slide(key: 'default-tmpl')]; @@ -90,8 +90,8 @@ void main() { }); test('template: "none" opts out of defaultTemplate', () { - final defaultTemplate = SlideTemplate(baseStyle: SlideStyle()); - final deckBase = SlideStyle(); + final defaultTemplate = SlideTemplate(baseStyle: SlideStyler()); + final deckBase = SlideStyler(); final options = DeckOptions( defaultTemplate: defaultTemplate, baseStyle: deckBase, @@ -125,8 +125,8 @@ void main() { }); test('mixed slides — some with template, some without', () { - final template = SlideTemplate(baseStyle: SlideStyle()); - final deckBase = SlideStyle(); + final template = SlideTemplate(baseStyle: SlideStyler()); + final deckBase = SlideStyler(); final options = DeckOptions( baseStyle: deckBase, templates: {'t': template}, diff --git a/packages/superdeck/test/src/deck/slide_configuration_test.dart b/packages/superdeck/test/src/deck/slide_configuration_test.dart index 9f28e5ce..9c8c87b9 100644 --- a/packages/superdeck/test/src/deck/slide_configuration_test.dart +++ b/packages/superdeck/test/src/deck/slide_configuration_test.dart @@ -12,14 +12,14 @@ void main() { final slide = Slide(key: 'slide-1'); final a = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: slide, thumbnailKey: 'thumbnail_slide-1.png', widgets: widgets, ); final b = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: slide, thumbnailKey: 'thumbnail_slide-1.png', widgets: widgets, @@ -32,14 +32,14 @@ void main() { final slide = Slide(key: 'slide-1'); final a = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: slide, thumbnailKey: 'thumbnail_slide-1.png', widgets: {'same': _sameWidget}, ); final b = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: slide, thumbnailKey: 'thumbnail_slide-1.png', widgets: {'same': _sameWidget}, diff --git a/packages/superdeck/test/src/deck/slide_template_test.dart b/packages/superdeck/test/src/deck/slide_template_test.dart index 8de0774e..322393be 100644 --- a/packages/superdeck/test/src/deck/slide_template_test.dart +++ b/packages/superdeck/test/src/deck/slide_template_test.dart @@ -14,8 +14,8 @@ void main() { test('all-parameter constructor stores supplied values', () { final parts = SlideParts(); - final baseStyle = SlideStyle(); - final variants = {'dark': SlideStyle()}; + final baseStyle = SlideStyler(); + final variants = {'dark': SlideStyler()}; final template = SlideTemplate( parts: parts, @@ -43,7 +43,7 @@ void main() { test('copies baseStyle field when supplied', () { const original = SlideTemplate(); - final newStyle = SlideStyle(); + final newStyle = SlideStyler(); final copy = original.copyWith(baseStyle: newStyle); @@ -54,7 +54,7 @@ void main() { test('copies styles field when supplied', () { const original = SlideTemplate(); - final newStyles = {'light': SlideStyle()}; + final newStyles = {'light': SlideStyler()}; final copy = original.copyWith(styles: newStyles); @@ -66,25 +66,25 @@ void main() { final parts = SlideParts(); final original = SlideTemplate(parts: parts); - final copy = original.copyWith(baseStyle: SlideStyle()); + final copy = original.copyWith(baseStyle: SlideStyler()); expect(copy.parts, same(parts)); }); test('preserves baseStyle when not specified', () { - final baseStyle = SlideStyle(); + final baseStyle = SlideStyler(); final original = SlideTemplate(baseStyle: baseStyle); - final copy = original.copyWith(styles: {'x': SlideStyle()}); + final copy = original.copyWith(styles: {'x': SlideStyler()}); expect(copy.baseStyle, same(baseStyle)); }); test('preserves styles when not specified', () { - final styles = {'a': SlideStyle()}; + final styles = {'a': SlideStyler()}; final original = SlideTemplate(styles: styles); - final copy = original.copyWith(baseStyle: SlideStyle()); + final copy = original.copyWith(baseStyle: SlideStyler()); expect(copy.styles, same(styles)); }); @@ -115,24 +115,24 @@ void main() { test('templates with different baseStyles are not equal', () { final parts = SlideParts(); - final a = SlideTemplate(parts: parts, baseStyle: SlideStyle()); + final a = SlideTemplate(parts: parts, baseStyle: SlideStyler()); final b = SlideTemplate(parts: parts); expect(a, isNot(equals(b))); }); test('templates with equal baseStyles are equal', () { - // SlideStyle uses Equatable, so two instances with same args are equal. + // SlideStyler uses Equatable, so two instances with same args are equal. final parts = SlideParts(); - final a = SlideTemplate(parts: parts, baseStyle: SlideStyle()); - final b = SlideTemplate(parts: parts, baseStyle: SlideStyle()); + final a = SlideTemplate(parts: parts, baseStyle: SlideStyler()); + final b = SlideTemplate(parts: parts, baseStyle: SlideStyler()); expect(a, equals(b)); }); test('templates with different styles maps are not equal', () { final parts = SlideParts(); - final a = SlideTemplate(parts: parts, styles: {'dark': SlideStyle()}); + final a = SlideTemplate(parts: parts, styles: {'dark': SlideStyler()}); final b = SlideTemplate(parts: parts, styles: {}); expect(a, isNot(equals(b))); @@ -140,7 +140,7 @@ void main() { test('templates sharing the same styles map instance are equal', () { final parts = SlideParts(); - final styles = {'dark': SlideStyle()}; + final styles = {'dark': SlideStyler()}; final a = SlideTemplate(parts: parts, styles: styles); final b = SlideTemplate(parts: parts, styles: styles); @@ -149,8 +149,8 @@ void main() { test('templates with same-content styles maps are not equal', () { final parts = SlideParts(); - final a = SlideTemplate(parts: parts, styles: {'dark': SlideStyle()}); - final b = SlideTemplate(parts: parts, styles: {'dark': SlideStyle()}); + final a = SlideTemplate(parts: parts, styles: {'dark': SlideStyler()}); + final b = SlideTemplate(parts: parts, styles: {'dark': SlideStyler()}); expect(a, isNot(equals(b))); }); @@ -159,8 +159,8 @@ void main() { group('hashCode', () { test('equal templates have the same hashCode', () { final parts = SlideParts(); - final baseStyle = SlideStyle(); - final styles = {'x': SlideStyle()}; + final baseStyle = SlideStyler(); + final styles = {'x': SlideStyler()}; final a = SlideTemplate( parts: parts, diff --git a/packages/superdeck/test/src/deck/template_resolver_test.dart b/packages/superdeck/test/src/deck/template_resolver_test.dart index eeff3d4b..05901c35 100644 --- a/packages/superdeck/test/src/deck/template_resolver_test.dart +++ b/packages/superdeck/test/src/deck/template_resolver_test.dart @@ -11,7 +11,7 @@ void main() { test( 'no template, no style — returns defaultSlideStyle merged with options.baseStyle', () { - final baseStyle = SlideStyle(); + final baseStyle = SlideStyler(); final options = DeckOptions(baseStyle: baseStyle); final resolver = TemplateResolver(options); @@ -40,7 +40,7 @@ void main() { test( 'no template, with style — resolves style from options.styles map', () { - final namedStyle = SlideStyle(); + final namedStyle = SlideStyler(); final options = DeckOptions(styles: {'dark': namedStyle}); final resolver = TemplateResolver(options); final slideOptions = SlideOptions(style: 'dark'); @@ -56,12 +56,12 @@ void main() { 'merge order is defaultSlideStyle -> baseStyle -> named style (last wins)', () { // Concrete last-wins check: named style overrides baseStyle fields. - final baseStyle = SlideStyle( - strong: const TextStyle(color: Color(0xFFFF0000)), - link: const TextStyle(color: Color(0xFF00FF00)), + final baseStyle = SlideStyler( + strong: TextStyleMix.color(const Color(0xFFFF0000)), + link: TextStyleMix.color(const Color(0xFF00FF00)), ); - final namedStyle = SlideStyle( - strong: const TextStyle(color: Color(0xFF0000FF)), + final namedStyle = SlideStyler( + strong: TextStyleMix.color(const Color(0xFF0000FF)), ); final options = DeckOptions( baseStyle: baseStyle, @@ -71,9 +71,7 @@ void main() { final result = resolver.resolve(SlideOptions(style: 'accent')); - final expected = defaultSlideStyle - .merge(baseStyle) - .merge(namedStyle); + final expected = defaultSlideStyle.merge(baseStyle).merge(namedStyle); expect(result.style, expected); // Named strong replaces base strong; link from base remains. expect(result.style, isNot(defaultSlideStyle.merge(baseStyle))); @@ -82,7 +80,7 @@ void main() { ); test('no template, unknown style — throws ArgumentError', () { - final options = DeckOptions(styles: {'light': SlideStyle()}); + final options = DeckOptions(styles: {'light': SlideStyler()}); final resolver = TemplateResolver(options); final slideOptions = SlideOptions(style: 'nonexistent'); @@ -96,7 +94,7 @@ void main() { 'no template, unknown style — exception message includes "in deck" and style name', () { final options = DeckOptions( - styles: {'light': SlideStyle(), 'dark': SlideStyle()}, + styles: {'light': SlideStyler(), 'dark': SlideStyler()}, ); final resolver = TemplateResolver(options); final slideOptions = SlideOptions(style: 'missing'); @@ -117,7 +115,7 @@ void main() { group('With template', () { test('valid template — uses template baseStyle and parts', () { - final templateBaseStyle = SlideStyle(); + final templateBaseStyle = SlideStyler(); final template = SlideTemplate(baseStyle: templateBaseStyle); final options = DeckOptions(templates: {'hero': template}); final resolver = TemplateResolver(options); @@ -146,7 +144,7 @@ void main() { }); test('template + style — uses template styles map', () { - final templateStyle = SlideStyle(); + final templateStyle = SlideStyler(); final template = SlideTemplate(styles: {'accent': templateStyle}); final options = DeckOptions(templates: {'branded': template}); final resolver = TemplateResolver(options); @@ -162,7 +160,7 @@ void main() { }); test('template, unknown style — throws ArgumentError', () { - final template = SlideTemplate(styles: {'known': SlideStyle()}); + final template = SlideTemplate(styles: {'known': SlideStyler()}); final options = DeckOptions(templates: {'myTemplate': template}); final resolver = TemplateResolver(options); final slideOptions = SlideOptions( @@ -179,7 +177,7 @@ void main() { test( 'template, unknown style — exception message includes template name and style name', () { - final template = SlideTemplate(styles: {'valid': SlideStyle()}); + final template = SlideTemplate(styles: {'valid': SlideStyler()}); final options = DeckOptions(templates: {'corporate': template}); final resolver = TemplateResolver(options); final slideOptions = SlideOptions( @@ -257,7 +255,7 @@ void main() { group('defaultTemplate', () { test('defaultTemplate used when slide has no explicit template', () { - final templateBaseStyle = SlideStyle(); + final templateBaseStyle = SlideStyler(); final defaultTemplate = SlideTemplate(baseStyle: templateBaseStyle); final options = DeckOptions(defaultTemplate: defaultTemplate); final resolver = TemplateResolver(options); @@ -273,8 +271,8 @@ void main() { }); test('explicit template overrides defaultTemplate', () { - final defaultTemplateStyle = SlideStyle(); - final explicitTemplateStyle = SlideStyle(); + final defaultTemplateStyle = SlideStyler(); + final explicitTemplateStyle = SlideStyler(); final defaultTemplate = SlideTemplate(baseStyle: defaultTemplateStyle); final explicitTemplate = SlideTemplate( @@ -311,8 +309,8 @@ void main() { }); test('template: "none" opts out of defaultTemplate', () { - final defaultTemplate = SlideTemplate(baseStyle: SlideStyle()); - final baseStyle = SlideStyle(); + final defaultTemplate = SlideTemplate(baseStyle: SlideStyler()); + final baseStyle = SlideStyler(); final options = DeckOptions( defaultTemplate: defaultTemplate, baseStyle: baseStyle, @@ -328,8 +326,8 @@ void main() { }); test('template: "none" uses deck-level styles, not template styles', () { - final deckStyle = SlideStyle(); - final templateStyle = SlideStyle(); + final deckStyle = SlideStyler(); + final templateStyle = SlideStyler(); final options = DeckOptions( defaultTemplate: SlideTemplate(baseStyle: templateStyle), styles: {'accent': deckStyle}, @@ -347,7 +345,7 @@ void main() { 'defaultTemplate unknown style message identifies defaultTemplate', () { final defaultTemplate = SlideTemplate( - styles: {'known': SlideStyle()}, + styles: {'known': SlideStyler()}, ); final options = DeckOptions(defaultTemplate: defaultTemplate); final resolver = TemplateResolver(options); @@ -384,8 +382,8 @@ void main() { test( 'without template: defaultSlideStyle → options.baseStyle → options.styles[style]', () { - final baseStyle = SlideStyle(); - final namedStyle = SlideStyle(); + final baseStyle = SlideStyler(); + final namedStyle = SlideStyler(); final options = DeckOptions( baseStyle: baseStyle, styles: {'variant': namedStyle}, @@ -404,8 +402,8 @@ void main() { test( 'with template: defaultSlideStyle → template.baseStyle → template.styles[style]', () { - final templateBase = SlideStyle(); - final templateVariant = SlideStyle(); + final templateBase = SlideStyler(); + final templateVariant = SlideStyler(); final template = SlideTemplate( baseStyle: templateBase, styles: {'highlight': templateVariant}, @@ -430,7 +428,7 @@ void main() { test( 'with template and no style variant: defaultSlideStyle → template.baseStyle', () { - final templateBase = SlideStyle(); + final templateBase = SlideStyler(); final template = SlideTemplate(baseStyle: templateBase); final options = DeckOptions(templates: {'simple': template}); final resolver = TemplateResolver(options); @@ -445,8 +443,8 @@ void main() { ); test('options.baseStyle is not applied when a named template is used', () { - final optionsBaseStyle = SlideStyle(); - final templateBase = SlideStyle(); + final optionsBaseStyle = SlideStyler(); + final templateBase = SlideStyler(); final template = SlideTemplate(baseStyle: templateBase); final options = DeckOptions( baseStyle: optionsBaseStyle, @@ -549,7 +547,7 @@ void main() { } test('layout normal behaves like omitted layout', () { - final baseStyle = SlideStyle(); + final baseStyle = SlideStyler(); final options = DeckOptions(baseStyle: baseStyle); final resolver = TemplateResolver(options); @@ -640,7 +638,7 @@ void main() { ); test('preserves resolved style without layout-specific overrides', () { - final baseStyle = SlideStyle( + final baseStyle = SlideStyler( blockContainer: BoxStyler( padding: EdgeInsetsGeometryMix.all(32), margin: EdgeInsetsGeometryMix.all(16), diff --git a/packages/superdeck/test/src/markdown/builders/text_element_builder_test.dart b/packages/superdeck/test/src/markdown/builders/text_element_builder_test.dart index 5dd02799..d3914953 100644 --- a/packages/superdeck/test/src/markdown/builders/text_element_builder_test.dart +++ b/packages/superdeck/test/src/markdown/builders/text_element_builder_test.dart @@ -80,7 +80,7 @@ void main() { // 4. They do NOT apply custom styles to the text ✗ // // To apply custom styles, use: - // - SlideStyle configurations in DeckOptions + // - SlideStyler configurations in DeckOptions // - Named slide styles via frontmatter (style: hero) // - Direct Mix styling in widget configurations diff --git a/packages/superdeck/test/src/markdown/builders/text_element_builder_widget_test.dart b/packages/superdeck/test/src/markdown/builders/text_element_builder_widget_test.dart index 0ef38830..bc4045f7 100644 --- a/packages/superdeck/test/src/markdown/builders/text_element_builder_widget_test.dart +++ b/packages/superdeck/test/src/markdown/builders/text_element_builder_widget_test.dart @@ -577,7 +577,7 @@ class _MarkdownHarness extends StatelessWidget { final styleSheet = slideSpec.toStyle(); final slideConfiguration = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: 'test-slide'), thumbnailKey: 'thumb.png', ); diff --git a/packages/superdeck/test/src/markdown/image_cache_resolution_test.dart b/packages/superdeck/test/src/markdown/image_cache_resolution_test.dart index 86e928cf..a5be560b 100644 --- a/packages/superdeck/test/src/markdown/image_cache_resolution_test.dart +++ b/packages/superdeck/test/src/markdown/image_cache_resolution_test.dart @@ -111,7 +111,7 @@ class _MarkdownHarness extends StatelessWidget { final styleSheet = slideSpec.toStyle(); final slideConfiguration = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: 'slide'), thumbnailKey: 'thumb.png', assetCacheStore: assetCacheStore, diff --git a/packages/superdeck/test/src/markdown/image_element_rendering_test.dart b/packages/superdeck/test/src/markdown/image_element_rendering_test.dart index c51ab7aa..341959b1 100644 --- a/packages/superdeck/test/src/markdown/image_element_rendering_test.dart +++ b/packages/superdeck/test/src/markdown/image_element_rendering_test.dart @@ -238,7 +238,7 @@ class _MarkdownHarness extends StatelessWidget { final styleSheet = slideSpec.toStyle(); final slideConfiguration = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: 'slide'), thumbnailKey: 'thumb.png', ); diff --git a/packages/superdeck/test/src/markdown/markdown_builders_test.dart b/packages/superdeck/test/src/markdown/markdown_builders_test.dart index 4f198577..6c5dcc81 100644 --- a/packages/superdeck/test/src/markdown/markdown_builders_test.dart +++ b/packages/superdeck/test/src/markdown/markdown_builders_test.dart @@ -237,7 +237,7 @@ class _MarkdownHarness extends StatelessWidget { final styleSheet = slideSpec.toStyle(); final slideConfiguration = SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: 'slide'), thumbnailKey: 'thumb.png', ); diff --git a/packages/superdeck/test/src/rendering/block_widget_test.dart b/packages/superdeck/test/src/rendering/block_widget_test.dart index 594c36a6..85bc6617 100644 --- a/packages/superdeck/test/src/rendering/block_widget_test.dart +++ b/packages/superdeck/test/src/rendering/block_widget_test.dart @@ -1,7 +1,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mix/mix.dart'; -import 'package:superdeck/superdeck.dart' show BlockVariant, SlideStyle; +import 'package:superdeck/superdeck.dart' show BlockVariant, SlideStyler; import 'package:superdeck/src/rendering/blocks/block_provider.dart'; import 'package:superdeck/src/rendering/blocks/block_widget.dart'; import 'package:superdeck_core/superdeck_core.dart'; @@ -236,7 +236,7 @@ void main() { ]), ], ), - style: SlideStyle( + style: SlideStyler( blockContainer: BoxStyler(padding: EdgeInsetsGeometryMix.all(40)) .variants([ VariantStyle( @@ -281,7 +281,7 @@ void main() { ]), ], ), - style: SlideStyle( + style: SlideStyler( blockContainer: BoxStyler(padding: EdgeInsetsGeometryMix.all(40)) .variants([ VariantStyle( @@ -318,7 +318,7 @@ void main() { SectionBlock([WidgetBlock(name: 'image')]), ], ), - style: SlideStyle( + style: SlideStyler( blockContainer: BoxStyler(padding: EdgeInsetsGeometryMix.all(40)) .variants([ VariantStyle( @@ -428,7 +428,7 @@ void main() { SectionBlock([WidgetBlock(name: 'webview')]), ], ), - style: SlideStyle( + style: SlideStyler( blockContainer: BoxStyler( padding: EdgeInsetsGeometryMix.all(10), diff --git a/packages/superdeck/test/src/rendering/slide_view_test.dart b/packages/superdeck/test/src/rendering/slide_view_test.dart index deefa900..b1b26ef1 100644 --- a/packages/superdeck/test/src/rendering/slide_view_test.dart +++ b/packages/superdeck/test/src/rendering/slide_view_test.dart @@ -87,7 +87,7 @@ void main() { final config = SlideConfiguration( slide: slide, slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), thumbnailKey: '', ); @@ -244,7 +244,7 @@ void main() { const SlideConfigurationBuilder().buildConfigurations( [slide], DeckOptions( - baseStyle: SlideStyle( + baseStyle: SlideStyler( blockContainer: BoxStyler( padding: EdgeInsetsGeometryMix.all(40), diff --git a/packages/superdeck/test/src/thumbnails/thumbnail_integration_test.dart b/packages/superdeck/test/src/thumbnails/thumbnail_integration_test.dart index b45c1fb6..2770f0a5 100644 --- a/packages/superdeck/test/src/thumbnails/thumbnail_integration_test.dart +++ b/packages/superdeck/test/src/thumbnails/thumbnail_integration_test.dart @@ -39,7 +39,7 @@ String _thumbnailKey(String slideKey) => 'thumbnail_$slideKey.png'; SlideConfiguration _slide(String key, {String? thumbnailKey}) { return SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: key), thumbnailKey: thumbnailKey ?? _thumbnailKey(key), ); diff --git a/packages/superdeck/test/src/thumbnails/thumbnail_service_test.dart b/packages/superdeck/test/src/thumbnails/thumbnail_service_test.dart index 4444f77d..97354dde 100644 --- a/packages/superdeck/test/src/thumbnails/thumbnail_service_test.dart +++ b/packages/superdeck/test/src/thumbnails/thumbnail_service_test.dart @@ -47,7 +47,7 @@ String _thumbnailKey(String key, {String? suffix}) { SlideConfiguration _createSlide(String key, {String? thumbnailKey}) { return SlideConfiguration( slideIndex: 0, - style: SlideStyle(), + style: SlideStyler(), slide: Slide(key: key), thumbnailKey: thumbnailKey ?? _thumbnailKey(key), ); From 27f8b9f546e0b739399627b533917a0d8cb4bfb4 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 10 Jul 2026 19:35:55 -0400 Subject: [PATCH 2/5] docs: point root changelog at per-package changelogs The root CHANGELOG.md was a drifted copy of packages/superdeck's (stale at 1.0.0, missing the Unreleased section). Per-package changelogs are the source of truth in this monorepo; make the root file a pointer so it cannot drift again. --- CHANGELOG.md | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9d0eaf5..267a5e7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,8 @@ -## 1.0.0 +# Changelog -* First stable release of SuperDeck -* Roll back experimental setext-heading hero parsing; ATX headers continue to use the shared helper -* Fix image hero-tag parsing to avoid inline parser overruns and keep Flutter/core paths aligned -* Document the shared `{.hero}` helper and scope so future contributions stay consistent +SuperDeck is a monorepo; each package keeps its own changelog: -### 0.0.4 - -* Fix: Better error handling when external asset tooling is not installed -* Enhancement: Improved asset generation pipeline - -### 0.0.3 - -* Cleaned up dependencies -* Updated example code -* Improved logging -* Fixed and improved asset generation - -## 0.0.2 - -* Added demo and example code - -## 0.0.1 - -* Initial version +- [`superdeck`](packages/superdeck/CHANGELOG.md) — the Flutter presentation framework +- [`superdeck_core`](packages/core/CHANGELOG.md) — parsing, models, and schema validation +- [`superdeck_cli`](packages/cli/CHANGELOG.md) — the `superdeck` command-line tool +- [`superdeck_builder`](packages/builder/CHANGELOG.md) — build_runner integration From 5935b66b0ff8b7a5d89d6eab478431f675f5fe7e Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Sat, 11 Jul 2026 14:49:35 -0400 Subject: [PATCH 3/5] test: pin field-wise TextStyle merge accumulation through style cascade --- .../test/src/deck/template_resolver_test.dart | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/superdeck/test/src/deck/template_resolver_test.dart b/packages/superdeck/test/src/deck/template_resolver_test.dart index 05901c35..42847f5f 100644 --- a/packages/superdeck/test/src/deck/template_resolver_test.dart +++ b/packages/superdeck/test/src/deck/template_resolver_test.dart @@ -73,12 +73,54 @@ void main() { final expected = defaultSlideStyle.merge(baseStyle).merge(namedStyle); expect(result.style, expected); - // Named strong replaces base strong; link from base remains. + // Named `strong` overrides the base `strong` color field-wise; `link` + // from base remains. expect(result.style, isNot(defaultSlideStyle.merge(baseStyle))); expect(result.style, isNot(defaultSlideStyle.merge(namedStyle))); }, ); + testWidgets( + 'merged text styles accumulate field-wise through the cascade', + (tester) async { + const grey = Color(0xFF9E9E9E); + const red = Color(0xFFFF0000); + + // Base sets two fields; the named override touches only `color`. + final baseStyle = SlideStyler( + strong: TextStyleMix(fontSize: 24, color: grey), + ); + final namedStyle = SlideStyler(strong: TextStyleMix.color(red)); + final options = DeckOptions( + baseStyle: baseStyle, + styles: {'accent': namedStyle}, + ); + final resolver = TemplateResolver(options); + + late final StyleSpec resolved; + await tester.pumpWidget( + Builder( + builder: (context) { + resolved = resolver + .resolve(SlideOptions(style: 'accent')) + .style + .resolve(context); + return const SizedBox(); + }, + ), + ); + + final strong = resolved.spec.strong; + expect(strong, isNotNull); + // Override wins on the contested field... + expect(strong!.color, red); + // ...while the base's untouched field survives. Replacement semantics + // (Prop.maybe) would resolve `strong` to `{color: red}` alone, leaving + // fontSize null — this assertion is the guard against that regression. + expect(strong.fontSize, 24.0); + }, + ); + test('no template, unknown style — throws ArgumentError', () { final options = DeckOptions(styles: {'light': SlideStyler()}); final resolver = TemplateResolver(options); From 964248d0f141a480e98f4295e54d8c8fb4786a9d Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Sun, 12 Jul 2026 09:32:41 -0400 Subject: [PATCH 4/5] refactor: generate nested Mix stylers by convention --- packages/superdeck/build.yaml | 21 +- .../styling/components/markdown_alert.dart | 90 ------- .../styling/components/markdown_alert.g.dart | 89 ++++++- .../components/markdown_alert_type.dart | 6 - .../styling/components/markdown_checkbox.dart | 1 - .../components/markdown_codeblock.dart | 1 - .../src/styling/components/markdown_list.dart | 2 - .../lib/src/styling/components/slide.dart | 237 ------------------ .../lib/src/styling/components/slide.g.dart | 231 +++++++++++++++-- packages/superdeck/pubspec.yaml | 4 +- .../test/src/deck/template_resolver_test.dart | 37 +++ 11 files changed, 333 insertions(+), 386 deletions(-) diff --git a/packages/superdeck/build.yaml b/packages/superdeck/build.yaml index c271c151..d8964b29 100644 --- a/packages/superdeck/build.yaml +++ b/packages/superdeck/build.yaml @@ -6,30 +6,23 @@ targets: enabled: true generate_for: - lib/src/styling/components/*.dart - # Full generated *Styler classes — LEAF specs only. A spec qualifies as a - # leaf when every nested StyleSpec field points at a mix built-in - # (TextSpec, BoxSpec, ...): @MixableField(setterType:) can only reference - # types that already resolve during generation, and same-package - # generated stylers never do (build phases hide later-phase outputs from - # the resolver), degrading silently to value semantics. Aggregators that - # nest SuperDeck's own specs (slide.dart, markdown_alert.dart) are - # excluded here and use hand-written stylers with the legacy mixin below. + # Full generated stylers for every annotated styling spec. The nested + # styler convention derives each StyleSpec field's XStyler, + # including SuperDeck's same-package generated stylers. mix_generator:spec_styler_generator: enabled: true generate_for: + - lib/src/styling/components/markdown_alert.dart - lib/src/styling/components/markdown_alert_type.dart - lib/src/styling/components/markdown_blockquote.dart - lib/src/styling/components/markdown_checkbox.dart - lib/src/styling/components/markdown_codeblock.dart - lib/src/styling/components/markdown_list.dart - lib/src/styling/components/markdown_table.dart - # Legacy @MixableStyler mixins (_$XStyleMixin) for the hand-written - # aggregator stylers noted above. - mix_generator:styler_generator: - enabled: true - generate_for: - lib/src/styling/components/slide.dart - - lib/src/styling/components/markdown_alert.dart + # All styling classes are now generated from @MixableSpec. + mix_generator:styler_generator: + enabled: false # Unused mix builders — keep them off superdeck sources. mix_generator:mixable_generator: enabled: false diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert.dart b/packages/superdeck/lib/src/styling/components/markdown_alert.dart index a480db23..c766ad8a 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert.dart @@ -1,11 +1,3 @@ -// The styler below stays hand-written on the legacy @MixableStyler mixin -// path: its fields nest same-package generated stylers -// (MarkdownAlertTypeStyler), which @MixableSpec's spec_styler_generator can -// only wire up through @MixableField(setterType:) — and annotation type -// arguments cannot reference same-package generated classes (build phases -// hide them from the resolver, degrading silently to value semantics). -// ignore_for_file: deprecated_member_use - import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; @@ -45,87 +37,5 @@ final class MarkdownAlertSpec with _$MarkdownAlertSpec { caution = caution ?? const StyleSpec(spec: MarkdownAlertTypeSpec()); } -/// Style class for configuring [MarkdownAlertSpec] properties. -@MixableStyler() -final class MarkdownAlertStyler - extends MixStyler - with _$MarkdownAlertStylerMixin { - @override - @MixableField(ignoreSetter: true) - final Prop>? $note; - @override - @MixableField(ignoreSetter: true) - final Prop>? $tip; - @override - @MixableField(ignoreSetter: true) - final Prop>? $important; - @override - @MixableField(ignoreSetter: true) - final Prop>? $warning; - @override - @MixableField(ignoreSetter: true) - final Prop>? $caution; - - const MarkdownAlertStyler.create({ - Prop>? note, - Prop>? tip, - Prop>? important, - Prop>? warning, - Prop>? caution, - required super.variants, - required super.animation, - required super.modifier, - }) : $note = note, - $tip = tip, - $important = important, - $warning = warning, - $caution = caution; - - MarkdownAlertStyler({ - MarkdownAlertTypeStyler? note, - MarkdownAlertTypeStyler? tip, - MarkdownAlertTypeStyler? important, - MarkdownAlertTypeStyler? warning, - MarkdownAlertTypeStyler? caution, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - note: Prop.maybeMix(note), - tip: Prop.maybeMix(tip), - important: Prop.maybeMix(important), - warning: Prop.maybeMix(warning), - caution: Prop.maybeMix(caution), - animation: animation, - variants: variants, - modifier: modifier, - ); - - /// Sets the note alert style. - MarkdownAlertStyler note(MarkdownAlertTypeStyler value) { - return merge(MarkdownAlertStyler(note: value)); - } - - /// Sets the tip alert style. - MarkdownAlertStyler tip(MarkdownAlertTypeStyler value) { - return merge(MarkdownAlertStyler(tip: value)); - } - - /// Sets the important alert style. - MarkdownAlertStyler important(MarkdownAlertTypeStyler value) { - return merge(MarkdownAlertStyler(important: value)); - } - - /// Sets the warning alert style. - MarkdownAlertStyler warning(MarkdownAlertTypeStyler value) { - return merge(MarkdownAlertStyler(warning: value)); - } - - /// Sets the caution alert style. - MarkdownAlertStyler caution(MarkdownAlertTypeStyler value) { - return merge(MarkdownAlertStyler(caution: value)); - } -} - /// Legacy alias for [MarkdownAlertStyler] (the pre-codegen class name). typedef MarkdownAlertStyle = MarkdownAlertStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart b/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart index 5819aee9..2f41a87a 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert.g.dart @@ -101,27 +101,102 @@ mixin _$MarkdownAlertSpec implements Spec, Diagnosticable { typedef _$MarkdownAlertSpecMethods = _$MarkdownAlertSpec; // ignore: unused_element // ************************************************************************** -// StylerGenerator +// SpecStylerGenerator // ************************************************************************** -mixin _$MarkdownAlertStylerMixin on Style, Diagnosticable { - Prop>? get $note; - Prop>? get $tip; - Prop>? get $important; - Prop>? get $warning; - Prop>? get $caution; +class MarkdownAlertStyler + extends MixStyler { + final Prop>? $note; + final Prop>? $tip; + final Prop>? $important; + final Prop>? $warning; + final Prop>? $caution; + + const MarkdownAlertStyler.create({ + Prop>? note, + Prop>? tip, + Prop>? important, + Prop>? warning, + Prop>? caution, + super.variants, + super.modifier, + super.animation, + }) : $note = note, + $tip = tip, + $important = important, + $warning = warning, + $caution = caution; + + MarkdownAlertStyler({ + MarkdownAlertTypeStyler? note, + MarkdownAlertTypeStyler? tip, + MarkdownAlertTypeStyler? important, + MarkdownAlertTypeStyler? warning, + MarkdownAlertTypeStyler? caution, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + note: Prop.maybeMix(note), + tip: Prop.maybeMix(tip), + important: Prop.maybeMix(important), + warning: Prop.maybeMix(warning), + caution: Prop.maybeMix(caution), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory MarkdownAlertStyler.note(MarkdownAlertTypeStyler value) => + MarkdownAlertStyler().note(value); + factory MarkdownAlertStyler.tip(MarkdownAlertTypeStyler value) => + MarkdownAlertStyler().tip(value); + factory MarkdownAlertStyler.important(MarkdownAlertTypeStyler value) => + MarkdownAlertStyler().important(value); + factory MarkdownAlertStyler.warning(MarkdownAlertTypeStyler value) => + MarkdownAlertStyler().warning(value); + factory MarkdownAlertStyler.caution(MarkdownAlertTypeStyler value) => + MarkdownAlertStyler().caution(value); + + /// Sets the note. + MarkdownAlertStyler note(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(note: value)); + } + + /// Sets the tip. + MarkdownAlertStyler tip(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(tip: value)); + } + + /// Sets the important. + MarkdownAlertStyler important(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(important: value)); + } + + /// Sets the warning. + MarkdownAlertStyler warning(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(warning: value)); + } + + /// Sets the caution. + MarkdownAlertStyler caution(MarkdownAlertTypeStyler value) { + return merge(MarkdownAlertStyler(caution: value)); + } /// Sets the animation configuration. + @override MarkdownAlertStyler animate(AnimationConfig value) { return merge(MarkdownAlertStyler(animation: value)); } /// Sets the style variants. + @override MarkdownAlertStyler variants(List> value) { return merge(MarkdownAlertStyler(variants: value)); } /// Wraps with a widget modifier. + @override MarkdownAlertStyler wrap(WidgetModifierConfig value) { return merge(MarkdownAlertStyler(modifier: value)); } diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart index 5a9d4696..1f1177ee 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart @@ -13,27 +13,21 @@ part 'markdown_alert_type.g.dart'; @immutable final class MarkdownAlertTypeSpec with _$MarkdownAlertTypeSpec { @override - @MixableField(setterType: TextStyler) final StyleSpec heading; @override - @MixableField(setterType: TextStyler) final StyleSpec description; @override - @MixableField(setterType: IconStyler) final StyleSpec icon; @override - @MixableField(setterType: BoxStyler) final StyleSpec container; @override - @MixableField(setterType: FlexBoxStyler) final StyleSpec containerFlex; @override - @MixableField(setterType: FlexBoxStyler) final StyleSpec headingFlex; const MarkdownAlertTypeSpec({ diff --git a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart index 7549506c..f02820d2 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart @@ -15,7 +15,6 @@ final class MarkdownCheckboxSpec with _$MarkdownCheckboxSpec { final TextStyle? textStyle; @override - @MixableField(setterType: IconStyler) final StyleSpec? icon; const MarkdownCheckboxSpec({this.textStyle, this.icon}); diff --git a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart index 99bede09..52eafb25 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart @@ -15,7 +15,6 @@ final class MarkdownCodeblockSpec with _$MarkdownCodeblockSpec { final TextStyle? textStyle; @override - @MixableField(setterType: BoxStyler) final StyleSpec? container; @override diff --git a/packages/superdeck/lib/src/styling/components/markdown_list.dart b/packages/superdeck/lib/src/styling/components/markdown_list.dart index 6140439d..d6af65b5 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_list.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_list.dart @@ -12,11 +12,9 @@ part 'markdown_list.g.dart'; @immutable final class MarkdownListSpec with _$MarkdownListSpec { @override - @MixableField(setterType: TextStyler) final StyleSpec? bullet; @override - @MixableField(setterType: TextStyler) final StyleSpec? text; @override diff --git a/packages/superdeck/lib/src/styling/components/slide.dart b/packages/superdeck/lib/src/styling/components/slide.dart index 93e8783f..cce62efa 100644 --- a/packages/superdeck/lib/src/styling/components/slide.dart +++ b/packages/superdeck/lib/src/styling/components/slide.dart @@ -1,12 +1,3 @@ -// The styler below stays hand-written on the legacy @MixableStyler mixin -// path: several fields nest same-package generated stylers -// (MarkdownAlertStyler, MarkdownCodeblockStyler, ...), which @MixableSpec's -// spec_styler_generator can only wire up through @MixableField(setterType:) — -// and annotation type arguments cannot reference same-package generated -// classes (build phases hide them from the resolver, degrading silently to -// value semantics). -// ignore_for_file: deprecated_member_use - import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_markdown_plus/flutter_markdown_plus.dart'; @@ -36,25 +27,18 @@ part 'slide.g.dart'; @immutable final class SlideSpec with _$SlideSpec { @override - @MixableField(setterType: TextStyler) final StyleSpec? h1; @override - @MixableField(setterType: TextStyler) final StyleSpec? h2; @override - @MixableField(setterType: TextStyler) final StyleSpec? h3; @override - @MixableField(setterType: TextStyler) final StyleSpec? h4; @override - @MixableField(setterType: TextStyler) final StyleSpec? h5; @override - @MixableField(setterType: TextStyler) final StyleSpec? h6; @override - @MixableField(setterType: TextStyler) final StyleSpec? p; /// Anchor style; [link] takes precedence when both are set. @@ -93,13 +77,10 @@ final class SlideSpec with _$SlideSpec { final StyleSpec? checkbox; @override - @MixableField(setterType: BoxStyler) final StyleSpec blockContainer; @override - @MixableField(setterType: BoxStyler) final StyleSpec slideContainer; @override - @MixableField(setterType: ImageStyler) final StyleSpec image; /// Static helper for context access @@ -181,223 +162,5 @@ final class SlideSpec with _$SlideSpec { } } -/// Root style class for configuring [SlideSpec] properties. -/// -/// This is the main style that controls all markdown element styling -/// including headings, text, alerts, lists, tables, code blocks, and more. -@MixableStyler() -final class SlideStyler extends MixStyler - with _$SlideStylerMixin { - @override - @MixableField(setterType: TextStyler) - final Prop>? $h1; - @override - @MixableField(setterType: TextStyler) - final Prop>? $h2; - @override - @MixableField(setterType: TextStyler) - final Prop>? $h3; - @override - @MixableField(setterType: TextStyler) - final Prop>? $h4; - @override - @MixableField(setterType: TextStyler) - final Prop>? $h5; - @override - @MixableField(setterType: TextStyler) - final Prop>? $h6; - @override - @MixableField(setterType: TextStyler) - final Prop>? $p; - - @override - final Prop? $a; - @override - final Prop? $em; - @override - final Prop? $strong; - @override - final Prop? $del; - @override - final Prop? $img; - @override - final Prop? $link; - - @override - final Prop? $textScaleFactor; - - @override - @MixableField(ignoreSetter: true) - final Prop>? $alert; - @override - final Prop? $horizontalRuleDecoration; - @override - @MixableField(ignoreSetter: true) - final Prop>? $blockquote; - @override - @MixableField(ignoreSetter: true) - final Prop>? $list; - @override - @MixableField(ignoreSetter: true) - final Prop>? $table; - @override - @MixableField(ignoreSetter: true) - final Prop>? $code; - @override - @MixableField(ignoreSetter: true) - final Prop>? $checkbox; - - @override - @MixableField(setterType: BoxStyler) - final Prop>? $blockContainer; - @override - @MixableField(setterType: BoxStyler) - final Prop>? $slideContainer; - @override - @MixableField(setterType: ImageStyler) - final Prop>? $image; - - const SlideStyler.create({ - Prop>? h1, - Prop>? h2, - Prop>? h3, - Prop>? h4, - Prop>? h5, - Prop>? h6, - Prop>? p, - Prop? a, - Prop? em, - Prop? strong, - Prop? del, - Prop? img, - Prop? link, - Prop? textScaleFactor, - Prop>? alert, - Prop? horizontalRuleDecoration, - Prop>? blockquote, - Prop>? list, - Prop>? table, - Prop>? code, - Prop>? checkbox, - Prop>? blockContainer, - Prop>? slideContainer, - Prop>? image, - required super.variants, - required super.animation, - required super.modifier, - }) : $h1 = h1, - $h2 = h2, - $h3 = h3, - $h4 = h4, - $h5 = h5, - $h6 = h6, - $p = p, - $a = a, - $em = em, - $strong = strong, - $del = del, - $img = img, - $link = link, - $textScaleFactor = textScaleFactor, - $alert = alert, - $horizontalRuleDecoration = horizontalRuleDecoration, - $blockquote = blockquote, - $list = list, - $table = table, - $code = code, - $checkbox = checkbox, - $blockContainer = blockContainer, - $slideContainer = slideContainer, - $image = image; - - SlideStyler({ - TextStyler? h1, - TextStyler? h2, - TextStyler? h3, - TextStyler? h4, - TextStyler? h5, - TextStyler? h6, - TextStyler? p, - TextStyleMix? a, - TextStyleMix? em, - TextStyleMix? strong, - TextStyleMix? del, - TextStyleMix? img, - TextStyleMix? link, - TextScaler? textScaleFactor, - MarkdownAlertStyler? alert, - BoxDecoration? horizontalRuleDecoration, - MarkdownBlockquoteStyler? blockquote, - MarkdownListStyler? list, - MarkdownTableStyler? table, - MarkdownCodeblockStyler? code, - MarkdownCheckboxStyler? checkbox, - BoxStyler? blockContainer, - BoxStyler? slideContainer, - ImageStyler? image, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - h1: Prop.maybeMix(h1), - h2: Prop.maybeMix(h2), - h3: Prop.maybeMix(h3), - h4: Prop.maybeMix(h4), - h5: Prop.maybeMix(h5), - h6: Prop.maybeMix(h6), - p: Prop.maybeMix(p), - a: Prop.maybeMix(a), - em: Prop.maybeMix(em), - strong: Prop.maybeMix(strong), - del: Prop.maybeMix(del), - img: Prop.maybeMix(img), - link: Prop.maybeMix(link), - textScaleFactor: Prop.maybe(textScaleFactor), - alert: Prop.maybeMix(alert), - horizontalRuleDecoration: Prop.maybe(horizontalRuleDecoration), - blockquote: Prop.maybeMix(blockquote), - list: Prop.maybeMix(list), - table: Prop.maybeMix(table), - code: Prop.maybeMix(code), - checkbox: Prop.maybeMix(checkbox), - blockContainer: Prop.maybeMix(blockContainer), - slideContainer: Prop.maybeMix(slideContainer), - image: Prop.maybeMix(image), - animation: animation, - variants: variants, - modifier: modifier, - ); - - /// Sets the alert styles. - SlideStyler alert(MarkdownAlertStyler value) { - return merge(SlideStyler(alert: value)); - } - - /// Sets the blockquote style. - SlideStyler blockquote(MarkdownBlockquoteStyler value) { - return merge(SlideStyler(blockquote: value)); - } - - /// Sets the list style. - SlideStyler list(MarkdownListStyler value) { - return merge(SlideStyler(list: value)); - } - - /// Sets the table style. - SlideStyler table(MarkdownTableStyler value) { - return merge(SlideStyler(table: value)); - } - - /// Sets the code block style. - SlideStyler code(MarkdownCodeblockStyler value) { - return merge(SlideStyler(code: value)); - } - - /// Sets the checkbox style. - SlideStyler checkbox(MarkdownCheckboxStyler value) { - return merge(SlideStyler(checkbox: value)); - } -} - /// Legacy alias for [SlideStyler] (the pre-codegen class name). typedef SlideStyle = SlideStyler; diff --git a/packages/superdeck/lib/src/styling/components/slide.g.dart b/packages/superdeck/lib/src/styling/components/slide.g.dart index bb0b8ead..3b5df8d9 100644 --- a/packages/superdeck/lib/src/styling/components/slide.g.dart +++ b/packages/superdeck/lib/src/styling/components/slide.g.dart @@ -235,34 +235,180 @@ mixin _$SlideSpec implements Spec, Diagnosticable { typedef _$SlideSpecMethods = _$SlideSpec; // ignore: unused_element // ************************************************************************** -// StylerGenerator +// SpecStylerGenerator // ************************************************************************** -mixin _$SlideStylerMixin on Style, Diagnosticable { - Prop>? get $h1; - Prop>? get $h2; - Prop>? get $h3; - Prop>? get $h4; - Prop>? get $h5; - Prop>? get $h6; - Prop>? get $p; - Prop? get $a; - Prop? get $em; - Prop? get $strong; - Prop? get $del; - Prop? get $img; - Prop? get $link; - Prop? get $textScaleFactor; - Prop>? get $alert; - Prop? get $horizontalRuleDecoration; - Prop>? get $blockquote; - Prop>? get $list; - Prop>? get $table; - Prop>? get $code; - Prop>? get $checkbox; - Prop>? get $blockContainer; - Prop>? get $slideContainer; - Prop>? get $image; +class SlideStyler extends MixStyler { + final Prop>? $h1; + final Prop>? $h2; + final Prop>? $h3; + final Prop>? $h4; + final Prop>? $h5; + final Prop>? $h6; + final Prop>? $p; + final Prop? $a; + final Prop? $em; + final Prop? $strong; + final Prop? $del; + final Prop? $img; + final Prop? $link; + final Prop? $textScaleFactor; + final Prop>? $alert; + final Prop? $horizontalRuleDecoration; + final Prop>? $blockquote; + final Prop>? $list; + final Prop>? $table; + final Prop>? $code; + final Prop>? $checkbox; + final Prop>? $blockContainer; + final Prop>? $slideContainer; + final Prop>? $image; + + const SlideStyler.create({ + Prop>? h1, + Prop>? h2, + Prop>? h3, + Prop>? h4, + Prop>? h5, + Prop>? h6, + Prop>? p, + Prop? a, + Prop? em, + Prop? strong, + Prop? del, + Prop? img, + Prop? link, + Prop? textScaleFactor, + Prop>? alert, + Prop? horizontalRuleDecoration, + Prop>? blockquote, + Prop>? list, + Prop>? table, + Prop>? code, + Prop>? checkbox, + Prop>? blockContainer, + Prop>? slideContainer, + Prop>? image, + super.variants, + super.modifier, + super.animation, + }) : $h1 = h1, + $h2 = h2, + $h3 = h3, + $h4 = h4, + $h5 = h5, + $h6 = h6, + $p = p, + $a = a, + $em = em, + $strong = strong, + $del = del, + $img = img, + $link = link, + $textScaleFactor = textScaleFactor, + $alert = alert, + $horizontalRuleDecoration = horizontalRuleDecoration, + $blockquote = blockquote, + $list = list, + $table = table, + $code = code, + $checkbox = checkbox, + $blockContainer = blockContainer, + $slideContainer = slideContainer, + $image = image; + + SlideStyler({ + TextStyler? h1, + TextStyler? h2, + TextStyler? h3, + TextStyler? h4, + TextStyler? h5, + TextStyler? h6, + TextStyler? p, + TextStyleMix? a, + TextStyleMix? em, + TextStyleMix? strong, + TextStyleMix? del, + TextStyleMix? img, + TextStyleMix? link, + TextScaler? textScaleFactor, + MarkdownAlertStyler? alert, + BoxDecoration? horizontalRuleDecoration, + MarkdownBlockquoteStyler? blockquote, + MarkdownListStyler? list, + MarkdownTableStyler? table, + MarkdownCodeblockStyler? code, + MarkdownCheckboxStyler? checkbox, + BoxStyler? blockContainer, + BoxStyler? slideContainer, + ImageStyler? image, + AnimationConfig? animation, + WidgetModifierConfig? modifier, + List>? variants, + }) : this.create( + h1: Prop.maybeMix(h1), + h2: Prop.maybeMix(h2), + h3: Prop.maybeMix(h3), + h4: Prop.maybeMix(h4), + h5: Prop.maybeMix(h5), + h6: Prop.maybeMix(h6), + p: Prop.maybeMix(p), + a: Prop.maybeMix(a), + em: Prop.maybeMix(em), + strong: Prop.maybeMix(strong), + del: Prop.maybeMix(del), + img: Prop.maybeMix(img), + link: Prop.maybeMix(link), + textScaleFactor: Prop.maybe(textScaleFactor), + alert: Prop.maybeMix(alert), + horizontalRuleDecoration: Prop.maybe(horizontalRuleDecoration), + blockquote: Prop.maybeMix(blockquote), + list: Prop.maybeMix(list), + table: Prop.maybeMix(table), + code: Prop.maybeMix(code), + checkbox: Prop.maybeMix(checkbox), + blockContainer: Prop.maybeMix(blockContainer), + slideContainer: Prop.maybeMix(slideContainer), + image: Prop.maybeMix(image), + variants: variants, + modifier: modifier, + animation: animation, + ); + + factory SlideStyler.h1(TextStyler value) => SlideStyler().h1(value); + factory SlideStyler.h2(TextStyler value) => SlideStyler().h2(value); + factory SlideStyler.h3(TextStyler value) => SlideStyler().h3(value); + factory SlideStyler.h4(TextStyler value) => SlideStyler().h4(value); + factory SlideStyler.h5(TextStyler value) => SlideStyler().h5(value); + factory SlideStyler.h6(TextStyler value) => SlideStyler().h6(value); + factory SlideStyler.p(TextStyler value) => SlideStyler().p(value); + factory SlideStyler.a(TextStyleMix value) => SlideStyler().a(value); + factory SlideStyler.em(TextStyleMix value) => SlideStyler().em(value); + factory SlideStyler.strong(TextStyleMix value) => SlideStyler().strong(value); + factory SlideStyler.del(TextStyleMix value) => SlideStyler().del(value); + factory SlideStyler.img(TextStyleMix value) => SlideStyler().img(value); + factory SlideStyler.link(TextStyleMix value) => SlideStyler().link(value); + factory SlideStyler.textScaleFactor(TextScaler value) => + SlideStyler().textScaleFactor(value); + factory SlideStyler.alert(MarkdownAlertStyler value) => + SlideStyler().alert(value); + factory SlideStyler.horizontalRuleDecoration(BoxDecoration value) => + SlideStyler().horizontalRuleDecoration(value); + factory SlideStyler.blockquote(MarkdownBlockquoteStyler value) => + SlideStyler().blockquote(value); + factory SlideStyler.list(MarkdownListStyler value) => + SlideStyler().list(value); + factory SlideStyler.table(MarkdownTableStyler value) => + SlideStyler().table(value); + factory SlideStyler.code(MarkdownCodeblockStyler value) => + SlideStyler().code(value); + factory SlideStyler.checkbox(MarkdownCheckboxStyler value) => + SlideStyler().checkbox(value); + factory SlideStyler.blockContainer(BoxStyler value) => + SlideStyler().blockContainer(value); + factory SlideStyler.slideContainer(BoxStyler value) => + SlideStyler().slideContainer(value); + factory SlideStyler.image(ImageStyler value) => SlideStyler().image(value); /// Sets the h1. SlideStyler h1(TextStyler value) { @@ -334,11 +480,41 @@ mixin _$SlideStylerMixin on Style, Diagnosticable { return merge(SlideStyler(textScaleFactor: value)); } + /// Sets the alert. + SlideStyler alert(MarkdownAlertStyler value) { + return merge(SlideStyler(alert: value)); + } + /// Sets the horizontalRuleDecoration. SlideStyler horizontalRuleDecoration(BoxDecoration value) { return merge(SlideStyler(horizontalRuleDecoration: value)); } + /// Sets the blockquote. + SlideStyler blockquote(MarkdownBlockquoteStyler value) { + return merge(SlideStyler(blockquote: value)); + } + + /// Sets the list. + SlideStyler list(MarkdownListStyler value) { + return merge(SlideStyler(list: value)); + } + + /// Sets the table. + SlideStyler table(MarkdownTableStyler value) { + return merge(SlideStyler(table: value)); + } + + /// Sets the code. + SlideStyler code(MarkdownCodeblockStyler value) { + return merge(SlideStyler(code: value)); + } + + /// Sets the checkbox. + SlideStyler checkbox(MarkdownCheckboxStyler value) { + return merge(SlideStyler(checkbox: value)); + } + /// Sets the blockContainer. SlideStyler blockContainer(BoxStyler value) { return merge(SlideStyler(blockContainer: value)); @@ -355,16 +531,19 @@ mixin _$SlideStylerMixin on Style, Diagnosticable { } /// Sets the animation configuration. + @override SlideStyler animate(AnimationConfig value) { return merge(SlideStyler(animation: value)); } /// Sets the style variants. + @override SlideStyler variants(List> value) { return merge(SlideStyler(variants: value)); } /// Wraps with a widget modifier. + @override SlideStyler wrap(WidgetModifierConfig value) { return merge(SlideStyler(modifier: value)); } diff --git a/packages/superdeck/pubspec.yaml b/packages/superdeck/pubspec.yaml index 92577c0b..fe86d8cc 100644 --- a/packages/superdeck/pubspec.yaml +++ b/packages/superdeck/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: go_router: ^17.3.0 path_provider: ^2.1.4 mix: ^2.1.0 - mix_annotations: ^2.1.1 + mix_annotations: ^2.1.2 remix: ^0.2.0 flutter_markdown_plus: ^1.0.5 superdeck_core: ^1.0.0 @@ -44,7 +44,7 @@ dev_dependencies: dart_code_metrics_presets: ^2.19.0 build_runner: ^2.5.4 dart_mappable_builder: ^4.7.0 - mix_generator: ^2.1.1 + mix_generator: ^2.1.2 path_provider_platform_interface: ^2.1.2 superdeck_builder: path: ../builder diff --git a/packages/superdeck/test/src/deck/template_resolver_test.dart b/packages/superdeck/test/src/deck/template_resolver_test.dart index 42847f5f..56018e44 100644 --- a/packages/superdeck/test/src/deck/template_resolver_test.dart +++ b/packages/superdeck/test/src/deck/template_resolver_test.dart @@ -121,6 +121,43 @@ void main() { }, ); + testWidgets( + 'nested generated stylers accumulate field-wise through the cascade', + (tester) async { + const grey = Color(0xFF9E9E9E); + const red = Color(0xFFFF0000); + final baseStyle = SlideStyler( + alert: MarkdownAlertStyler( + note: MarkdownAlertTypeStyler( + heading: TextStyler().style( + TextStyleMix(fontSize: 24, color: grey), + ), + ), + ), + ); + final namedStyle = SlideStyler( + alert: MarkdownAlertStyler( + note: MarkdownAlertTypeStyler(heading: TextStyler().color(red)), + ), + ); + + late final StyleSpec resolved; + await tester.pumpWidget( + Builder( + builder: (context) { + resolved = baseStyle.merge(namedStyle).resolve(context); + return const SizedBox(); + }, + ), + ); + + final heading = resolved.spec.alert.spec.note.spec.heading.spec.style; + expect(heading, isNotNull); + expect(heading!.color, red); + expect(heading.fontSize, 24.0); + }, + ); + test('no template, unknown style — throws ArgumentError', () { final options = DeckOptions(styles: {'light': SlideStyler()}); final resolver = TemplateResolver(options); From 6f6cd87bdeff51a565cdecd70a5cc60a40e60963 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Sun, 12 Jul 2026 10:31:53 -0400 Subject: [PATCH 5/5] refactor: drop legacy Style typedefs and deprecated MarkdownText surface --- .../styling/components/markdown_alert.dart | 3 - .../components/markdown_alert_type.dart | 3 - .../components/markdown_blockquote.dart | 3 - .../styling/components/markdown_checkbox.dart | 3 - .../components/markdown_codeblock.dart | 3 - .../src/styling/components/markdown_list.dart | 3 - .../styling/components/markdown_table.dart | 3 - .../src/styling/components/markdown_text.dart | 192 ------------------ .../lib/src/styling/components/slide.dart | 3 - packages/superdeck/lib/superdeck.dart | 1 - 10 files changed, 217 deletions(-) delete mode 100644 packages/superdeck/lib/src/styling/components/markdown_text.dart diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert.dart b/packages/superdeck/lib/src/styling/components/markdown_alert.dart index c766ad8a..174b440c 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert.dart @@ -36,6 +36,3 @@ final class MarkdownAlertSpec with _$MarkdownAlertSpec { warning = warning ?? const StyleSpec(spec: MarkdownAlertTypeSpec()), caution = caution ?? const StyleSpec(spec: MarkdownAlertTypeSpec()); } - -/// Legacy alias for [MarkdownAlertStyler] (the pre-codegen class name). -typedef MarkdownAlertStyle = MarkdownAlertStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart index 1f1177ee..5fba50c7 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_alert_type.dart @@ -44,6 +44,3 @@ final class MarkdownAlertTypeSpec with _$MarkdownAlertTypeSpec { containerFlex = containerFlex ?? const StyleSpec(spec: FlexBoxSpec()), headingFlex = headingFlex ?? const StyleSpec(spec: FlexBoxSpec()); } - -/// Legacy alias for [MarkdownAlertTypeStyler] (the pre-codegen class name). -typedef MarkdownAlertTypeStyle = MarkdownAlertTypeStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart b/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart index 9c309d8b..d909bf78 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_blockquote.dart @@ -28,6 +28,3 @@ final class MarkdownBlockquoteSpec with _$MarkdownBlockquoteSpec { this.alignment, }); } - -/// Legacy alias for [MarkdownBlockquoteStyler] (the pre-codegen class name). -typedef MarkdownBlockquoteStyle = MarkdownBlockquoteStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart index f02820d2..8a587c13 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_checkbox.dart @@ -19,6 +19,3 @@ final class MarkdownCheckboxSpec with _$MarkdownCheckboxSpec { const MarkdownCheckboxSpec({this.textStyle, this.icon}); } - -/// Legacy alias for [MarkdownCheckboxStyler] (the pre-codegen class name). -typedef MarkdownCheckboxStyle = MarkdownCheckboxStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart index 52eafb25..35b66c93 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_codeblock.dart @@ -22,6 +22,3 @@ final class MarkdownCodeblockSpec with _$MarkdownCodeblockSpec { const MarkdownCodeblockSpec({this.textStyle, this.container, this.alignment}); } - -/// Legacy alias for [MarkdownCodeblockStyler] (the pre-codegen class name). -typedef MarkdownCodeblockStyle = MarkdownCodeblockStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_list.dart b/packages/superdeck/lib/src/styling/components/markdown_list.dart index d6af65b5..4340ea1f 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_list.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_list.dart @@ -30,6 +30,3 @@ final class MarkdownListSpec with _$MarkdownListSpec { this.unorderedAlignment, }); } - -/// Legacy alias for [MarkdownListStyler] (the pre-codegen class name). -typedef MarkdownListStyle = MarkdownListStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_table.dart b/packages/superdeck/lib/src/styling/components/markdown_table.dart index 96710b63..58f1d9f3 100644 --- a/packages/superdeck/lib/src/styling/components/markdown_table.dart +++ b/packages/superdeck/lib/src/styling/components/markdown_table.dart @@ -44,6 +44,3 @@ final class MarkdownTableSpec with _$MarkdownTableSpec { this.verticalAlignment, }); } - -/// Legacy alias for [MarkdownTableStyler] (the pre-codegen class name). -typedef MarkdownTableStyle = MarkdownTableStyler; diff --git a/packages/superdeck/lib/src/styling/components/markdown_text.dart b/packages/superdeck/lib/src/styling/components/markdown_text.dart deleted file mode 100644 index 709ccb17..00000000 --- a/packages/superdeck/lib/src/styling/components/markdown_text.dart +++ /dev/null @@ -1,192 +0,0 @@ -// Self-references inside this deprecated compatibility surface. -// ignore_for_file: deprecated_member_use_from_same_package - -import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; -import 'package:mix/mix.dart'; - -/// Specification for markdown text styling properties. -/// -/// **Not used by the renderer.** Active text styling goes through -/// [SlideSpec]/[SlideStyle] (e.g. `p`, `h1`–`h6`, `strong`, `em`) and Mix -/// [TextStyler]s. Kept for source compatibility only. -@Deprecated( - 'MarkdownTextSpec is not wired into rendering. Use SlideStyle / SlideSpec ' - '(p, h1–h6, strong, em, del, link) with Mix TextStyler instead.', -) -final class MarkdownTextSpec extends Spec - with Diagnosticable { - final TextStyle? textStyle; - final EdgeInsets? padding; - final WrapAlignment? alignment; - - @Deprecated( - 'MarkdownTextSpec is not wired into rendering. Use SlideStyle / SlideSpec ' - 'instead.', - ) - const MarkdownTextSpec({this.textStyle, this.padding, this.alignment}); - - @override - MarkdownTextSpec copyWith({ - TextStyle? textStyle, - EdgeInsets? padding, - WrapAlignment? alignment, - }) { - return MarkdownTextSpec( - textStyle: textStyle ?? this.textStyle, - padding: padding ?? this.padding, - alignment: alignment ?? this.alignment, - ); - } - - @override - MarkdownTextSpec lerp(MarkdownTextSpec? other, double t) { - if (other == null) return this; - - return MarkdownTextSpec( - textStyle: TextStyle.lerp(textStyle, other.textStyle, t), - padding: EdgeInsets.lerp(padding, other.padding, t), - alignment: t < 0.5 ? alignment : other.alignment, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', textStyle)) - ..add(DiagnosticsProperty('padding', padding)) - ..add(EnumProperty('alignment', alignment)); - } - - @override - List get props => [textStyle, padding, alignment]; -} - -/// Style class for configuring [MarkdownTextSpec] properties. -/// -/// **Not used by the renderer.** Prefer [SlideStyle] / Mix [TextStyler] for -/// active styling. Kept exported for source compatibility. -@Deprecated( - 'MarkdownTextStyle is not wired into rendering. Use SlideStyle with Mix ' - 'TextStyler (p, h1–h6, strong, em, del, link) instead.', -) -final class MarkdownTextStyle extends Style - with - Diagnosticable, - WidgetModifierStyleMixin, - VariantStyleMixin, - AnimationStyleMixin { - final Prop? $textStyle; - final Prop? $padding; - final Prop? $alignment; - - @Deprecated( - 'MarkdownTextStyle is not wired into rendering. Use SlideStyle instead.', - ) - const MarkdownTextStyle.create({ - Prop? textStyle, - Prop? padding, - Prop? alignment, - required super.variants, - required super.animation, - required super.modifier, - }) : $textStyle = textStyle, - $padding = padding, - $alignment = alignment; - - @Deprecated( - 'MarkdownTextStyle is not wired into rendering. Use SlideStyle instead.', - ) - MarkdownTextStyle({ - TextStyle? textStyle, - EdgeInsets? padding, - WrapAlignment? alignment, - AnimationConfig? animation, - List>? variants, - WidgetModifierConfig? modifier, - }) : this.create( - textStyle: Prop.maybe(textStyle), - padding: Prop.maybe(padding), - alignment: Prop.maybe(alignment), - animation: animation, - variants: variants, - modifier: modifier, - ); - - /// Sets text style - MarkdownTextStyle textStyle(TextStyle value) { - return merge(MarkdownTextStyle(textStyle: value)); - } - - /// Sets padding - MarkdownTextStyle padding(EdgeInsets value) { - return merge(MarkdownTextStyle(padding: value)); - } - - /// Sets alignment - MarkdownTextStyle alignment(WrapAlignment value) { - return merge(MarkdownTextStyle(alignment: value)); - } - - @override - MarkdownTextStyle variants(List> value) { - return merge(MarkdownTextStyle(variants: value)); - } - - @override - MarkdownTextStyle animate(AnimationConfig value) { - return merge(MarkdownTextStyle(animation: value)); - } - - @override - MarkdownTextStyle wrap(WidgetModifierConfig value) { - return merge(MarkdownTextStyle(modifier: value)); - } - - @override - StyleSpec resolve(BuildContext context) { - return StyleSpec( - spec: MarkdownTextSpec( - textStyle: MixOps.resolve(context, $textStyle), - padding: MixOps.resolve(context, $padding), - alignment: MixOps.resolve(context, $alignment), - ), - animation: $animation, - widgetModifiers: $modifier?.resolve(context), - ); - } - - @override - MarkdownTextStyle merge(MarkdownTextStyle? other) { - if (other == null) return this; - - return MarkdownTextStyle.create( - textStyle: MixOps.merge($textStyle, other.$textStyle), - padding: MixOps.merge($padding, other.$padding), - alignment: MixOps.merge($alignment, other.$alignment), - animation: MixOps.mergeAnimation($animation, other.$animation), - variants: MixOps.mergeVariants($variants, other.$variants), - modifier: MixOps.mergeModifier($modifier, other.$modifier), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('textStyle', $textStyle)) - ..add(DiagnosticsProperty('padding', $padding)) - ..add(DiagnosticsProperty('alignment', $alignment)); - } - - @override - List get props => [ - $textStyle, - $padding, - $alignment, - $animation, - $variants, - $modifier, - ]; -} diff --git a/packages/superdeck/lib/src/styling/components/slide.dart b/packages/superdeck/lib/src/styling/components/slide.dart index cce62efa..6ea92f8d 100644 --- a/packages/superdeck/lib/src/styling/components/slide.dart +++ b/packages/superdeck/lib/src/styling/components/slide.dart @@ -161,6 +161,3 @@ final class SlideSpec with _$SlideSpec { ); } } - -/// Legacy alias for [SlideStyler] (the pre-codegen class name). -typedef SlideStyle = SlideStyler; diff --git a/packages/superdeck/lib/superdeck.dart b/packages/superdeck/lib/superdeck.dart index db2527ad..b752900b 100644 --- a/packages/superdeck/lib/superdeck.dart +++ b/packages/superdeck/lib/superdeck.dart @@ -21,7 +21,6 @@ export 'src/styling/components/markdown_checkbox.dart'; export 'src/styling/components/markdown_codeblock.dart'; export 'src/styling/components/markdown_list.dart'; export 'src/styling/components/markdown_table.dart'; -export 'src/styling/components/markdown_text.dart'; export 'src/styling/components/slide.dart'; // UI