YTNaviDiaLog.ets 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { BasicType, yTRouter } from 'basic'
  2. import { YTDiaLogComp } from 'basic/src/main/ets/components/generalComp/YTDiaLogComp'
  3. import { DiaLogParam, YTDiaLogModel } from 'basic/src/main/ets/models/YTDiaLogModel'
  4. @ComponentV2
  5. struct YTNaviDiaLog {
  6. @Local param: DiaLogParam = {} as DiaLogParam
  7. @Local isPop: boolean = false
  8. @Local routerAns: string = ''
  9. _onBackPress = () => {
  10. yTRouter.pop(this.routerAns, false)
  11. }
  12. onBack(){
  13. this.isPop = !this.isPop
  14. }
  15. aboutToAppear(): void {
  16. this.param = yTRouter.getNaviDiaLogParam()
  17. }
  18. build() {
  19. YTDiaLogComp({ Align: YTDiaLogModel.Bottom, _onPop: this._onBackPress, isBack: this.isPop }){
  20. this.BottomMenu()
  21. }
  22. }
  23. // 底部菜单
  24. @Builder BottomMenu() {
  25. Column(){
  26. ForEach(this.param.params, (item: BasicType, index) => {
  27. Row(){
  28. Text(item.text)
  29. .fontSize(16)
  30. .textAlign(TextAlign.Center)
  31. }
  32. .width("100%")
  33. .alignItems(VerticalAlign.Center)
  34. .justifyContent(FlexAlign.Center)
  35. .padding({ top: 24, bottom: 24 })
  36. .onClick(() => {
  37. this.routerAns = item.message ?? item.text ?? `${index}`
  38. this.onBack()
  39. })
  40. Divider().width("80%").height(1).backgroundColor('#000000F2')
  41. })
  42. }
  43. .width("100%")
  44. .padding({ bottom: 30 })
  45. .backgroundColor(Color.White)
  46. .justifyContent(FlexAlign.Center)
  47. .alignItems(HorizontalAlign.Center)
  48. .borderRadius({ topLeft: 8, topRight: 8 })
  49. }
  50. }
  51. @Builder
  52. function YTNaviDiaLogBuilder() {
  53. YTNaviDiaLog()
  54. }