diff --git a/MODULE.bazel b/MODULE.bazel index af2f7ec4..670dc48f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -126,6 +126,8 @@ http_archive( integrity = "sha256-+GQiTtN6H8TQz/+YkVz73dHeYAZ86/9hAUwTlkISx48=", strip_prefix = "hermes-880b1645b5dca974f4329dc4108692d301abee0d", build_file = "@valdi//third-party/hermes:hermes.BUILD", + patch_args = ["-p1"], + patches = ["@valdi//third-party/hermes/patches:nontrivial_memcall.patch"], ) bazel_dep(name = "boringssl", version = "0.20250415.0") diff --git a/apps/inline_text_children_example/BUILD.bazel b/apps/inline_text_children_example/BUILD.bazel new file mode 100644 index 00000000..36053ca9 --- /dev/null +++ b/apps/inline_text_children_example/BUILD.bazel @@ -0,0 +1,24 @@ +load("//bzl/valdi:valdi_application.bzl", "valdi_application") +load("//bzl/valdi:valdi_module.bzl", "valdi_module") + +valdi_module( + name = "inline_text_children_example", + srcs = glob([ + "**/*.ts", + "**/*.tsx", + ]), + visibility = ["//visibility:public"], + deps = [ + "//src/valdi_modules/src/valdi/valdi_core", + "//src/valdi_modules/src/valdi/valdi_tsx", + ], +) + +valdi_application( + name = "inline_text_children_example_app", + ios_bundle_id = "com.snap.valdi.inlinetextchildren", + root_component_path = "App@inline_text_children_example/InlineTextChildrenExample", + title = "Inline Text Children", + version = "1.0.0", + deps = [":inline_text_children_example"], +) diff --git a/apps/inline_text_children_example/InlineTextChildrenExample.tsx b/apps/inline_text_children_example/InlineTextChildrenExample.tsx new file mode 100644 index 00000000..156cd1d5 --- /dev/null +++ b/apps/inline_text_children_example/InlineTextChildrenExample.tsx @@ -0,0 +1,273 @@ +import { Component, StatefulComponent } from 'valdi_core/src/Component'; +import { Device } from 'valdi_core/src/Device'; +import { Style } from 'valdi_core/src/Style'; +import { systemBoldFont, systemFont } from 'valdi_core/src/SystemFont'; +import { AttributedTextBuilder } from 'valdi_core/src/utils/AttributedTextBuilder'; +import { AttributedTextInlineViewVerticalAlignment } from 'valdi_tsx/src/AttributedTextInlineViewAttachment'; +import { View } from 'valdi_tsx/src/NativeTemplateElements'; + +const alignmentText = new AttributedTextBuilder() + .append('Top ') + .appendInlineView(0, AttributedTextInlineViewVerticalAlignment.Top) + .append(' Center ') + .appendInlineView(1, AttributedTextInlineViewVerticalAlignment.Center) + .append(' Bottom ') + .appendInlineView(2, AttributedTextInlineViewVerticalAlignment.Bottom) + .append(' Baseline ') + .appendInlineView(3, AttributedTextInlineViewVerticalAlignment.Baseline) + .append(' inside one wrapped text run.') + .build(); + +const labelInteractiveText = new AttributedTextBuilder() + .append('A label can host a stateful inline child: ') + .appendInlineView(0, AttributedTextInlineViewVerticalAlignment.Center) + .append(' and the surrounding text is not rebuilt when it changes size.') + .build(); + +const textViewInteractiveText = new AttributedTextBuilder() + .append('The same stateful child works in a textview: ') + .appendInlineView(0, AttributedTextInlineViewVerticalAlignment.Center) + .append(' so text layout can place a resized view again.') + .build(); + +const ltrEndInlineText = new AttributedTextBuilder() + .append('Text before ') + .appendInlineView(0, AttributedTextInlineViewVerticalAlignment.Center) + .build(); + +const rtlEndInlineText = new AttributedTextBuilder() + .append('אבג ') + .appendInlineView(0, AttributedTextInlineViewVerticalAlignment.Center) + .build(); + +/** + * @ViewModel + * @ExportModel + */ +export interface ViewModel {} + +interface MarkerViewModel { + title: string; + color: string; + height: number; + width: number; +} + +class AlignmentMarker extends Component { + onRender(): void { + + ; + } +} + +interface ExpandableInlineButtonViewModel { + compactTitle: string; + expandedTitle: string; +} + +interface ExpandableInlineButtonState { + expanded: boolean; +} + +class ExpandableInlineButton extends StatefulComponent { + state: ExpandableInlineButtonState = { + expanded: false, + }; + + onRender(): void { + const expanded = this.state.expanded; + + ; + } + + private toggle = () => { + this.setState({ expanded: !this.state.expanded }); + }; +} + +/** + * @Component + * @ExportModel + */ +export class App extends Component { + onRender(): void { + + + + + + ; + } +} + +const styles = { + card: new Style({ + backgroundColor: '#FFFFFF', + border: '1 solid #CBD5E1', + borderRadius: 8, + padding: 14, + width: '100%', + }), +}; diff --git a/apps/text_animation_group_example/BUILD.bazel b/apps/text_animation_group_example/BUILD.bazel new file mode 100644 index 00000000..56971dff --- /dev/null +++ b/apps/text_animation_group_example/BUILD.bazel @@ -0,0 +1,22 @@ +load("//bzl/valdi:valdi_application.bzl", "valdi_application") +load("//bzl/valdi:valdi_module.bzl", "valdi_module") + +valdi_module( + name = "text_animation_group_example", + srcs = glob([ + "**/*.ts", + "**/*.tsx", + ]), + visibility = ["//visibility:public"], + deps = [ + "//src/valdi_modules/src/valdi/valdi_core", + "//src/valdi_modules/src/valdi/valdi_tsx", + ], +) + +valdi_application( + name = "text_animation_group_example_app", + root_component_path = "App@text_animation_group_example/TextAnimationGroupExample", + title = "Text Animation Group", + deps = [":text_animation_group_example"], +) diff --git a/apps/text_animation_group_example/TextAnimationGroupExample.tsx b/apps/text_animation_group_example/TextAnimationGroupExample.tsx new file mode 100644 index 00000000..6b234df7 --- /dev/null +++ b/apps/text_animation_group_example/TextAnimationGroupExample.tsx @@ -0,0 +1,166 @@ +import { StatefulComponent } from 'valdi_core/src/Component'; +import { Style } from 'valdi_core/src/Style'; +import { systemBoldFont, systemFont } from 'valdi_core/src/SystemFont'; +import { AttributedTextBuilder } from 'valdi_core/src/utils/AttributedTextBuilder'; +import { Label, TextAnimationGroup, TextView, View } from 'valdi_tsx/src/NativeTemplateElements'; + +interface State { + runId: number; +} + +/** + * @ViewModel + * @ExportModel + */ +export interface ViewModel {} + +/** + * @Component + * @ExportModel + */ +export class App extends StatefulComponent { + state: State = { + runId: 0, + }; + + onRender(): void { + + ; + } + + private renderAnimatedLabel(text: string): void { +