Commit b5cfd81b by huangqy

自定义弹窗

parent 5f959268
import { generalInitList, UniListItem } from '@ohos/system/src/main/ets/model/UniInitList' import { generalInitList, UniListItem } from '@ohos/system/src/main/ets/model/UniInitList'
import { TitleBar } from '../../view/title/TitleBar' import { TitleBar } from '../../view/title/TitleBar'
import { BasicDialog } from '../../view/BasicDialog/BasicDialog'
@Extend(Button) function CommonButtonStyle() { @Extend(Button) function CommonButtonStyle() {
.borderWidth(2) .borderWidth(2)
...@@ -15,6 +16,31 @@ import { TitleBar } from '../../view/title/TitleBar' ...@@ -15,6 +16,31 @@ import { TitleBar } from '../../view/title/TitleBar'
@Component @Component
export struct General { export struct General {
dialogController: CustomDialogController = new CustomDialogController({
builder: BasicDialog({
cancel: this.onCancel,
confirm: this.onSubmit,
}),
cancel: this.existApp,
autoCancel: true,
alignment: DialogAlignment.Default,
offset: { dx: 0, dy: -20 },
gridCount: 4,
customStyle: false
})
onCancel() {
console.info('------取消------')
}
onSubmit() {
console.info('------确认------')
}
existApp() {
console.info('Click the callback in the blank area')
}
build() { build() {
Column() { Column() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween}) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween}) {
...@@ -46,7 +72,9 @@ export struct General { ...@@ -46,7 +72,9 @@ export struct General {
} }
.height('8%') .height('8%')
.onClick(() => { .onClick(() => {
if (this.dialogController != undefined) {
this.dialogController.open()
}
}) })
}) })
} }
......
import { BasicTable } from '../../view/BasicTable/BasicTable'
import { TitleBar } from '../../view/title/TitleBar' import { TitleBar } from '../../view/title/TitleBar'
@Entry @Entry
......
@CustomDialog
@Component
export struct BasicDialog {
controller: CustomDialogController
cancel: () => void
confirm: () => void
build() {
Column() {
Row() {
Text().fontSize(20).textAlign(TextAlign.Start)
}.margin({ top: 10, bottom: 10 })
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('确认')
.onClick(() => {
this.controller.close()
this.confirm()
}).backgroundColor('#0fa983').fontColor(Color.Black)
Button('取消')
.onClick(() => {
this.controller.close()
this.cancel()
}).backgroundColor('#0fa983').fontColor(Color.Red)
}.margin({ bottom: 10 })
}
}
}
\ No newline at end of file
...@@ -103,7 +103,7 @@ export const generalInitList: UniListItem[] = [ ...@@ -103,7 +103,7 @@ export const generalInitList: UniListItem[] = [
showExtraIcon: true, showExtraIcon: true,
showArrow: true, showArrow: true,
//extraIcon: '', //extraIcon: '',
targetValue: '', targetValue: '网络传输',
description: '数据传输方式' description: '数据传输方式'
}, },
{ {
...@@ -111,7 +111,7 @@ export const generalInitList: UniListItem[] = [ ...@@ -111,7 +111,7 @@ export const generalInitList: UniListItem[] = [
showExtraIcon: true, showExtraIcon: true,
showArrow: true, showArrow: true,
//extraIcon: '', //extraIcon: '',
targetValue: '', targetValue: '自动5S重连',
description: '模式连接方式' description: '模式连接方式'
}, },
{ {
...@@ -119,7 +119,7 @@ export const generalInitList: UniListItem[] = [ ...@@ -119,7 +119,7 @@ export const generalInitList: UniListItem[] = [
showExtraIcon: true, showExtraIcon: true,
showArrow: true, showArrow: true,
//extraIcon: '', //extraIcon: '',
targetValue: '', targetValue: '自动推送',
description: '模式推送方式' description: '模式推送方式'
}, },
] ]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论