Skip to content

Commit

Permalink
优化语法写法,以适配最新的 api12 和 ide,hvigor 5.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
zmtzawqlp committed Jun 18, 2024
1 parent 6048f55 commit 9f65d4c
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 167 deletions.
4 changes: 2 additions & 2 deletions build-profile.json5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"app": {
"signingConfigs": [],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "4.0.0(10)",
"runtimeOS": "HarmonyOS"
}
],
"buildModeSet": [
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class EntryAbility extends UIAbility {
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
AppStorage.SetOrCreate<number>("statusBarHeight", 36);
AppStorage.setOrCreate<number>("statusBarHeight", 36);
ScreenUtils.enterImmersion(windowStage);

windowStage.loadContent('pages/Index', (err, data) => {
Expand Down
6 changes: 3 additions & 3 deletions entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Index {
Column() {
Text(`${this.title}`)
List() {
ForEach(this.pages, (item, index) => {
ForEach(this.pages, (item:PageInfo, index) => {
ListItem() {
Text(`${index + 1}. ${item.description}`).onClick((x) => {
router.pushUrl({ url: item.route });
Expand All @@ -34,8 +34,8 @@ struct Index {
}

interface PageInfo {
description: String;
route: String;
description: string;
route: string;
}


6 changes: 3 additions & 3 deletions entry/src/main/ets/pages/PullToRefreshAppbar.ets
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct PullToRefreshAppbar {
}

onRefresh(): void {
var length = this.listData.length;
let length = this.listData.length;
let list: Array<number> = [];
for (let index = length; index < length + 20; index++) {
list.push(index);
Expand Down Expand Up @@ -71,11 +71,11 @@ struct PullToRefreshAppbar {
.height(this.controller.dragOffset + 200)
.objectFit(ImageFit.Cover)
List({ scroller: this.scroller }) {
ForEach(this.listData, (item, index) => {
ForEach(this.listData, (item:number, index) => {
ListItem() {
Text(`${item}`,).align(Alignment.Center)
}.height(100).width('100%')
}, (item, index) => {
}, (item:number, index) => {
return `${item}`;
})
}
Expand Down
6 changes: 3 additions & 3 deletions entry/src/main/ets/pages/PullToRefreshHeader.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct PullToRefreshHeader {
this.firstTime = false;
return false;
}
var length = this.listData.length;
let length = this.listData.length;

this.listData = [length + 3, length + 2, length + 1, ...this.listData];
this.lastRefreshTime = Date.now();
Expand Down Expand Up @@ -56,11 +56,11 @@ struct PullToRefreshHeader {
controller: this.controller,
})
List({ scroller: this.scroller }) {
ForEach(this.listData, (item, index) => {
ForEach(this.listData, (item:number, index) => {
ListItem() {
Text(`${item}`,).align(Alignment.Center)
}.height(100).width('100%')
}, (item, index) => {
}, (item:number, index) => {
return `${item}`;
})
}
Expand Down
15 changes: 8 additions & 7 deletions entry/src/main/ets/util/ScreenUtils.ets
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import display from '@ohos.display'

export class ScreenUtils {
static getStatusBarHeight() {
var statusBarHeight= AppStorage.Get<number>('statusBarHeight');
let statusBarHeight = AppStorage.get<number>('statusBarHeight');
return statusBarHeight;
}

static getBottomHeight() {
return AppStorage.Get<number>('bottomHeight');
return AppStorage.get<number>('bottomHeight');
}

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

let windowClass: window.Window = await windowStage.getMainWindow()

// 获取状态栏和导航栏的高度
windowClass.on("avoidAreaChange", ({ type, area }) => {
if (type == window.AvoidAreaType.TYPE_SYSTEM) {
windowClass.on("avoidAreaChange", (options: window.AvoidAreaOptions) => {
if (options.type == window.AvoidAreaType.TYPE_SYSTEM) {
// 将状态栏和导航栏的高度保存在AppStorage中
var defaultDisplay = display.getDefaultDisplaySync();
AppStorage.SetOrCreate<number>("statusBarHeight", area.topRect.height / defaultDisplay.densityPixels);
AppStorage.SetOrCreate<number>("bottomHeight", area.bottomRect.height / defaultDisplay.densityPixels);
let defaultDisplay = display.getDefaultDisplaySync();
AppStorage.setOrCreate<number>("statusBarHeight", options.area.topRect.height / defaultDisplay.densityPixels);
AppStorage.setOrCreate<number>("bottomHeight", options.area.bottomRect.height / defaultDisplay.densityPixels);
}
})
// 设置窗口布局为沉浸式布局
Expand Down
5 changes: 2 additions & 3 deletions hvigor/hvigor-config.json5
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"hvigorVersion": "3.0.9",
"modelVersion": "5.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "3.0.9"
},
"execution": {
// "daemon": true, /* Enable daemon compilation. Default: true */
Expand All @@ -15,4 +14,4 @@
"debugging": {
// "stacktrace": false /* Disable stacktrace compilation. Default: false */
}
}
}
1 change: 0 additions & 1 deletion hvigor/hvigor-wrapper.js

This file was deleted.

48 changes: 0 additions & 48 deletions hvigorw

This file was deleted.

64 changes: 0 additions & 64 deletions hvigorw.bat

This file was deleted.

3 changes: 2 additions & 1 deletion oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"modelVersion": "5.0.0",
"license": "",
"devDependencies": {
"@ohos/hypium": "1.0.11"
Expand All @@ -9,4 +10,4 @@
"main": "",
"version": "1.0.0",
"dependencies": {}
}
}
Binary file added pull_to_refresh/.DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions pull_to_refresh/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.1';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';

/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
4 changes: 4 additions & 0 deletions pull_to_refresh/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1

* 优化语法写法,以适配最新的 api12 和 ide,hvigor 5.0.0.

## 1.0.0

* Initial Open Source release.
Expand Down
2 changes: 1 addition & 1 deletion pull_to_refresh/build-profile.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"runtimeOS": "HarmonyOS"
}
]
}
}
Empty file.
2 changes: 1 addition & 1 deletion pull_to_refresh/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"description": "Harmony plugin for building pull to refresh effects with PullToRefresh quickly.",
"main": "index.ets",
"repository": "https://github.com/HarmonyCandies/pull_to_refresh",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/HarmonyCandies/pull_to_refresh",
"dependencies": {}
}
2 changes: 1 addition & 1 deletion pull_to_refresh/src/main/ets/common/Controller.ets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace pull_to_refresh {
/// The current pull mode
mode: PullToRefreshIndicatorMode = PullToRefreshIndicatorMode.initial;
/// internal
onRefresh: () => void;
onRefresh?: () => void | undefined = undefined;

refresh() {
if (this.onRefresh != undefined) {
Expand Down
Loading

0 comments on commit 9f65d4c

Please sign in to comment.