Skip to content

Commit 9f65d4c

Browse files
committed
优化语法写法,以适配最新的 api12 和 ide,hvigor 5.0.0.
1 parent 6048f55 commit 9f65d4c

19 files changed

+79
-167
lines changed

build-profile.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"app": {
33
"signingConfigs": [],
4-
"compileSdkVersion": 9,
5-
"compatibleSdkVersion": 9,
64
"products": [
75
{
86
"name": "default",
97
"signingConfig": "default",
8+
"compatibleSdkVersion": "4.0.0(10)",
9+
"runtimeOS": "HarmonyOS"
1010
}
1111
],
1212
"buildModeSet": [

entry/src/main/ets/entryability/EntryAbility.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class EntryAbility extends UIAbility {
1818
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
1919
// Main window is created, set main page for this ability
2020
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
21-
AppStorage.SetOrCreate<number>("statusBarHeight", 36);
21+
AppStorage.setOrCreate<number>("statusBarHeight", 36);
2222
ScreenUtils.enterImmersion(windowStage);
2323

2424
windowStage.loadContent('pages/Index', (err, data) => {

entry/src/main/ets/pages/Index.ets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Index {
2020
Column() {
2121
Text(`${this.title}`)
2222
List() {
23-
ForEach(this.pages, (item, index) => {
23+
ForEach(this.pages, (item:PageInfo, index) => {
2424
ListItem() {
2525
Text(`${index + 1}. ${item.description}`).onClick((x) => {
2626
router.pushUrl({ url: item.route });
@@ -34,8 +34,8 @@ struct Index {
3434
}
3535

3636
interface PageInfo {
37-
description: String;
38-
route: String;
37+
description: string;
38+
route: string;
3939
}
4040

4141

entry/src/main/ets/pages/PullToRefreshAppbar.ets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct PullToRefreshAppbar {
1717
}
1818

1919
onRefresh(): void {
20-
var length = this.listData.length;
20+
let length = this.listData.length;
2121
let list: Array<number> = [];
2222
for (let index = length; index < length + 20; index++) {
2323
list.push(index);
@@ -71,11 +71,11 @@ struct PullToRefreshAppbar {
7171
.height(this.controller.dragOffset + 200)
7272
.objectFit(ImageFit.Cover)
7373
List({ scroller: this.scroller }) {
74-
ForEach(this.listData, (item, index) => {
74+
ForEach(this.listData, (item:number, index) => {
7575
ListItem() {
7676
Text(`${item}`,).align(Alignment.Center)
7777
}.height(100).width('100%')
78-
}, (item, index) => {
78+
}, (item:number, index) => {
7979
return `${item}`;
8080
})
8181
}

entry/src/main/ets/pages/PullToRefreshHeader.ets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct PullToRefreshHeader {
2121
this.firstTime = false;
2222
return false;
2323
}
24-
var length = this.listData.length;
24+
let length = this.listData.length;
2525

2626
this.listData = [length + 3, length + 2, length + 1, ...this.listData];
2727
this.lastRefreshTime = Date.now();
@@ -56,11 +56,11 @@ struct PullToRefreshHeader {
5656
controller: this.controller,
5757
})
5858
List({ scroller: this.scroller }) {
59-
ForEach(this.listData, (item, index) => {
59+
ForEach(this.listData, (item:number, index) => {
6060
ListItem() {
6161
Text(`${item}`,).align(Alignment.Center)
6262
}.height(100).width('100%')
63-
}, (item, index) => {
63+
}, (item:number, index) => {
6464
return `${item}`;
6565
})
6666
}

entry/src/main/ets/util/ScreenUtils.ets

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ import display from '@ohos.display'
33

44
export class ScreenUtils {
55
static getStatusBarHeight() {
6-
var statusBarHeight= AppStorage.Get<number>('statusBarHeight');
6+
let statusBarHeight = AppStorage.get<number>('statusBarHeight');
77
return statusBarHeight;
88
}
99

1010
static getBottomHeight() {
11-
return AppStorage.Get<number>('bottomHeight');
11+
return AppStorage.get<number>('bottomHeight');
1212
}
1313

1414
static async enterImmersion(windowStage: window.WindowStage): Promise<void> {
1515

1616
let windowClass: window.Window = await windowStage.getMainWindow()
17+
1718
// 获取状态栏和导航栏的高度
18-
windowClass.on("avoidAreaChange", ({ type, area }) => {
19-
if (type == window.AvoidAreaType.TYPE_SYSTEM) {
19+
windowClass.on("avoidAreaChange", (options: window.AvoidAreaOptions) => {
20+
if (options.type == window.AvoidAreaType.TYPE_SYSTEM) {
2021
// 将状态栏和导航栏的高度保存在AppStorage中
21-
var defaultDisplay = display.getDefaultDisplaySync();
22-
AppStorage.SetOrCreate<number>("statusBarHeight", area.topRect.height / defaultDisplay.densityPixels);
23-
AppStorage.SetOrCreate<number>("bottomHeight", area.bottomRect.height / defaultDisplay.densityPixels);
22+
let defaultDisplay = display.getDefaultDisplaySync();
23+
AppStorage.setOrCreate<number>("statusBarHeight", options.area.topRect.height / defaultDisplay.densityPixels);
24+
AppStorage.setOrCreate<number>("bottomHeight", options.area.bottomRect.height / defaultDisplay.densityPixels);
2425
}
2526
})
2627
// 设置窗口布局为沉浸式布局

hvigor/hvigor-config.json5

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"hvigorVersion": "3.0.9",
2+
"modelVersion": "5.0.0",
33
"dependencies": {
4-
"@ohos/hvigor-ohos-plugin": "3.0.9"
54
},
65
"execution": {
76
// "daemon": true, /* Enable daemon compilation. Default: true */
@@ -15,4 +14,4 @@
1514
"debugging": {
1615
// "stacktrace": false /* Disable stacktrace compilation. Default: false */
1716
}
18-
}
17+
}

hvigor/hvigor-wrapper.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

hvigorw

Lines changed: 0 additions & 48 deletions
This file was deleted.

hvigorw.bat

Lines changed: 0 additions & 64 deletions
This file was deleted.

oh-package.json5

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"modelVersion": "5.0.0",
23
"license": "",
34
"devDependencies": {
45
"@ohos/hypium": "1.0.11"
@@ -9,4 +10,4 @@
910
"main": "",
1011
"version": "1.0.0",
1112
"dependencies": {}
12-
}
13+
}

pull_to_refresh/.DS_Store

6 KB
Binary file not shown.

pull_to_refresh/BuildProfile.ets

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
3+
*/
4+
export const HAR_VERSION = '1.0.1';
5+
export const BUILD_MODE_NAME = 'debug';
6+
export const DEBUG = true;
7+
export const TARGET_NAME = 'default';
8+
9+
/**
10+
* BuildProfile Class is used only for compatibility purposes.
11+
*/
12+
export default class BuildProfile {
13+
static readonly HAR_VERSION = HAR_VERSION;
14+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15+
static readonly DEBUG = DEBUG;
16+
static readonly TARGET_NAME = TARGET_NAME;
17+
}

pull_to_refresh/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
* 优化语法写法,以适配最新的 api12 和 ide,hvigor 5.0.0.
4+
15
## 1.0.0
26

37
* Initial Open Source release.

pull_to_refresh/build-profile.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"runtimeOS": "HarmonyOS"
99
}
1010
]
11-
}
11+
}

pull_to_refresh/example/example.ets

Whitespace-only changes.

pull_to_refresh/oh-package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"description": "Harmony plugin for building pull to refresh effects with PullToRefresh quickly.",
1212
"main": "index.ets",
1313
"repository": "https://github.com/HarmonyCandies/pull_to_refresh",
14-
"version": "1.0.0",
14+
"version": "1.0.1",
1515
"homepage": "https://github.com/HarmonyCandies/pull_to_refresh",
1616
"dependencies": {}
1717
}

pull_to_refresh/src/main/ets/common/Controller.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace pull_to_refresh {
99
/// The current pull mode
1010
mode: PullToRefreshIndicatorMode = PullToRefreshIndicatorMode.initial;
1111
/// internal
12-
onRefresh: () => void;
12+
onRefresh?: () => void | undefined = undefined;
1313

1414
refresh() {
1515
if (this.onRefresh != undefined) {

0 commit comments

Comments
 (0)