ref |> 新增普通升级和强制升级对话框
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
4 changed files
with
104 additions
and
14 deletions
| @@ -7,6 +7,7 @@ import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeChe | @@ -7,6 +7,7 @@ import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeChe | ||
| 7 | import router from '@ohos.router'; | 7 | import router from '@ohos.router'; |
| 8 | import { promptAction } from '@kit.ArkUI'; | 8 | import { promptAction } from '@kit.ArkUI'; |
| 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" | 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" |
| 10 | +import { ProcessUtils } from 'wdRouter/Index'; | ||
| 10 | 11 | ||
| 11 | const TAG = 'MainPage'; | 12 | const TAG = 'MainPage'; |
| 12 | 13 | ||
| @@ -66,8 +67,8 @@ struct MainPage { | @@ -66,8 +67,8 @@ struct MainPage { | ||
| 66 | Logger.info(TAG, 'onPageShow'); | 67 | Logger.info(TAG, 'onPageShow'); |
| 67 | this.pageShow = Math.random() | 68 | this.pageShow = Math.random() |
| 68 | 69 | ||
| 69 | - // TODO: 升级检查,暂时不开放 | ||
| 70 | - // this.upgradeCheck() | 70 | + // 升级检查 |
| 71 | + this.upgradeCheck() | ||
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | upgradeCheck() { | 74 | upgradeCheck() { |
| @@ -77,8 +78,19 @@ struct MainPage { | @@ -77,8 +78,19 @@ struct MainPage { | ||
| 77 | 78 | ||
| 78 | this.upgradeDialogController = new CustomDialogController({ | 79 | this.upgradeDialogController = new CustomDialogController({ |
| 79 | builder: UpgradeTipDialog({ | 80 | builder: UpgradeTipDialog({ |
| 80 | - tipContent:data | ||
| 81 | - }) | 81 | + tipContent:data, |
| 82 | + confirm: () => { | ||
| 83 | + ProcessUtils.jumpExternalWebPage(data.downloadUrl); | ||
| 84 | + } | ||
| 85 | + }), | ||
| 86 | + autoCancel: false, | ||
| 87 | + alignment: DialogAlignment.Center, | ||
| 88 | + customStyle: true, | ||
| 89 | + offset: { | ||
| 90 | + dx: 0, | ||
| 91 | + dy: 20 | ||
| 92 | + }, | ||
| 93 | + backgroundColor: "#50000000", | ||
| 82 | }) | 94 | }) |
| 83 | this.upgradeDialogController?.open() | 95 | this.upgradeDialogController?.open() |
| 84 | } | 96 | } |
| 1 | -import { UpgradeTipContent } from 'wdKit/Index' | 1 | +import { DeviceUtil, DisplayUtils, UpgradeTipContent } from 'wdKit/Index' |
| 2 | 2 | ||
| 3 | @Preview | 3 | @Preview |
| 4 | @CustomDialog | 4 | @CustomDialog |
| @@ -8,27 +8,105 @@ export struct UpgradeTipDialog { | @@ -8,27 +8,105 @@ export struct UpgradeTipDialog { | ||
| 8 | confirm?: () => void | 8 | confirm?: () => void |
| 9 | controller: CustomDialogController | 9 | controller: CustomDialogController |
| 10 | 10 | ||
| 11 | + maxHeight: number = 0 | ||
| 12 | + maxWidth: number = 0 | ||
| 13 | + scroller: Scroller = new Scroller(); | ||
| 14 | + aboutToAppear(): void { | ||
| 15 | + this.maxHeight = DisplayUtils.getDeviceHeight() * 0.6 | ||
| 16 | + this.maxWidth = DisplayUtils.getDeviceWidth() * 0.76 | ||
| 17 | + | ||
| 18 | + // this.tipContent.content = "1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电1、啊啊啊啊啊啊\n2、啊啊啊啊啊\n4、阿斯兰减肥的垃圾发电" | ||
| 19 | + // this.tipContent.forceUpgrade = false | ||
| 20 | + } | ||
| 21 | + | ||
| 11 | build() { | 22 | build() { |
| 12 | Column() { | 23 | Column() { |
| 13 | - Text(this.tipContent.content).fontSize(20).margin({ top: 10, bottom: 10 }) | ||
| 14 | - Flex({ justifyContent: FlexAlign.SpaceAround }) { | ||
| 15 | - Button('cancel') | 24 | + |
| 25 | + Image($r("app.media.wd_upgrade_rocket")) | ||
| 26 | + .objectFit(ImageFit.Fill) | ||
| 27 | + .width(this.maxWidth).height(147) | ||
| 28 | + | ||
| 29 | + this.CenterContainer() | ||
| 30 | + | ||
| 31 | + // 关闭按钮 | ||
| 32 | + Row() { | ||
| 33 | + Image($r("app.media.wd_upgrade_close")) | ||
| 34 | + .width(32).height(32) | ||
| 35 | + .margin({top: 24}) | ||
| 16 | .onClick(() => { | 36 | .onClick(() => { |
| 17 | this.controller.close() | 37 | this.controller.close() |
| 18 | if (this.cancel) { | 38 | if (this.cancel) { |
| 19 | this.cancel() | 39 | this.cancel() |
| 20 | } | 40 | } |
| 21 | - }).backgroundColor(0xffffff).fontColor(Color.Black) | ||
| 22 | - Button('立即升级') | 41 | + }) |
| 42 | + }.justifyContent(FlexAlign.SpaceBetween) | ||
| 43 | + .visibility(this.tipContent.forceUpgrade ? Visibility.Hidden: Visibility.Visible) | ||
| 44 | + } | ||
| 45 | + .height(this.maxHeight) | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Builder CenterContainer() { | ||
| 49 | + Column() { | ||
| 50 | + Text(`V${this.tipContent.newVersion}版本更新说明`) | ||
| 51 | + .fontColor("#222222") | ||
| 52 | + .fontSize(18) | ||
| 53 | + .textAlign(TextAlign.Center) | ||
| 54 | + | ||
| 55 | + Scroll(this.scroller) { | ||
| 56 | + Column() { | ||
| 57 | + Row() { | ||
| 58 | + Text(this.tipContent.content) | ||
| 59 | + .fontColor("#000000") | ||
| 60 | + .fontSize(14) | ||
| 61 | + .textAlign(TextAlign.Start) | ||
| 62 | + } | ||
| 63 | + .alignItems(VerticalAlign.Top) | ||
| 64 | + .width("100%") | ||
| 65 | + // .height("100%") // 设置后,无法滚动。TODO:内容较短,高度问题待解决 | ||
| 66 | + } | ||
| 67 | + .padding({left: 24, right: 24}) | ||
| 68 | + } | ||
| 69 | + .width("100%") | ||
| 70 | + .margin({top: 16, bottom: 2}) | ||
| 71 | + // .backgroundColor(Color.Brown) | ||
| 72 | + .layoutWeight(1) | ||
| 73 | + | ||
| 74 | + /// 灰色线 | ||
| 75 | + Row().width("100%").height(1).backgroundColor("#50E6E6E6") | ||
| 76 | + | ||
| 77 | + Button() { | ||
| 78 | + Text("立即升级").fontColor(Color.White) | ||
| 79 | + | ||
| 80 | + }.borderRadius(4) | ||
| 81 | + .buttonStyle(ButtonStyleMode.NORMAL) | ||
| 82 | + .type(ButtonType.Normal) | ||
| 83 | + .backgroundColor("#ED2800") | ||
| 84 | + .width("90%") | ||
| 85 | + .height(40) | ||
| 86 | + .margin({ | ||
| 87 | + top: 12, bottom: 12 | ||
| 88 | + }) | ||
| 23 | .onClick(() => { | 89 | .onClick(() => { |
| 24 | this.controller.close() | 90 | this.controller.close() |
| 25 | if (this.confirm) { | 91 | if (this.confirm) { |
| 26 | this.confirm() | 92 | this.confirm() |
| 27 | } | 93 | } |
| 28 | - }).backgroundColor(0xffffff).fontColor(Color.Red) | ||
| 29 | - }.margin({ bottom: 10 }) | 94 | + }) |
| 95 | + | ||
| 96 | + if (this.tipContent.forceUpgrade) { | ||
| 97 | + Text("温馨提示:本次更新为必要更新,若您选择拒绝,将无法再使用app") | ||
| 98 | + .fontColor("999999") | ||
| 99 | + .fontSize(12) | ||
| 100 | + .fontWeight(400) | ||
| 101 | + .lineHeight(17) | ||
| 102 | + .margin({ | ||
| 103 | + left: 16, right: 16, bottom: 12 | ||
| 104 | + }) | ||
| 30 | } | 105 | } |
| 31 | } | 106 | } |
| 32 | - | ||
| 33 | - | 107 | + .justifyContent(FlexAlign.SpaceBetween) |
| 108 | + .backgroundColor(Color.White) | ||
| 109 | + .width(this.maxWidth) | ||
| 110 | + .layoutWeight(1) | ||
| 111 | + } | ||
| 34 | } | 112 | } |
-
Please register or login to post a comment