xugenyuan

ref |> 评论列表换成半模态弹框

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index'
import { PublicDialogManager } from 'wdKit/Index'
import { Logger, PublicDialogManager } from 'wdKit/Index'
import { TrackConstants } from 'wdTracking/Index'
import { OperRowListView } from '../../view/OperRowListView'
import { publishCommentModel } from '../model/PublishCommentModel'
import { CommentComponent } from './CommentComponent'
const TAG = "CommentListDialogView"
/// 评论列表弹框
@Component
export struct CommentListDialogView {
@Link @Watch('showCommentListChange') showCommentList: boolean
@State windowWidth: number = AppStorage.get<number>('windowWidth') || 0
@State windowHeight: number = AppStorage.get<number>('windowHeight') || 0
@Link showCommentList: boolean
@Link contentDetailData: ContentDetailDTO // 详情页传
@Link pageInfo: PageInfoDTO // 专题页传
@Link publishCommentModel: publishCommentModel
private maxHeight: number = 0 // px
onClose?: () => void
onHeightDidChange?: Callback<number>
// @Consume pageId: TrackConstants.PageName
// @Consume pageName: TrackConstants.PageName
private dialogController: CustomDialogController = new CustomDialogController({
builder: CommentListDialog({
contentDetailData: this.contentDetailData,
publishCommentModel:this.publishCommentModel,
pageInfo: this.pageInfo,
onClose: this.onClose
}),
autoCancel: true,
cancel: () => {
PublicDialogManager.shareInstance().closeDialog(this.dialogController)
},
customStyle: true,
alignment: DialogAlignment.Bottom,
})
showCommentListChange(val: boolean) {
if (this.showCommentList) {
PublicDialogManager.shareInstance().openDialog(this.dialogController, this.closeAction.bind(this))
} else {
PublicDialogManager.shareInstance().closeDialog(this.dialogController)
}
aboutToAppear(): void {
this.maxHeight = this.windowHeight - this.windowWidth * 9 / 16
}
closeAction() {
if (this.onClose) {
this.onClose()
} else {
this.showCommentList = false
build() {
Row() {
}
.height("100%").width("100%")
.bindSheet($$this.showCommentList,
this.commentListDialog(),
{
height: this.maxHeight + 'px',
preferType: SheetType.BOTTOM,
showClose: false,
dragBar: false,
onDisappear: () => {
this.showCommentList = false
if (this.onClose) { this.onClose() }
},
shouldDismiss:((sheetDismiss: SheetDismiss)=> {
console.log("bind sheet shouldDismiss")
sheetDismiss.dismiss()
}),
onHeightDidChange: (number: number) => {
Logger.debug(TAG, "onHeightDidChange : " + number)
let height = number
if (height > this.maxHeight) {
height = this.maxHeight
}
if (this.onHeightDidChange) {
this.onHeightDidChange(height)
}
}
})
}
build() {
@Builder commentListDialog() {
Column() {
CommentListDialog({
contentDetailData: this.contentDetailData,
publishCommentModel:this.publishCommentModel,
pageInfo: this.pageInfo,
onClose: this.onClose
})
}.height("100%").width("100%")
}
}
@CustomDialog
@Component
struct CommentListDialog {
/// 内部使用
@Link publishCommentModel: publishCommentModel
@State private operationButtonList: string[] = []
controller?: CustomDialogController
@State windowWidth: number = AppStorage.get<number>('windowWidth') || 0
@State windowHeight: number = AppStorage.get<number>('windowHeight') || 0
/// 外部初始化
@Link contentDetailData: ContentDetailDTO // 详情页传
... ... @@ -97,6 +110,7 @@ struct CommentListDialog {
build() {
Column() {
Row().height(10)
this.titleHeaderView()
CommentComponent({
... ... @@ -117,11 +131,11 @@ struct CommentListDialog {
styleType: 1,
inDialog: true,
dialogBeforeJumpOtherPageAction: () => {
PublicDialogManager.shareInstance().closeLastDialog()
// PublicDialogManager.shareInstance().closeLastDialog()
}
})
}
.height(this.windowHeight - this.windowWidth * 9 / 16 + 'px')
.height("100%").width("100%")
.backgroundColor(Color.White)
}
... ...