Showing
2 changed files
with
96 additions
and
29 deletions
| @@ -7,7 +7,7 @@ import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel | @@ -7,7 +7,7 @@ import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel | ||
| 7 | import { PaperTitleComponent } from './PaperTitleComponent'; | 7 | import { PaperTitleComponent } from './PaperTitleComponent'; |
| 8 | import { SingleColumn999Component } from './SingleColumn999Component'; | 8 | import { SingleColumn999Component } from './SingleColumn999Component'; |
| 9 | import { topicInfoView } from './topicInfoView'; | 9 | import { topicInfoView } from './topicInfoView'; |
| 10 | -import { WDPlayerController } from 'wdPlayer'; | 10 | +import { PlayerConstants, WDPlayerController } from 'wdPlayer'; |
| 11 | 11 | ||
| 12 | const TAG = 'MorningEveningPaperComponent'; | 12 | const TAG = 'MorningEveningPaperComponent'; |
| 13 | 13 | ||
| @@ -40,16 +40,33 @@ export struct MorningEveningPaperComponent { | @@ -40,16 +40,33 @@ export struct MorningEveningPaperComponent { | ||
| 40 | @Provide title: string = '' | 40 | @Provide title: string = '' |
| 41 | @Provide subTitle: string = '' | 41 | @Provide subTitle: string = '' |
| 42 | @Provide isAudioPlaying: boolean = false | 42 | @Provide isAudioPlaying: boolean = false |
| 43 | + @Provide status: number = PlayerConstants.STATUS_START; | ||
| 43 | private playerController: WDPlayerController = new WDPlayerController(); | 44 | private playerController: WDPlayerController = new WDPlayerController(); |
| 44 | - private xComponentController: XComponentController = new XComponentController(); | ||
| 45 | simpleAudioDialog: CustomDialogController = new CustomDialogController({ | 45 | simpleAudioDialog: CustomDialogController = new CustomDialogController({ |
| 46 | - builder: PaperReaderSimpleDialog(), | 46 | + builder: PaperReaderSimpleDialog({ |
| 47 | + cancel: this.onCancel, | ||
| 48 | + confirm: this.onConfirm | ||
| 49 | + }), | ||
| 47 | autoCancel: false, | 50 | autoCancel: false, |
| 48 | customStyle: true, | 51 | customStyle: true, |
| 49 | alignment: DialogAlignment.CenterStart, | 52 | alignment: DialogAlignment.CenterStart, |
| 50 | - offset: { dx: 12, dy: -150 } | 53 | + offset: { dx: 12, dy: -150 }, |
| 54 | + | ||
| 51 | }) | 55 | }) |
| 52 | 56 | ||
| 57 | + onCancel() { | ||
| 58 | + Logger.info(TAG, "cj2024 onCancel = ") | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + onConfirm() { | ||
| 62 | + Logger.info(TAG, "cj2024 onConfirm = ") | ||
| 63 | + // if (this.playerController != undefined) { | ||
| 64 | + // | ||
| 65 | + // } | ||
| 66 | + this.status = PlayerConstants.STATUS_PAUSE; | ||
| 67 | + this.playerController?.pause() | ||
| 68 | + } | ||
| 69 | + | ||
| 53 | async aboutToAppear() { | 70 | async aboutToAppear() { |
| 54 | console.info(TAG, `aboutToAppear`) | 71 | console.info(TAG, `aboutToAppear`) |
| 55 | 72 | ||
| @@ -84,6 +101,11 @@ export struct MorningEveningPaperComponent { | @@ -84,6 +101,11 @@ export struct MorningEveningPaperComponent { | ||
| 84 | } | 101 | } |
| 85 | } | 102 | } |
| 86 | 103 | ||
| 104 | + onPageHide() { | ||
| 105 | + this.status = PlayerConstants.STATUS_PAUSE; | ||
| 106 | + this.playerController?.pause(); | ||
| 107 | + } | ||
| 108 | + | ||
| 87 | build() { | 109 | build() { |
| 88 | Stack({ alignContent: Alignment.Top }) { | 110 | Stack({ alignContent: Alignment.Top }) { |
| 89 | List() { | 111 | List() { |
| 1 | /** | 1 | /** |
| 2 | * 简易音频对话框 | 2 | * 简易音频对话框 |
| 3 | * */ | 3 | * */ |
| 4 | + | ||
| 4 | @CustomDialog | 5 | @CustomDialog |
| 5 | export struct PaperReaderSimpleDialog { | 6 | export struct PaperReaderSimpleDialog { |
| 6 | - private controllerSimple?: CustomDialogController; | 7 | + cancel: () => void = () => { |
| 8 | + } | ||
| 9 | + confirm: () => void = () => { | ||
| 10 | + } | ||
| 11 | + paperReaderDialog: CustomDialogController = new CustomDialogController({ | ||
| 12 | + builder: PaperReaderDialog({ | ||
| 13 | + onCancel: this.cancel, | ||
| 14 | + onConfirm: this.confirm | ||
| 15 | + }), | ||
| 16 | + autoCancel: false, | ||
| 17 | + customStyle: true, | ||
| 18 | + alignment: DialogAlignment.CenterStart, | ||
| 19 | + offset: { dx: 12, dy: -150 } | ||
| 20 | + }) | ||
| 21 | + controllerSimple?: CustomDialogController // // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在所有controller的后面 | ||
| 7 | 22 | ||
| 8 | build() { | 23 | build() { |
| 9 | Row() { | 24 | Row() { |
| @@ -19,6 +34,18 @@ export struct PaperReaderSimpleDialog { | @@ -19,6 +34,18 @@ export struct PaperReaderSimpleDialog { | ||
| 19 | .onClick(() => { | 34 | .onClick(() => { |
| 20 | if (this.controllerSimple) { | 35 | if (this.controllerSimple) { |
| 21 | this.controllerSimple.close() | 36 | this.controllerSimple.close() |
| 37 | + this.paperReaderDialog.open() | ||
| 38 | + if (this.paperReaderDialog) { | ||
| 39 | + setTimeout(() => { | ||
| 40 | + console.log('PaperReaderSimpleDialog delay 1s'); | ||
| 41 | + if (this.paperReaderDialog != undefined) { | ||
| 42 | + this.paperReaderDialog.close() | ||
| 43 | + } | ||
| 44 | + if (this.controllerSimple != undefined) { | ||
| 45 | + this.controllerSimple.open() | ||
| 46 | + } | ||
| 47 | + }, 100000); | ||
| 48 | + } | ||
| 22 | } | 49 | } |
| 23 | 50 | ||
| 24 | }) | 51 | }) |
| @@ -32,13 +59,17 @@ export struct PaperReaderSimpleDialog { | @@ -32,13 +59,17 @@ export struct PaperReaderSimpleDialog { | ||
| 32 | @CustomDialog | 59 | @CustomDialog |
| 33 | export struct PaperReaderDialog { | 60 | export struct PaperReaderDialog { |
| 34 | controllerDetail?: CustomDialogController | 61 | controllerDetail?: CustomDialogController |
| 62 | + onCancel: () => void = () => { | ||
| 63 | + } | ||
| 64 | + onConfirm: () => void = () => { | ||
| 65 | + } | ||
| 35 | 66 | ||
| 36 | build() { | 67 | build() { |
| 37 | - Stack() { | 68 | + Stack({ alignContent: Alignment.End }) { |
| 38 | Column() { //标题 时间 进度条 | 69 | Column() { //标题 时间 进度条 |
| 39 | Marquee({ | 70 | Marquee({ |
| 40 | start: true, | 71 | start: true, |
| 41 | - step: 50, | 72 | + step: 5, |
| 42 | loop: Number.POSITIVE_INFINITY, | 73 | loop: Number.POSITIVE_INFINITY, |
| 43 | fromStart: true, | 74 | fromStart: true, |
| 44 | src: "Running Marquee starts rolling" | 75 | src: "Running Marquee starts rolling" |
| @@ -47,7 +78,8 @@ export struct PaperReaderDialog { | @@ -47,7 +78,8 @@ export struct PaperReaderDialog { | ||
| 47 | .height(20) | 78 | .height(20) |
| 48 | .fontColor($r("app.color.color_222222")) | 79 | .fontColor($r("app.color.color_222222")) |
| 49 | .fontSize(14) | 80 | .fontSize(14) |
| 50 | - .margin({ top: 10 }) | 81 | + .margin({ top: 10, left: 10 }) |
| 82 | + .alignSelf(ItemAlign.Start) | ||
| 51 | .onStart(() => { | 83 | .onStart(() => { |
| 52 | console.info('Marquee animation complete onStart') | 84 | console.info('Marquee animation complete onStart') |
| 53 | }) | 85 | }) |
| @@ -62,45 +94,58 @@ export struct PaperReaderDialog { | @@ -62,45 +94,58 @@ export struct PaperReaderDialog { | ||
| 62 | Text("00:00") | 94 | Text("00:00") |
| 63 | .fontSize($r('app.float.font_size_12')) | 95 | .fontSize($r('app.float.font_size_12')) |
| 64 | .fontColor($r('app.color.color_999999')) | 96 | .fontColor($r('app.color.color_999999')) |
| 65 | - .width("49%") | ||
| 66 | .height("100%") | 97 | .height("100%") |
| 98 | + .alignSelf(ItemAlign.Start) | ||
| 67 | Text("/00:00") | 99 | Text("/00:00") |
| 68 | .fontSize($r('app.float.font_size_12')) | 100 | .fontSize($r('app.float.font_size_12')) |
| 69 | .fontColor($r('app.color.color_999999')) | 101 | .fontColor($r('app.color.color_999999')) |
| 70 | - .width("51%") | ||
| 71 | .height("100%") | 102 | .height("100%") |
| 103 | + .alignSelf(ItemAlign.Start) | ||
| 72 | 104 | ||
| 73 | } | 105 | } |
| 74 | .width("100%") | 106 | .width("100%") |
| 75 | .height(16) | 107 | .height(16) |
| 76 | - .margin({ top: 4 }) | 108 | + .margin({ top: 4, left: 10 }) |
| 109 | + | ||
| 110 | + Progress({ value: 50, total: 100, type: ProgressType.Capsule }) | ||
| 111 | + .color($r('app.color.color_ED2800')) | ||
| 112 | + .backgroundColor($r('app.color.white')) | ||
| 113 | + .width("100%") | ||
| 114 | + .height(3) | ||
| 115 | + .margin({ top: 7 }) | ||
| 77 | } | 116 | } |
| 78 | .width("100%") | 117 | .width("100%") |
| 79 | .height("100%") | 118 | .height("100%") |
| 119 | + .justifyContent(FlexAlign.Start) | ||
| 80 | 120 | ||
| 81 | - Progress({ value: 0, total: 100, type: ProgressType.Linear }) | ||
| 82 | - .color($r('app.color.color_ED2800')) | ||
| 83 | - .width("100%") | ||
| 84 | - .height(3) | 121 | + Row() { |
| 122 | + Image($r("app.media.icon_audio_pause")) | ||
| 123 | + .objectFit(ImageFit.Contain) | ||
| 124 | + .width(24) | ||
| 125 | + .height(24) | ||
| 126 | + .margin({ right: 12 }) | ||
| 127 | + .onClick(() => { | ||
| 128 | + if (this.controllerDetail) { | ||
| 129 | + this.onConfirm() | ||
| 130 | + } | ||
| 131 | + }) | ||
| 85 | 132 | ||
| 86 | - Image($r("app.media.icon_audio_pause")) | ||
| 87 | - .objectFit(ImageFit.Auto) | ||
| 88 | - .align(Alignment.End) | ||
| 89 | - .margin({ right: 12 }) | 133 | + Image($r("app.media.icon_audio_close")) |
| 134 | + .objectFit(ImageFit.Contain) | ||
| 135 | + .width(24) | ||
| 136 | + .height(24) | ||
| 137 | + .onClick(() => { | ||
| 138 | + if (this.controllerDetail) { | ||
| 139 | + this.controllerDetail.close() | ||
| 140 | + } | ||
| 141 | + }) | ||
| 142 | + }.width(80) | ||
| 143 | + .height(60) | ||
| 90 | 144 | ||
| 91 | - Image($r("app.media.icon_audio_close")) | ||
| 92 | - .objectFit(ImageFit.Auto) | ||
| 93 | - .align(Alignment.End) | ||
| 94 | - .margin({ right: 48 }) | ||
| 95 | - .onClick(() => { | ||
| 96 | - if (this.controllerDetail) { | ||
| 97 | - this.controllerDetail.close() | ||
| 98 | - } | ||
| 99 | - }) | ||
| 100 | } | 145 | } |
| 101 | .width("65%") | 146 | .width("65%") |
| 102 | .height(60) | 147 | .height(60) |
| 103 | .backgroundColor(Color.White) | 148 | .backgroundColor(Color.White) |
| 104 | - .borderRadius(5) | 149 | + .borderRadius(2) |
| 105 | } | 150 | } |
| 106 | } | 151 | } |
-
Please register or login to post a comment