ref |> 评论列表换成半模态弹框
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
1 changed file
with
52 additions
and
38 deletions
| 1 | import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index' | 1 | import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index' |
| 2 | -import { PublicDialogManager } from 'wdKit/Index' | 2 | +import { Logger, PublicDialogManager } from 'wdKit/Index' |
| 3 | import { TrackConstants } from 'wdTracking/Index' | 3 | import { TrackConstants } from 'wdTracking/Index' |
| 4 | import { OperRowListView } from '../../view/OperRowListView' | 4 | import { OperRowListView } from '../../view/OperRowListView' |
| 5 | import { publishCommentModel } from '../model/PublishCommentModel' | 5 | import { publishCommentModel } from '../model/PublishCommentModel' |
| 6 | import { CommentComponent } from './CommentComponent' | 6 | import { CommentComponent } from './CommentComponent' |
| 7 | 7 | ||
| 8 | +const TAG = "CommentListDialogView" | ||
| 9 | + | ||
| 8 | /// 评论列表弹框 | 10 | /// 评论列表弹框 |
| 9 | @Component | 11 | @Component |
| 10 | export struct CommentListDialogView { | 12 | export struct CommentListDialogView { |
| 11 | - @Link @Watch('showCommentListChange') showCommentList: boolean | 13 | + @State windowWidth: number = AppStorage.get<number>('windowWidth') || 0 |
| 14 | + @State windowHeight: number = AppStorage.get<number>('windowHeight') || 0 | ||
| 15 | + @Link showCommentList: boolean | ||
| 12 | @Link contentDetailData: ContentDetailDTO // 详情页传 | 16 | @Link contentDetailData: ContentDetailDTO // 详情页传 |
| 13 | @Link pageInfo: PageInfoDTO // 专题页传 | 17 | @Link pageInfo: PageInfoDTO // 专题页传 |
| 14 | @Link publishCommentModel: publishCommentModel | 18 | @Link publishCommentModel: publishCommentModel |
| 19 | + private maxHeight: number = 0 // px | ||
| 15 | onClose?: () => void | 20 | onClose?: () => void |
| 21 | + onHeightDidChange?: Callback<number> | ||
| 16 | 22 | ||
| 17 | - // @Consume pageId: TrackConstants.PageName | ||
| 18 | - // @Consume pageName: TrackConstants.PageName | ||
| 19 | - | ||
| 20 | - private dialogController: CustomDialogController = new CustomDialogController({ | ||
| 21 | - builder: CommentListDialog({ | ||
| 22 | - contentDetailData: this.contentDetailData, | ||
| 23 | - publishCommentModel:this.publishCommentModel, | ||
| 24 | - pageInfo: this.pageInfo, | ||
| 25 | - onClose: this.onClose | ||
| 26 | - }), | ||
| 27 | - autoCancel: true, | ||
| 28 | - cancel: () => { | ||
| 29 | - PublicDialogManager.shareInstance().closeDialog(this.dialogController) | ||
| 30 | - }, | ||
| 31 | - customStyle: true, | ||
| 32 | - alignment: DialogAlignment.Bottom, | ||
| 33 | - }) | ||
| 34 | - | ||
| 35 | - showCommentListChange(val: boolean) { | ||
| 36 | - if (this.showCommentList) { | ||
| 37 | - PublicDialogManager.shareInstance().openDialog(this.dialogController, this.closeAction.bind(this)) | ||
| 38 | - } else { | ||
| 39 | - PublicDialogManager.shareInstance().closeDialog(this.dialogController) | ||
| 40 | - } | 23 | + aboutToAppear(): void { |
| 24 | + this.maxHeight = this.windowHeight - this.windowWidth * 9 / 16 | ||
| 41 | } | 25 | } |
| 42 | 26 | ||
| 43 | - closeAction() { | ||
| 44 | - if (this.onClose) { | ||
| 45 | - this.onClose() | ||
| 46 | - } else { | ||
| 47 | - this.showCommentList = false | 27 | + build() { |
| 28 | + Row() { | ||
| 48 | } | 29 | } |
| 30 | + .height("100%").width("100%") | ||
| 31 | + .bindSheet($$this.showCommentList, | ||
| 32 | + this.commentListDialog(), | ||
| 33 | + { | ||
| 34 | + height: this.maxHeight + 'px', | ||
| 35 | + preferType: SheetType.BOTTOM, | ||
| 36 | + showClose: false, | ||
| 37 | + dragBar: false, | ||
| 38 | + onDisappear: () => { | ||
| 39 | + this.showCommentList = false | ||
| 40 | + if (this.onClose) { this.onClose() } | ||
| 41 | + }, | ||
| 42 | + shouldDismiss:((sheetDismiss: SheetDismiss)=> { | ||
| 43 | + console.log("bind sheet shouldDismiss") | ||
| 44 | + sheetDismiss.dismiss() | ||
| 45 | + }), | ||
| 46 | + onHeightDidChange: (number: number) => { | ||
| 47 | + Logger.debug(TAG, "onHeightDidChange : " + number) | ||
| 48 | + let height = number | ||
| 49 | + if (height > this.maxHeight) { | ||
| 50 | + height = this.maxHeight | ||
| 51 | + } | ||
| 52 | + if (this.onHeightDidChange) { | ||
| 53 | + this.onHeightDidChange(height) | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + }) | ||
| 49 | } | 57 | } |
| 50 | 58 | ||
| 51 | - build() { | 59 | + @Builder commentListDialog() { |
| 60 | + Column() { | ||
| 61 | + CommentListDialog({ | ||
| 62 | + contentDetailData: this.contentDetailData, | ||
| 63 | + publishCommentModel:this.publishCommentModel, | ||
| 64 | + pageInfo: this.pageInfo, | ||
| 65 | + onClose: this.onClose | ||
| 66 | + }) | ||
| 67 | + }.height("100%").width("100%") | ||
| 52 | } | 68 | } |
| 53 | } | 69 | } |
| 54 | 70 | ||
| 55 | -@CustomDialog | 71 | +@Component |
| 56 | struct CommentListDialog { | 72 | struct CommentListDialog { |
| 57 | 73 | ||
| 58 | /// 内部使用 | 74 | /// 内部使用 |
| 59 | @Link publishCommentModel: publishCommentModel | 75 | @Link publishCommentModel: publishCommentModel |
| 60 | @State private operationButtonList: string[] = [] | 76 | @State private operationButtonList: string[] = [] |
| 61 | - controller?: CustomDialogController | ||
| 62 | - @State windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | ||
| 63 | - @State windowHeight: number = AppStorage.get<number>('windowHeight') || 0 | ||
| 64 | 77 | ||
| 65 | /// 外部初始化 | 78 | /// 外部初始化 |
| 66 | @Link contentDetailData: ContentDetailDTO // 详情页传 | 79 | @Link contentDetailData: ContentDetailDTO // 详情页传 |
| @@ -97,6 +110,7 @@ struct CommentListDialog { | @@ -97,6 +110,7 @@ struct CommentListDialog { | ||
| 97 | 110 | ||
| 98 | build() { | 111 | build() { |
| 99 | Column() { | 112 | Column() { |
| 113 | + Row().height(10) | ||
| 100 | this.titleHeaderView() | 114 | this.titleHeaderView() |
| 101 | 115 | ||
| 102 | CommentComponent({ | 116 | CommentComponent({ |
| @@ -117,11 +131,11 @@ struct CommentListDialog { | @@ -117,11 +131,11 @@ struct CommentListDialog { | ||
| 117 | styleType: 1, | 131 | styleType: 1, |
| 118 | inDialog: true, | 132 | inDialog: true, |
| 119 | dialogBeforeJumpOtherPageAction: () => { | 133 | dialogBeforeJumpOtherPageAction: () => { |
| 120 | - PublicDialogManager.shareInstance().closeLastDialog() | 134 | + // PublicDialogManager.shareInstance().closeLastDialog() |
| 121 | } | 135 | } |
| 122 | }) | 136 | }) |
| 123 | } | 137 | } |
| 124 | - .height(this.windowHeight - this.windowWidth * 9 / 16 + 'px') | 138 | + .height("100%").width("100%") |
| 125 | .backgroundColor(Color.White) | 139 | .backgroundColor(Color.White) |
| 126 | } | 140 | } |
| 127 | 141 |
-
Please register or login to post a comment