list组件
这个提交包含在:
父节点
b46ca97553
当前提交
4130519353
@ -47,6 +47,7 @@ export { WindowHelper } from './src/main/ets/utils/WindowHelper'
|
|||||||
*/
|
*/
|
||||||
export { LoadingView } from './src/main/ets/view/LoadingView'
|
export { LoadingView } from './src/main/ets/view/LoadingView'
|
||||||
export { SafeView } from './src/main/ets/view/SafeView'
|
export { SafeView } from './src/main/ets/view/SafeView'
|
||||||
|
export { RefreshView } from './src/main/ets/view/RefreshView'
|
||||||
/**
|
/**
|
||||||
* 自定义view
|
* 自定义view
|
||||||
*/
|
*/
|
||||||
|
|||||||
40
README.md
40
README.md
@ -4,6 +4,28 @@
|
|||||||
ohpm install @szyx/sdk_base
|
ohpm install @szyx/sdk_base
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 0.初始化
|
||||||
|
> 在UIAbility的onWindowStageCreate方法中初始化该方法
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// 初始化
|
||||||
|
import { WindowHelper } from '@szyx/sdk_base';
|
||||||
|
export default class AppAbility extends UIAbility {
|
||||||
|
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||||
|
|
||||||
|
windowStage.loadContent('pages/Index', (err) => {
|
||||||
|
if (err.code) {
|
||||||
|
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WindowHelper.windowClass = windowStage.getMainWindowSync()
|
||||||
|
});
|
||||||
|
// 这行代码
|
||||||
|
GlobalContext.setContext(this.context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 1.[utils](./src/main/ets/utils)
|
## 1.[utils](./src/main/ets/utils)
|
||||||
|
|
||||||
### 1.1.[AppStorageHelper](./src/main/ets/utils/AppStorageHelper.ets)
|
### 1.1.[AppStorageHelper](./src/main/ets/utils/AppStorageHelper.ets)
|
||||||
@ -330,24 +352,6 @@ WindowHelper.close()
|
|||||||
|
|
||||||
### 5.2.设置沉浸式相关
|
### 5.2.设置沉浸式相关
|
||||||
|
|
||||||
```tsx
|
|
||||||
// 初始化
|
|
||||||
import { WindowHelper } from '@szyx/sdk_base';
|
|
||||||
export default class AppAbility extends UIAbility {
|
|
||||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
||||||
|
|
||||||
windowStage.loadContent('pages/Index', (err) => {
|
|
||||||
if (err.code) {
|
|
||||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WindowHelper.windowClass = windowStage.getMainWindowSync()
|
|
||||||
});
|
|
||||||
GlobalContext.setContext(this.context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
// 需要的界面
|
// 需要的界面
|
||||||
// 设置是否全屏
|
// 设置是否全屏
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type common from '@ohos.app.ability.common';
|
import type common from '@ohos.app.ability.common';
|
||||||
|
import { WindowHelper } from './utils/WindowHelper';
|
||||||
|
|
||||||
declare namespace globalThis {
|
declare namespace globalThis {
|
||||||
let _brushEngineContext: common.UIAbilityContext;
|
let _brushEngineContext: common.UIAbilityContext;
|
||||||
@ -15,6 +16,7 @@ export class GlobalContext {
|
|||||||
|
|
||||||
static setContext(context: common.UIAbilityContext): void {
|
static setContext(context: common.UIAbilityContext): void {
|
||||||
globalThis._brushEngineContext = context;
|
globalThis._brushEngineContext = context;
|
||||||
|
WindowHelper.windowClass = context.windowStage.getMainWindowSync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
import { ToolsHelper } from '../utils/ToolsHelper'
|
||||||
|
|
||||||
|
type ItemType = (string | number | Object)
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Component
|
||||||
|
export struct RefreshView {
|
||||||
|
@Prop isLoading: boolean
|
||||||
|
@Prop data: ItemType[]
|
||||||
|
|
||||||
|
@Builder customBuilder() {}
|
||||||
|
// 使用父组件@Builder装饰的方法初始化子组件@BuilderParam
|
||||||
|
@BuilderParam customBuilderParam: (item:string) => void = this.customBuilder;
|
||||||
|
|
||||||
|
build() {
|
||||||
|
|
||||||
|
Refresh({ refreshing: $$this.isLoading }) {
|
||||||
|
List() {
|
||||||
|
ForEach(this.data ?? [], (item: string) => {
|
||||||
|
ListItem() {
|
||||||
|
this.customBuilderParam(item)
|
||||||
|
}
|
||||||
|
.backgroundColor('blue')
|
||||||
|
}, (index: number) => index.toString())
|
||||||
|
}
|
||||||
|
.onScrollStart(() => {
|
||||||
|
ToolsHelper.log('onScrollStart')
|
||||||
|
})
|
||||||
|
.onScrollStop(() => {
|
||||||
|
ToolsHelper.log('onScrollStop')
|
||||||
|
})
|
||||||
|
.onTouch((event: TouchEvent) => {
|
||||||
|
const e1 = event.touches[0]
|
||||||
|
ToolsHelper.log(`onTouch ${event.type}-${e1.x.toString()}-${e1.y.toString()}`)
|
||||||
|
})
|
||||||
|
.onScrollIndex((first: number, last: number) => {
|
||||||
|
ToolsHelper.log(`${first.toString()}-${last.toString()}`)
|
||||||
|
})
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
.alignListItem(ListItemAlign.Center)
|
||||||
|
.scrollBar(BarState.Off)
|
||||||
|
}.width('100%')
|
||||||
|
.backgroundColor('red')
|
||||||
|
.height('100%')
|
||||||
|
.onStateChange((refreshStatus: RefreshStatus) => {
|
||||||
|
ToolsHelper.log('Refresh onStatueChange state is ' + refreshStatus)
|
||||||
|
})
|
||||||
|
.onRefreshing(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isLoading = false
|
||||||
|
}, 2000)
|
||||||
|
ToolsHelper.log('onRefreshing test')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -80,7 +80,7 @@ export struct SafeView {
|
|||||||
}).visibility(!this.hideBack ? Visibility.Visible : Visibility.None)
|
}).visibility(!this.hideBack ? Visibility.Visible : Visibility.None)
|
||||||
}.width(110)
|
}.width(110)
|
||||||
|
|
||||||
Text(`${this.titleText}`)
|
Text(this.titleText ?? '')
|
||||||
.maxLines(1)
|
.maxLines(1)
|
||||||
.fontColor('#11102C')
|
.fontColor('#11102C')
|
||||||
.fontSize(16)
|
.fontSize(16)
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户