From 00b3514a1369923d9c04210cebb185d1e1f8ce5e Mon Sep 17 00:00:00 2001 From: lsh Date: Tue, 18 Feb 2025 21:15:42 +0800 Subject: [PATCH] 0218 Signed-off-by: lsh --- .../arkui/config/etsconfig-base.json | 6 ++ .../src/generated/ArkWithThemeInterfaces.ts | 45 +++++++++++-- arkoala-arkts/arkui/src/index.ts | 3 +- arkoala-arkts/arkui/types/index-full.d.ts | 17 ++++- .../shopping/user/src/ets/@Builder.ets | 31 +++++++++ .../shopping/user/src/ets/@Provide.ets | 9 +++ .../shopping/user/src/ets/Private.ets | 17 +++++ .../shopping/user/src/ets/WithTheme.ets | 26 ++++++++ .../shopping/user/src/ets/dollar-dollar | 65 +++++++++++++++++++ .../shopping/user/tsconfig-unmemoize.json | 3 + arkoala/ets-plugin/src/utils.ts | 26 ++++++-- 11 files changed, 235 insertions(+), 13 deletions(-) create mode 100644 arkoala-arkts/shopping/user/src/ets/@Builder.ets create mode 100644 arkoala-arkts/shopping/user/src/ets/@Provide.ets create mode 100644 arkoala-arkts/shopping/user/src/ets/Private.ets create mode 100644 arkoala-arkts/shopping/user/src/ets/WithTheme.ets create mode 100644 arkoala-arkts/shopping/user/src/ets/dollar-dollar diff --git a/arkoala-arkts/arkui/config/etsconfig-base.json b/arkoala-arkts/arkui/config/etsconfig-base.json index a1bc1c4e3..2d0215a9f 100644 --- a/arkoala-arkts/arkui/config/etsconfig-base.json +++ b/arkoala-arkts/arkui/config/etsconfig-base.json @@ -225,6 +225,7 @@ "UIExtensionComponent", "RichEditor", "CachedImage", + "WithTheme", "MediaCachedImage" ], "extend": { @@ -798,6 +799,11 @@ "type": "CachedImageAttribute", "instance": "CachedImageInstance" }, + { + "name": "WithTheme", + "type": "WithThemeAttribute", + "instance": "WithThemeInstance" + }, { "name": "MediaCachedImage", "type": "MediaCachedImageAttribute", diff --git a/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts index 7ddd06167..b5b5479ae 100644 --- a/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts @@ -20,13 +20,50 @@ import { int32, int64, float32 } from "@koalaui/common" import { KInt, KPointer, KBoolean, KStringPtr, wrapCallback, NativeBuffer } from "@koalaui/interop" import { NodeAttach, remember } from "@koalaui/runtime" import { ThemeColorMode } from "./ArkCommonInterfaces" + + +declare enum ThemeColorMode { + SYSTEM = 0, + LIGHT = 1, + DARK = 2, +} + +declare interface Colors { + +} + +declare type CustomColors = Partial; export interface CustomTheme { - _CustomThemeStub: string; + /** + * Define tokens associated with color resources.. + * + * @type { ?CustomColors } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 12 + */ + colors?: CustomColors; } + export interface WithThemeOptions { theme?: CustomTheme; colorMode?: ThemeColorMode; } -export type WithThemeInterface = (options: WithThemeOptions) => WithThemeAttribute; -export interface WithThemeAttribute { -} + +export type WithThemeInterface = (p: any,func: () => any, r: WithThemeOptions) => void + + +export const ArkWithTheme: WithThemeInterface = (p: any,func: () => any, r: WithThemeOptions) => void {} + + +// export interface CustomTheme { +// _CustomThemeStub: string; +// } +// export interface WithThemeOptions { +// theme?: CustomTheme; +// colorMode?: ThemeColorMode; +// } +// export type WithThemeInterface = (options: WithThemeOptions) => WithThemeAttribute; +// export interface WithThemeAttribute { +// } diff --git a/arkoala-arkts/arkui/src/index.ts b/arkoala-arkts/arkui/src/index.ts index b8ebda64d..e74e56033 100644 --- a/arkoala-arkts/arkui/src/index.ts +++ b/arkoala-arkts/arkui/src/index.ts @@ -25,4 +25,5 @@ export * from "./stateOf" export * from "./ForEach" export * from "./LazyForEach" export * from "./ohos.router" -export * from "./ArkNavigation" \ No newline at end of file +export * from "./ArkNavigation" + diff --git a/arkoala-arkts/arkui/types/index-full.d.ts b/arkoala-arkts/arkui/types/index-full.d.ts index 228f2bfde..474510c7e 100644 --- a/arkoala-arkts/arkui/types/index-full.d.ts +++ b/arkoala-arkts/arkui/types/index-full.d.ts @@ -7388,9 +7388,24 @@ declare class ToggleAttribute extends CommonMethod { switchStyle(value: SwitchStyle): ToggleAttribute; _onChangeEvent_isOn(callback_: ((parameter: boolean) => void)): void; } +declare interface Colors { + +} + +declare type CustomColors = Partial; declare interface CustomTheme { - _CustomThemeStub: string; + /** + * Define tokens associated with color resources.. + * + * @type { ?CustomColors } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 12 + */ + colors?: CustomColors; } +declare const WithTheme: WithThemeInterface declare interface WithThemeOptions { theme?: CustomTheme; colorMode?: ThemeColorMode; diff --git a/arkoala-arkts/shopping/user/src/ets/@Builder.ets b/arkoala-arkts/shopping/user/src/ets/@Builder.ets new file mode 100644 index 000000000..7d74fde6a --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/@Builder.ets @@ -0,0 +1,31 @@ + + +@Component +struct CustomContentDialog { + @BuilderParam contentBuilder: () => void + + build() { + Column() { + + } + } +} + +@Entry +@Component +struct Page2 { + build() { + Column() { + CustomContentDialog({ + contentBuilder: this.hidden + }) + } + } + @Builder + hidden() { + Column() { + + } + } +} + diff --git a/arkoala-arkts/shopping/user/src/ets/@Provide.ets b/arkoala-arkts/shopping/user/src/ets/@Provide.ets new file mode 100644 index 000000000..f949acb72 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/@Provide.ets @@ -0,0 +1,9 @@ +@Component +struct allow { + @Provide({ allowOverride: 'bar'}) bar:number = 1 + @Provide({ allowOverride: 'har'}) har:number = 1 + + build(){ + Text() + } +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/src/ets/Private.ets b/arkoala-arkts/shopping/user/src/ets/Private.ets new file mode 100644 index 000000000..761dc738a --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/Private.ets @@ -0,0 +1,17 @@ + +/* +@CustomDialog +export struct AiWallpaperDialog { + private disableService: boolean = false; +} + + +@Component +struct myprivate { + cs:CustomDialogController = new CustomDialogController({ + builder: AiWallpaperDialog({ + disableService: true + }) + }) +} +*/ \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/src/ets/WithTheme.ets b/arkoala-arkts/shopping/user/src/ets/WithTheme.ets new file mode 100644 index 000000000..13168ce15 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/WithTheme.ets @@ -0,0 +1,26 @@ + + +import { CustomColors, CustomTheme, Theme } from '@ohos.arkui.theme' + +class CustomThemeImpl implements CustomTheme { + public colors?: CustomColors; + constructor(colors: CustomColors) { + this.colors = colors; + } +} + + +@Component +struct Customdia { + theme?: Theme | CustomTheme = new CustomThemeImpl({}); + themeColorMode?: ThemeColorMode = ThemeColorMode.SYSTEM; + build() { + WithTheme({ theme: this.theme, colorMode: this.themeColorMode }) { + Scroll() { + Column() { + + } + } + } + } +} diff --git a/arkoala-arkts/shopping/user/src/ets/dollar-dollar b/arkoala-arkts/shopping/user/src/ets/dollar-dollar new file mode 100644 index 000000000..907c444da --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/dollar-dollar @@ -0,0 +1,65 @@ +@Entry +@Component +struct Index { + @State n: number = 0.5 + @State s: string = "0.5" + @State b: boolean = true + @State d: Date = new Date('2021-08-08') + @State m: PanelMode = PanelMode.Mini + @State l: ListItemStyle = ListItemStyle.NONE + + build() { + Column() { + Slider({ value: this.n }) + Toggle({ type: ToggleType.Switch, isOn: $$(this.b) }) + Stepper({ index: this.n }) + Checkbox() + .select($$(this.b)) + CheckboxGroup() + .selectAll($$(this.b)) + DatePicker({ selected: $$(this.d) }) + TimePicker({ selected: $$(this.d) }) + MenuItem() + .selected($$(this.b)) + Panel(false) + .mode($$(this.m)) + Radio({group: "", value: ""}) + .checked($$(this.b)) + Search({ value: $$(this.s) }) + SideBarContainer(SideBarContainerType.Embed) + .showSideBar($$(this.b)) + Swiper() + .index($$(this.n)) + Tabs({ index: $$(this.n) }) + TextInput({ text: $$(this.s) }) + TextArea({ text: $$(this.s) }) + TextInput({ text: $$(this.s) }) + Toggle({ type: ToggleType.Checkbox, isOn: $$(this.b) }) + AlphabetIndexer({arrayValue: [], selected: $$(this.n) }) + Refresh({ refreshing: $$(this.b) }) + TextPicker({ range: [], value: $$(this.s), selected: $$(this.n) }) + Select([]) + .value($$(this.s)) + .selected($$(this.n)) + List() { + ListItemGroup() { + ListItem({ style: this.l }) + .selected($$(this.b)) + } + } + Grid() { + GridItem({}) + .selected($$(this.b)) + } + + Button() + .bindSheet($$(this.b), builder) + .bindContentCover($$(this.b), builder) + } + } +} + +@Builder +function builder() { + Text() +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json index 2abbabdde..2ff0eb114 100644 --- a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json +++ b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json @@ -30,6 +30,9 @@ ], "app/*": [ "./build/generated/*" + ], + "@ohos.*": [ + "../../../arkoala/arkui-common/interface_sdk-js/api/@ohos.*" ] } }, diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 5ac9f4c70..5f1ba6ef4 100644 --- a/arkoala/ets-plugin/src/utils.ts +++ b/arkoala/ets-plugin/src/utils.ts @@ -274,13 +274,25 @@ export function deduceProvideConsumeName(property: ts.PropertyDeclaration, name: } // @Provide({ allowOverride: 'bar'}) bar if (ts.isObjectLiteralExpression(arg)) { - return (arg as ts.ObjectLiteralExpression).properties - .filter( - (property) => - ts.isPropertyAssignment(property) && - property.name.getText() === "allowOveride" - ) - .map((p) => (p as ts.PropertyAssignment).initializer.getText())[0]; + // return (arg as ts.ObjectLiteralExpression).properties + // .filter( + // (property) => + // ts.isPropertyAssignment(property) && + // property.name.getText() === "allowOveride" + // ) + // .map((p) => (p as ts.PropertyAssignment).initializer.getText())[0]; + const propertiesName = (arg as ts.ObjectLiteralExpression).properties + .filter( + (property) => + ts.isPropertyAssignment(property) && + property.name.getText() === "allowOverride" + ) + if (propertiesName.length > 0) { + const arg = propertiesName[0] as ts.PropertyAssignment + if (ts.isStringLiteral(arg.initializer)) { + return arg.initializer.text + } + } } } -- Gitee