From 9818389e91e3aa859499094a4fb7b773815abc1f Mon Sep 17 00:00:00 2001 From: genglingxia Date: Sat, 11 Mar 2023 18:02:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E9=A1=B5=E9=9D=A2=E5=B8=83=E5=B1=80=E5=90=88?= =?UTF-8?q?=E4=B8=80=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=96=87=E6=9C=AC=E6=A1=86?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/MainAbility/MainAbility.ts | 3 + .../entry/src/main/ets/pages/index/index.ets | 97 +++++++++++++------ kvdb_stage_demo/entry/src/main/module.json5 | 6 +- 3 files changed, 77 insertions(+), 29 deletions(-) diff --git a/kvdb_stage_demo/entry/src/main/ets/MainAbility/MainAbility.ts b/kvdb_stage_demo/entry/src/main/ets/MainAbility/MainAbility.ts index e8030f8..90b7f1d 100644 --- a/kvdb_stage_demo/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/kvdb_stage_demo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -219,6 +219,7 @@ export default class MainAbility extends Ability { let key = DEMO_KEY_PREFIX + nameList[Math.floor(Math.random() * nameList.length)]; let value = random(1, 100); let self = this; + self.logText += "put start. key=" + key + ", value=" + value + " \r\n"; this.kvStore.put(key, value).then((data) => { console.log("[JSDemo]: put success. "); self.logText += "put success. \r\n"; @@ -240,6 +241,8 @@ export default class MainAbility extends Ability { return; } try { + console.log("[JSDemo] Get All localDevice data start. "); + this.logText += ("Get All local localDevice start. \r\n"); let self = this; if (globalThis.kvStoreType == distributedData.KVStoreType.DEVICE_COLLABORATION) { //deviceKvStore var localDeviceId = this.devManager.getLocalDeviceInfoSync().deviceId; diff --git a/kvdb_stage_demo/entry/src/main/ets/pages/index/index.ets b/kvdb_stage_demo/entry/src/main/ets/pages/index/index.ets index 22b3cbb..2de3aca 100644 --- a/kvdb_stage_demo/entry/src/main/ets/pages/index/index.ets +++ b/kvdb_stage_demo/entry/src/main/ets/pages/index/index.ets @@ -48,7 +48,13 @@ struct Index { core.execute() } - @State text: string = '' + @State rotateAngle: number = 0 + @State speed: number = 1 + + scroller: Scroller = new Scroller() + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + @State text: string = 'The green button calls the interface, and the blue button sets the properties.' @State encryptSelect:number = 0 private encryptLst:string[] = ['false','true'] @@ -70,12 +76,12 @@ struct Index { build() { Column({space:2}) { Row({space:2}) { - Button('CreateKvManager').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('CreateKvManager').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.CreateKvManager(); this.text = globalThis.printLogs(); }) - Button('SetEncrypt').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetEncrypt').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.encryptLst, @@ -95,7 +101,7 @@ struct Index { } }) }) - Button('SetAutoSync').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetAutoSync').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.autoSyncLst, @@ -116,11 +122,12 @@ struct Index { }) }) } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Row({space:2}) { - Button('SetKvStoreType').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetKvStoreType').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.kvStoreTypeLst, @@ -140,7 +147,7 @@ struct Index { } }) }) - Button('SetSecurityLevel').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetSecurityLevel').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.securityLevelLst, @@ -160,18 +167,19 @@ struct Index { } }) }) - Button('GetKvStore').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('GetKvStore').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.GetKvStore(); this.text = globalThis.printLogs(); }) } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Row({space:2}) { - Button('SetSubscribeType').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetSubscribeType').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.subscribeTypeLst, @@ -191,43 +199,45 @@ struct Index { } }) }) - Button('RegDataChange').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('RegDataChange').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.RegDataChange(); this.text = globalThis.printLogs(); }) - Button('RegSyncComplete').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('RegSyncComplete').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.RegSyncComplete(); this.text = globalThis.printLogs(); }) } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Row({space:2}) { - Button('Put').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('Put').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.PutRandom(); this.text = globalThis.printLogs(); }) - Button('Get').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('Get').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.GetAllData(); this.text = globalThis.printLogs(); }) - Button('Delete').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('Delete').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.DeleteAllData(); this.text = globalThis.printLogs(); }) } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Row({space:2}) { - Button('SetSyncMode').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('SetSyncMode').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .onClick(() => { TextPickerDialog.show({ range:this.syncModLst, @@ -247,43 +257,74 @@ struct Index { } }) }) - Button('Sync').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('Sync').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.Sync(); this.text = globalThis.printLogs(); }) - Button('DeleteKvStore').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('DeleteKvStore').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { globalThis.DeleteKvStore(); this.text = globalThis.printLogs(); }) } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Row({space:2}){ - Button('PrintLogs').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('PrintLogs').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { this.text = globalThis.printLogs(); }) - Button('ClearLog').fontSize(12).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('150').height('100%') + Button('ClearLog').fontSize(10).fontWeight(FontWeight.Normal).type(ButtonType.Capsule).margin({}).width('33%').height('100%') .backgroundColor('#f32dc400').onClick(() => { this.text = globalThis.clearLog(); }) + Column().width('33%').height('100%') } - .width('100%') + .justifyContent(FlexAlign.Center) + .width('99%') .height('6%') Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { - Text(this.text) { + Scroll(this.scroller) { + Column(){ + Text(this.text).textAlign(TextAlign.Start).fontSize(10).baselineOffset(10).width('100%') + } + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .gesture( + SwipeGesture({ direction: SwipeDirection.Vertical }) // ´¹Ö±»¬¶¯ + .onAction((event: GestureEvent) => { + this.scroller.scrollBy(0, 150) + }) + ) + .width('100%') + .height('500%') + } + .scrollable(ScrollDirection.Vertical) // ¹ö¶¯·½Ïò×ÝÏò + .scrollBar(BarState.On) // ¹ö¶¯Ìõ³£×¤ÏÔʾ + .scrollBarColor(Color.Gray) // ¹ö¶¯ÌõÑÕÉ« + .scrollBarWidth(3) // ¹ö¶¯Ìõ¿í¶È + .edgeEffect(EdgeEffect.None) + .onScroll((xOffset: number, yOffset: number) => { + console.info(xOffset + ' ' + yOffset) + }) + .onScrollEdge((side: Edge) => { + console.info('To the edge') + }) + .onScrollEnd(() => { + console.info('Scroll Stop') + }) - }.baselineOffset(10).fontSize(9) } - .width('100%') + .width('99%') .height('60%') .border({width:1}) } - .width('99%') + .justifyContent(FlexAlign.Center) + .width('100%') .height('100%') } diff --git a/kvdb_stage_demo/entry/src/main/module.json5 b/kvdb_stage_demo/entry/src/main/module.json5 index 2373bba..c97c9bb 100644 --- a/kvdb_stage_demo/entry/src/main/module.json5 +++ b/kvdb_stage_demo/entry/src/main/module.json5 @@ -38,6 +38,10 @@ { "name": "ohos.permission.DISTRIBUTED_DATASYNC" } - ] + ], + "metadata": [{ + "name": "ArkTSPartialUpdate", + "value": "true" + }] } } \ No newline at end of file -- Gitee