diff --git a/SimpleChatList/.gitignore b/SimpleChatList/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/SimpleChatList/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/SimpleChatList/AppScope/app.json5 b/SimpleChatList/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f8276ba46393c4d0de988f4b476706f61c7487b2 --- /dev/null +++ b/SimpleChatList/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.simplechatlist", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/SimpleChatList/AppScope/resources/base/element/string.json b/SimpleChatList/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ce1a5e303ab91b3ae1ce992e1f87e0d8bc14486c --- /dev/null +++ b/SimpleChatList/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "SimpleChatList" + } + ] +} diff --git a/SimpleChatList/AppScope/resources/base/media/background.png b/SimpleChatList/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/SimpleChatList/AppScope/resources/base/media/background.png differ diff --git a/SimpleChatList/AppScope/resources/base/media/foreground.png b/SimpleChatList/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/SimpleChatList/AppScope/resources/base/media/foreground.png differ diff --git a/SimpleChatList/AppScope/resources/base/media/layered_image.json b/SimpleChatList/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/SimpleChatList/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/SimpleChatList/build-profile.json5 b/SimpleChatList/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3fe3beb28b59a5e0318d7d915aa9864359099e0 --- /dev/null +++ b/SimpleChatList/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.1.1(19)", + "compatibleSdkVersion": "5.1.1(19)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/SimpleChatList/code-linter.json5 b/SimpleChatList/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/SimpleChatList/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/.gitignore b/SimpleChatList/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/SimpleChatList/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/SimpleChatList/entry/build-profile.json5 b/SimpleChatList/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/SimpleChatList/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/SimpleChatList/entry/hvigorfile.ts b/SimpleChatList/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/SimpleChatList/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/SimpleChatList/entry/obfuscation-rules.txt b/SimpleChatList/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/SimpleChatList/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/SimpleChatList/entry/oh-package.json5 b/SimpleChatList/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/SimpleChatList/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/SimpleChatList/entry/src/main/ets/entryability/EntryAbility.ets b/SimpleChatList/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/SimpleChatList/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets b/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets new file mode 100644 index 0000000000000000000000000000000000000000..0be3050cfa481c6f43fd5b13320fc559e39d488e --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/EdgeBlur.ets @@ -0,0 +1,51 @@ +@Entry +@Component +struct EdgeBlur { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + // [Start linearGradient] + @Builder + overlayBuilder() { + Stack().height('100%').height('100%') + .linearGradient({ + direction: GradientDirection.Bottom, // Gradient direction. + colors: [['#00FFFFFF', 0.0], ['#FFFFFFFF', 0.3], ['#FFFFFFFF', 0.7], ['#00FFFFFF', 1]] + }) + .blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN) + } + + build() { + Column() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(16) + .backgroundColor(0xDCDCDC) + } + .borderRadius(16) + .backgroundColor(0xDCDCDC) + }, (item: string) => item) + } + .overlay(this.overlayBuilder()) + // [End linearGradient] + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + // [Start DisableScrolling] + .onScrollFrameBegin((offset: number, state: ScrollState) => { + return { offsetRemain: 0 } // If the return value is set to 0, it means that there will be no scrolling. + }) + // [End DisableScrolling] + .friction(0.6) + .contentEndOffset(60) + .width('90%') + } + .width('100%') + .height('100%') + .padding({ top: 10 }) + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/Index.ets b/SimpleChatList/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f27e9cf56f8e002118fd1d4a0680ae6d393875d9 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,64 @@ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + @State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + private scroller: Scroller = new Scroller(); + + build() { + Column() { + // [Start Specify_Offset_Scrolling] + Button('scroll 200') + .height('5%') + .onClick(() => { + let curve = curves.interpolatingSpring(10, 1, 228, 30); + const yOffset: number = this.scroller.currentOffset().yOffset; + this.scroller.scrollTo({ xOffset: 0, yOffset: yOffset + 200, animation: { duration: 1000, curve: curve } }) + }) + // [End Specify_Offset_Scrolling] + + // [Start Partial_Refresh] + Button('Partial_Refresh') + .height('5%') + .margin({ top: 8, bottom: 8 }) + .onClick(() => { + this.arr[0] += 10; + }) + // [End Partial_Refresh] + + List({ space: 20, initialIndex: 0, scroller: this.scroller }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(16) + .backgroundColor(0xDCDCDC) + } + .borderRadius(16) + .backgroundColor(0xDCDCDC) + }, (item: string) => item) + } + .scrollBar(BarState.Off) + .friction(0.6) + .contentEndOffset(60) + // [Start Rolling_Monitoring] + .onWillScroll(() => { + // Trigger before scrolling component scrolling. + console.info('currentOffset:' + this.scroller.currentOffset().yOffset) + }) + .onDidScroll(() => { + // Triggered when scrolling components scroll. + console.info('currentOffset:' + this.scroller.currentOffset().yOffset) + }) + // [End Rolling_Monitoring] + .width('90%') + } + .width('100%') + .height('100%') + .padding({ top: 10 }) + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets b/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets new file mode 100644 index 0000000000000000000000000000000000000000..7888fa0c76cc13ab93aebcb315df2de65ea2015f --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/LoopScrolling.ets @@ -0,0 +1,145 @@ +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: string[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return this.originDataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length * 3; + } + + public getData(index: number): string { + return this.dataArray[index % this.dataArray.length]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public moveDataWithoutNotify(from: number, to: number): void { + let tmp = this.dataArray.splice(from, 1); + this.dataArray.splice(to, 0, tmp[0]); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } + + public deleteData(index: number): void { + this.dataArray.splice(index, 1); + this.notifyDataDelete(index) + } +} + +@Entry +@Component +struct LoopScrolling { + private data: MyDataSource = new MyDataSource(); + private scroller: Scroller = new Scroller(); + + aboutToAppear(): void { + for (let i = 0; i < 10; i++) { + this.data.pushData(i.toString()) + } + } + + build() { + Row() { + List({ initialIndex: 10, scroller: this.scroller }) { + LazyForEach(this.data, (item: string) => { + ListItem() { + Text(item.toString()) + .fontSize(16) + .textAlign(TextAlign.Center) + .size({ height: 200, width: 200 }) + } + .borderRadius(16) + .margin(10) + .backgroundColor("#FFFFFF") + + }, (item: string) => item) + } + .width('100%') + .height(300) + .backgroundColor('#FFDCDCDC') + .listDirection(Axis.Horizontal) + .scrollSnapAlign(ScrollSnapAlign.START) + .friction(2) + // [Start LoopScrolling] + .onScrollFrameBegin((offset: number, state: ScrollState) => { + let currentOffset = this.scroller.currentOffset().xOffset; + let newOffset = currentOffset + offset; + let totalWeight = 220 * 10; // The total width of LIST. + if (newOffset < totalWeight * 0.5) { + newOffset += totalWeight; + } else if (newOffset > totalWeight * 2.5) { + newOffset -= totalWeight; + } + return { offsetRemain: newOffset - currentOffset }; + }) + + // [End LoopScrolling] + } + .width('100%') + .height('100%') + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/MaintainVisibleAreaContent.ets b/SimpleChatList/entry/src/main/ets/pages/MaintainVisibleAreaContent.ets new file mode 100644 index 0000000000000000000000000000000000000000..d8722526a8aaab615929511ec87796b465c55dd1 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/MaintainVisibleAreaContent.ets @@ -0,0 +1,131 @@ +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: TextClass[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): TextClass { + return this.originDataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: TextClass[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): TextClass { + return this.dataArray[index]; + } + + // [Start Add_delete data] + public addData(index: number, data: TextClass): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: TextClass): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } + + // [Start Add_delete data] +} + +class TextClass { + message: string = ''; + + constructor(message: string) { + this.message = message; + } +} + +@Entry +@Component +struct MaintainVisibleAreaContent { + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + for (let i = 0; i < 20; i++) { + this.data.pushData(new TextClass(`Hello ${i}`)); + } + } + + build() { + Stack() { + // [Start MaintainVisibleAreaContent] + List({ space: 3 }) { + LazyForEach(this.data, (item: TextClass) => { + ListItem() { + Row() { + Text(item.message).fontSize(20) + } + .height(50) + .margin({ left: 10, right: 10 }) + } + }, (item: TextClass) => JSON.stringify(item)) + } + .width('100%') + .height('100%') + .maintainVisibleContentPosition(true) + + // [End MaintainVisibleAreaContent] + + Button('Insert Data') + .onClick(() => { + this.data.addData(0, new TextClass('Hello -1')); + this.data.addData(0, new TextClass('Hello -2')); + this.data.addData(0, new TextClass('Hello -3')); + }) + } + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets b/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets new file mode 100644 index 0000000000000000000000000000000000000000..479b1f163b8517b71fc3653da3176c0d482fa002 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets @@ -0,0 +1,80 @@ +@Entry +@Component +struct PullUpLoading { + @State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State isRefreshing: boolean = false; + @State refreshOffset: number = 0; + @State refreshState: RefreshStatus = RefreshStatus.Inactive; + + // [Start PullToRefresh] + @Builder + refreshBuilder() { + Stack({ alignContent: Alignment.Bottom }) { + if (this.refreshState != RefreshStatus.Inactive && this.refreshState != RefreshStatus.Done) { + Progress({ value: this.refreshOffset, total: 64, type: ProgressType.Ring }) + .width(32) + .height(32) + .style({ status: this.isRefreshing ? ProgressStatus.LOADING : ProgressStatus.PROGRESSING }) + .margin(10) + } + } + .width('100%') + .height('100%') + } + + build() { + Refresh({ refreshing: $$this.isRefreshing, builder: this.refreshBuilder }) { + // [StartExclude PullToRefresh] + // [Start PullUpLoading] + List() { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }, (item: string) => item) + ListItem() { + Row() { + LoadingProgress().height(32).width(48) + Text('加载中') + } + } + .width('100%') + .height(64) + } + .onScrollIndex((start: number, end: number) => { + if (end > this.arr.length) { + setTimeout(() => { + for (let i = 0; i < 5; i++) { + this.arr.push(this.arr.length); + } + }) + } + }) + // [End PullUpLoading] + .onAreaChange((oldValue: Area, newValue: Area) => { + this.refreshOffset = newValue.position.y as number; + }) + .scrollBar(BarState.Off) + .divider({ strokeWidth: '1px' }) + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .onStateChange((state: RefreshStatus) => { + this.refreshState = state; + }) + // [EndExclude PullToRefresh] + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + }) + // [End PullToRefresh] + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/ScrollLeftAndRightToRefresh.ets b/SimpleChatList/entry/src/main/ets/pages/ScrollLeftAndRightToRefresh.ets new file mode 100644 index 0000000000000000000000000000000000000000..94dc2ef0e0dca451520276a8bfc824addd875d1b --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/ScrollLeftAndRightToRefresh.ets @@ -0,0 +1,63 @@ +@Entry +@Component +struct ScrollLeftAndRightToRefresh { + @State isRefreshing: boolean = false; + @State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + build() { + // [Start ScrollLeftAndRightToRefresh] + Column() { + Refresh({ refreshing: $$this.isRefreshing }) { + List({ space: 10 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width(300) + .height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(16) + .backgroundColor(0xFFFFFF) + .translate({ x: (80 - 300) / 2 }) + .rotate({ + x: 0, + y: 0, + z: 1, + centerX: '50%', + centerY: '50%', + angle: 90 + }) + } + .width(80) + .height(300) + }, (item: string) => item) + } + .width(300) + .height(300) + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + } + .onRefreshing(() => { + setTimeout(() => { + this.isRefreshing = false; + }, 2000) + }) + .backgroundColor(0x89CFF0) + .refreshOffset(64) + .pullToRefresh(true) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + .rotate({ + x: 0, + y: 0, + z: 1, + centerX: '50%', + centerY: '50%', + angle: -90 + }) + + // [End ScrollLeftAndRightToRefresh] + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/ScrollToTheBottom.ets b/SimpleChatList/entry/src/main/ets/pages/ScrollToTheBottom.ets new file mode 100644 index 0000000000000000000000000000000000000000..6220a6a045716726f845ab112a3158d598bf7598 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/ScrollToTheBottom.ets @@ -0,0 +1,50 @@ +@Entry +@Component +struct ScrollToTheBottom { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + // [Start Scroller] + private scroller: Scroller = new Scroller(); + + // [StartExclude Scroller] + + build() { + Column() { + // [EndExclude Scroller] + // [Start initialIndex] + List({ space: 20, initialIndex: this.arr.length - 1, scroller: this.scroller }) { + // [End Scroller] + ForEach(this.arr, (item: number) => { + ListItem() { + // [StartExclude initialIndex] + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(16) + .backgroundColor(0xDCDCDC) + // [EndExclude initialIndex] + } + .borderRadius(16) + .backgroundColor(0xDCDCDC) + }, (item: string) => item) + } + // [End initialIndex] + .scrollBar(BarState.Off) + .friction(0.6) + .contentEndOffset(60) + .onAppear(() => { + // [Start scrollToIndex] + this.scroller.scrollToIndex(this.arr.length - 1); + // [End scrollToIndex] + // [Start scrollEdge] + this.scroller.scrollEdge(Edge.Bottom); + // [End scrollEdge] + }) + .width('90%') + } + .width('100%') + .height('100%') + .padding({ top: 10 }) + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/ets/pages/UnilateralRebound.ets b/SimpleChatList/entry/src/main/ets/pages/UnilateralRebound.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5c3f8c20216980201deb61b8cf505919942f5d1 --- /dev/null +++ b/SimpleChatList/entry/src/main/ets/pages/UnilateralRebound.ets @@ -0,0 +1,47 @@ +@Entry +@Component +struct EdgeBlur { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + private scroller: Scroller = new Scroller(); + private isTop: boolean = true; + + build() { + Column() { + // [Start UnilateralRebound] + List({ space: 20, initialIndex: 0, scroller: this.scroller }) { + // [StartExclude UnilateralRebound] + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(16) + .backgroundColor(0xDCDCDC) + } + .borderRadius(16) + .backgroundColor(0xDCDCDC) + }, (item: string) => item) + // [EndExclude UnilateralRebound] + } + .width('90%') + .scrollBar(BarState.Off) + .onDidScroll(() => { + const y = this.scroller.currentOffset().yOffset; + this.isTop = y <= 0; + }) + // [Start UnilateralRebound2] + .edgeEffect(this.isTop ? EdgeEffect.Spring : EdgeEffect.None) + // [End UnilateralRebound] + .onScrollIndex((firstIndex: number) => { + this.isTop = firstIndex === 0; + console.info('firstIndex:' + firstIndex + ',' + this.isTop) + }) + // [End UnilateralRebound2] + } + .width('100%') + .height('100%') + .padding({ top: 10 }) + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/module.json5 b/SimpleChatList/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..53024e8f020cc0824592631ba6924108c8028f0f --- /dev/null +++ b/SimpleChatList/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/resources/base/element/color.json b/SimpleChatList/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/resources/base/element/float.json b/SimpleChatList/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/SimpleChatList/entry/src/main/resources/base/element/string.json b/SimpleChatList/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/resources/base/media/background.png b/SimpleChatList/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/SimpleChatList/entry/src/main/resources/base/media/background.png differ diff --git a/SimpleChatList/entry/src/main/resources/base/media/foreground.png b/SimpleChatList/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/SimpleChatList/entry/src/main/resources/base/media/foreground.png differ diff --git a/SimpleChatList/entry/src/main/resources/base/media/layered_image.json b/SimpleChatList/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/resources/base/media/startIcon.png b/SimpleChatList/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/SimpleChatList/entry/src/main/resources/base/media/startIcon.png differ diff --git a/SimpleChatList/entry/src/main/resources/base/profile/backup_config.json b/SimpleChatList/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/SimpleChatList/entry/src/main/resources/base/profile/main_pages.json b/SimpleChatList/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/SimpleChatList/entry/src/main/resources/dark/element/color.json b/SimpleChatList/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/SimpleChatList/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/SimpleChatList/hvigor/hvigor-config.json5 b/SimpleChatList/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6f008c99c91ca502036e67232e4c089e0421aefc --- /dev/null +++ b/SimpleChatList/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.1.1", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/SimpleChatList/hvigorfile.ts b/SimpleChatList/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/SimpleChatList/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/SimpleChatList/oh-package-lock.json5 b/SimpleChatList/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c2f6d1bc9cb330eeb990573aa7e74cbccfb64b61 --- /dev/null +++ b/SimpleChatList/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/SimpleChatList/oh-package.json5 b/SimpleChatList/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..052cc24d6e7b3f754ab5557652fd9db52c4c2549 --- /dev/null +++ b/SimpleChatList/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.1.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +}