diff --git a/arkoala-arkts/arkui/config/etsconfig-base.json b/arkoala-arkts/arkui/config/etsconfig-base.json index a1bc1c4e3cb49a2235a702a6b4e3f4f7125c59a9..2d0215a9f55aba9c155e2b1cbee3f70619e3bd4b 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 7ddd061676358e3bbab082ef8175911c345754dc..b5b5479ae7087d8bf15e0781a501982b191d58a2 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 b8ebda64d9c0bea28ee0443322ce9c17244da51b..e74e56033456eddf6bdbc55b4b9581c6f1b70c59 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 228f2bfde7bb613129437b24e7a0bbf5b35d0ae9..474510c7e412d82d868b64d04189fb26d441108f 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 0000000000000000000000000000000000000000..7d74fde6a8d608d7a9f190997794a60fda4ed327 --- /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 0000000000000000000000000000000000000000..f949acb72d747985febfd79dc15455fa1ec11b81 --- /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 0000000000000000000000000000000000000000..761dc738a281c3d98045e875a103101d244ad3d6 --- /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 0000000000000000000000000000000000000000..13168ce15892c181faf08ded317c818586970024 --- /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 0000000000000000000000000000000000000000..907c444dab76b54a4b4f76fe496ffed0c3981b77 --- /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 2abbabdde2f936ab1172c39bccee6d2e47bc60fb..2ff0eb1146303e21b06ba23eec0ef44dbf7471fc 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 5ac9f4c700424e71f99f57d1962829f45751e1f3..5f1ba6ef4a5f8c10d7889f3e7e25cbedc8d6ba6c 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 + } + } } }