|
|
@@ -0,0 +1,104 @@
|
|
|
+import { BasicType } from '../../models'
|
|
|
+import { yTToast } from '../../utils/YTToast'
|
|
|
+import { YTButton } from '../generalComp/YTButton'
|
|
|
+
|
|
|
+
|
|
|
+@Builder
|
|
|
+export function AlertToastBuilder(item: BasicType<undefined>) {
|
|
|
+ AlertToastComp({
|
|
|
+ message: item.message,
|
|
|
+ onConfirm: item.onConfirm,
|
|
|
+ onCancel: item.onCancel,
|
|
|
+ messageAlignSelf: item.messageAlignSelf,
|
|
|
+ confirmMessage: item.confirmMessage,
|
|
|
+ cancelMessage: item.cancelMessage,
|
|
|
+ isShowClose: item.isShowClose
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+@Component
|
|
|
+struct AlertToastComp {
|
|
|
+ message: string = ''
|
|
|
+ confirmMessage: string = '保存并退出'
|
|
|
+ cancelMessage: string = '取消并退出'
|
|
|
+ isShowClose: boolean = true
|
|
|
+ onConfirm: (index: string) => void = (index: string) => {
|
|
|
+ }
|
|
|
+ onCancel: () => void = () => {
|
|
|
+ }
|
|
|
+ messageAlignSelf: ItemAlign = ItemAlign.Center
|
|
|
+
|
|
|
+ build() {
|
|
|
+
|
|
|
+ Column({ space: 24 }) {
|
|
|
+ Stack() {
|
|
|
+ Row() {
|
|
|
+ Text(this.message)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(400)
|
|
|
+ .fontColor('#FF353C46')
|
|
|
+ .alignSelf(this.messageAlignSelf)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ Image($r('app.media.icon_cancel_blue'))
|
|
|
+ .width(16)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ .onClick(() => {
|
|
|
+ yTToast.hide()
|
|
|
+ })
|
|
|
+ .visibility(this.isShowClose ? Visibility.Visible : Visibility.Hidden)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ YTButton({
|
|
|
+ btContent: this.confirmMessage,
|
|
|
+ btWidth: 104,
|
|
|
+ btHeight: 42,
|
|
|
+ btFontSize: 16,
|
|
|
+ bgc: '#FF6E645E',
|
|
|
+ btPadding: 0,
|
|
|
+ btFontColor: '#FFF',
|
|
|
+ click: () => {
|
|
|
+ // yTToast.hide()
|
|
|
+ // yTRouter.routerBack()
|
|
|
+
|
|
|
+ this.onConfirm?.('0')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ YTButton({
|
|
|
+ btContent: this.cancelMessage,
|
|
|
+ btWidth: 104,
|
|
|
+ btHeight: 42,
|
|
|
+ btFontSize: 16,
|
|
|
+ bgc: '#FFF5F5F7',
|
|
|
+ btPadding: 0,
|
|
|
+ btFontColor: '#FF353C46',
|
|
|
+ click: () => {
|
|
|
+ // console.log('你好')
|
|
|
+ this.onCancel?.()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ }
|
|
|
+ .width(343)
|
|
|
+ // .height(138)
|
|
|
+ .padding({
|
|
|
+ left: 48,
|
|
|
+ right: 48,
|
|
|
+ top: 28,
|
|
|
+ bottom: 20
|
|
|
+ })
|
|
|
+ .backgroundColor('#FFF')
|
|
|
+ .borderRadius(16)
|
|
|
+
|
|
|
+ // .margin({ left: 16, right: 16 })
|
|
|
+ }
|
|
|
+}
|