Showing
4 changed files
with
68 additions
and
41 deletions
| @@ -19,6 +19,9 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一 | @@ -19,6 +19,9 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一 | ||
| 19 | @Preview | 19 | @Preview |
| 20 | @Component | 20 | @Component |
| 21 | export struct CommentComponent { | 21 | export struct CommentComponent { |
| 22 | + private onCloseClick = () => { | ||
| 23 | + } | ||
| 24 | + @Prop showCloseIcon?: boolean = false | ||
| 22 | @State hasMore: boolean = true; | 25 | @State hasMore: boolean = true; |
| 23 | @State currentPage: number = 1; | 26 | @State currentPage: number = 1; |
| 24 | @State isComments: boolean = true | 27 | @State isComments: boolean = true |
| @@ -29,13 +32,12 @@ export struct CommentComponent { | @@ -29,13 +32,12 @@ export struct CommentComponent { | ||
| 29 | historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset | 32 | historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset |
| 30 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); | 33 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); |
| 31 | @State dialogController: CustomDialogController | null = null; | 34 | @State dialogController: CustomDialogController | null = null; |
| 32 | - | ||
| 33 | // @State private browSingModel: commentListModel = new commentListModel() | 35 | // @State private browSingModel: commentListModel = new commentListModel() |
| 34 | 36 | ||
| 35 | // 是否为固定高度模式。true时,里面上拉加载更多生效,外层不能包Scroll。 | 37 | // 是否为固定高度模式。true时,里面上拉加载更多生效,外层不能包Scroll。 |
| 36 | // false时,外层实现加载更多,并通过reachEndIncreament通知开发加载更多,reachEndLoadMoreFinish 通知上层加载更多完成 | 38 | // false时,外层实现加载更多,并通过reachEndIncreament通知开发加载更多,reachEndLoadMoreFinish 通知上层加载更多完成 |
| 37 | fixedHeightMode: boolean = false | 39 | fixedHeightMode: boolean = false |
| 38 | - @Prop @Watch("parentOnReachEnd") reachEndIncreament : number = 0 | 40 | + @Prop @Watch("parentOnReachEnd") reachEndIncreament: number = 0 |
| 39 | reachEndLoadMoreFinish?: () => void | 41 | reachEndLoadMoreFinish?: () => void |
| 40 | 42 | ||
| 41 | // 在自定义组件即将析构销毁时将dialogControlle置空 | 43 | // 在自定义组件即将析构销毁时将dialogControlle置空 |
| @@ -102,6 +104,7 @@ export struct CommentComponent { | @@ -102,6 +104,7 @@ export struct CommentComponent { | ||
| 102 | /*标题:全部评论*/ | 104 | /*标题:全部评论*/ |
| 103 | @Builder | 105 | @Builder |
| 104 | titleHeader() { | 106 | titleHeader() { |
| 107 | + | ||
| 105 | Row() { | 108 | Row() { |
| 106 | Row() { | 109 | Row() { |
| 107 | Image($r('app.media.redLine')) | 110 | Image($r('app.media.redLine')) |
| @@ -112,18 +115,30 @@ export struct CommentComponent { | @@ -112,18 +115,30 @@ export struct CommentComponent { | ||
| 112 | .fontColor($r('app.color.color_222222')) | 115 | .fontColor($r('app.color.color_222222')) |
| 113 | .fontWeight(FontWeight.Medium) | 116 | .fontWeight(FontWeight.Medium) |
| 114 | .margin({ left: 5 }) | 117 | .margin({ left: 5 }) |
| 115 | - | ||
| 116 | } | 118 | } |
| 117 | .margin({ left: 16 }) | 119 | .margin({ left: 16 }) |
| 118 | - .onClick(() => { | ||
| 119 | - // this.allDatas.push(new commentItemModel()) | ||
| 120 | - // this.allDatas.addFirstItem(new commentItemModel()) | ||
| 121 | - // this.allDatas.reloadData(); | ||
| 122 | - }) | ||
| 123 | 120 | ||
| 124 | - }.height(44) | 121 | + Row() { |
| 122 | + Image($r('app.media.close_button')) | ||
| 123 | + .height(16) | ||
| 124 | + .width(3) | ||
| 125 | + .margin({ right: 16 }) | ||
| 126 | + .visibility(this.showCloseIcon ? Visibility.Visible : Visibility.Hidden) | ||
| 127 | + .onClick(() => { | ||
| 128 | + this.onCloseClick() | ||
| 129 | + }) | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + } | ||
| 133 | + .height(44) | ||
| 125 | .width('100%') | 134 | .width('100%') |
| 126 | - .justifyContent(FlexAlign.SpaceBetween); | 135 | + .justifyContent(FlexAlign.SpaceBetween) |
| 136 | + .onClick(() => { | ||
| 137 | + // this.allDatas.push(new commentItemModel()) | ||
| 138 | + // this.allDatas.addFirstItem(new commentItemModel()) | ||
| 139 | + // this.allDatas.reloadData(); | ||
| 140 | + }) | ||
| 141 | + | ||
| 127 | } | 142 | } |
| 128 | 143 | ||
| 129 | /*1级评论作为titleHeader*/ | 144 | /*1级评论作为titleHeader*/ |
| @@ -200,7 +215,7 @@ export struct CommentComponent { | @@ -200,7 +215,7 @@ export struct CommentComponent { | ||
| 200 | } | 215 | } |
| 201 | } | 216 | } |
| 202 | } | 217 | } |
| 203 | - .margin({bottom: 10}) | 218 | + .margin({ bottom: 10 }) |
| 204 | .onReachEnd(() => { | 219 | .onReachEnd(() => { |
| 205 | if (!this.fixedHeightMode) { | 220 | if (!this.fixedHeightMode) { |
| 206 | return | 221 | return |
| @@ -209,7 +224,8 @@ export struct CommentComponent { | @@ -209,7 +224,8 @@ export struct CommentComponent { | ||
| 209 | this.getData() | 224 | this.getData() |
| 210 | } | 225 | } |
| 211 | }) | 226 | }) |
| 212 | - .enableScrollInteraction(this.fixedHeightMode ? true: false) | 227 | + .enableScrollInteraction(this.fixedHeightMode ? true : false) |
| 228 | + | ||
| 213 | // .nestedScroll({ | 229 | // .nestedScroll({ |
| 214 | // scrollForward: NestedScrollMode.PARENT_FIRST, | 230 | // scrollForward: NestedScrollMode.PARENT_FIRST, |
| 215 | // scrollBackward: NestedScrollMode.SELF_FIRST | 231 | // scrollBackward: NestedScrollMode.SELF_FIRST |
| @@ -46,11 +46,11 @@ const TAG = 'OperRowListView'; | @@ -46,11 +46,11 @@ const TAG = 'OperRowListView'; | ||
| 46 | @Preview | 46 | @Preview |
| 47 | @Component | 47 | @Component |
| 48 | export struct OperRowListView { | 48 | export struct OperRowListView { |
| 49 | - private onBack: () => void = () => { | 49 | + private onBack = () => { |
| 50 | } | 50 | } |
| 51 | - private onCommentFocus: () => void = () => { | 51 | + private onCommentFocus = () => { |
| 52 | } | 52 | } |
| 53 | - private onCommentIconClick: () => void = () => { | 53 | + private onCommentIconClick = () => { |
| 54 | } | 54 | } |
| 55 | @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 | 55 | @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 |
| 56 | /** | 56 | /** |
| @@ -64,7 +64,12 @@ export struct OperRowListView { | @@ -64,7 +64,12 @@ export struct OperRowListView { | ||
| 64 | * 7:图集详情页 | 64 | * 7:图集详情页 |
| 65 | */ | 65 | */ |
| 66 | @Prop componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口 | 66 | @Prop componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口 |
| 67 | - @Prop pageComponentType?: number = -1 //1:视频详情页 2:竖屏直播页 3:图集 4: 横屏直播页 | 67 | + /** |
| 68 | + * 用于区分页面类型,在哪个页面嵌套就传相应的值 | ||
| 69 | + * 1:视频详情页 2:竖屏直播页 3:图集 4:横屏直播页 | ||
| 70 | + */ | ||
| 71 | + @Prop pageComponentType?: number = -1 | ||
| 72 | + @Prop showBackIcon?: boolean = true | ||
| 68 | @State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 | 73 | @State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 |
| 69 | @Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件 | 74 | @Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件 |
| 70 | @State needLike: boolean = true | 75 | @State needLike: boolean = true |
| @@ -131,12 +136,11 @@ export struct OperRowListView { | @@ -131,12 +136,11 @@ export struct OperRowListView { | ||
| 131 | 136 | ||
| 132 | build() { | 137 | build() { |
| 133 | // 视频详情页 | 138 | // 视频详情页 |
| 134 | - | ||
| 135 | Column() { | 139 | Column() { |
| 136 | Image($r('app.media.ic_news_detail_division')) | 140 | Image($r('app.media.ic_news_detail_division')) |
| 137 | .width('100%') | 141 | .width('100%') |
| 138 | .height($r('app.float.margin_1')) | 142 | .height($r('app.float.margin_1')) |
| 139 | - .margin({bottom: -2}) | 143 | + .margin({ bottom: -2 }) |
| 140 | 144 | ||
| 141 | Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { | 145 | Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { |
| 142 | // AudioDialog() | 146 | // AudioDialog() |
| @@ -149,14 +153,16 @@ export struct OperRowListView { | @@ -149,14 +153,16 @@ export struct OperRowListView { | ||
| 149 | .aspectRatio(1) | 153 | .aspectRatio(1) |
| 150 | .interpolation(ImageInterpolation.High) | 154 | .interpolation(ImageInterpolation.High) |
| 151 | } | 155 | } |
| 156 | + .width(48) | ||
| 152 | .hoverEffect(HoverEffect.Scale) | 157 | .hoverEffect(HoverEffect.Scale) |
| 158 | + .visibility(this.showBackIcon ? Visibility.Visible : Visibility.None) | ||
| 153 | .onClick(() => { | 159 | .onClick(() => { |
| 154 | if (this.onBack) { | 160 | if (this.onBack) { |
| 155 | this.onBack() | 161 | this.onBack() |
| 156 | } | 162 | } |
| 157 | router.back(); | 163 | router.back(); |
| 158 | }) | 164 | }) |
| 159 | - .width(48) | 165 | + |
| 160 | 166 | ||
| 161 | if (this.contentDetailData?.newsId) { | 167 | if (this.contentDetailData?.newsId) { |
| 162 | ForEach(this.operationButtonList, (item: string, index: number) => { | 168 | ForEach(this.operationButtonList, (item: string, index: number) => { |
| @@ -4,12 +4,19 @@ import { | @@ -4,12 +4,19 @@ import { | ||
| 4 | publishCommentModel | 4 | publishCommentModel |
| 5 | } from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel' | 5 | } from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel' |
| 6 | import { CommentComponent } from '../../../../../wdComponent/src/main/ets/components/comment/view/CommentComponent' | 6 | import { CommentComponent } from '../../../../../wdComponent/src/main/ets/components/comment/view/CommentComponent' |
| 7 | - | ||
| 8 | import { OperRowListView } from '../../../../../wdComponent/src/main/ets/components/view/OperRowListView' | 7 | import { OperRowListView } from '../../../../../wdComponent/src/main/ets/components/view/OperRowListView' |
| 9 | 8 | ||
| 10 | @Component | 9 | @Component |
| 11 | -export struct CommentComponentPage { | ||
| 12 | - scroller: Scroller = new Scroller() | 10 | +export struct CommentDialogView { |
| 11 | + private dialogController: CustomDialogController = new CustomDialogController({ | ||
| 12 | + builder: this.commentBuilder(), | ||
| 13 | + autoCancel: true, | ||
| 14 | + customStyle: true, | ||
| 15 | + alignment: DialogAlignment.Bottom, | ||
| 16 | + height: (this.windowHeight - this.windowWidth / 16 / 9) + 'px' as Dimension | ||
| 17 | + }) | ||
| 18 | + @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | ||
| 19 | + @Provide windowHeight: number = AppStorage.get<number>('windowHeight') || 0 | ||
| 13 | @Consume contentDetailData: ContentDetailDTO | 20 | @Consume contentDetailData: ContentDetailDTO |
| 14 | @Consume showCommentList: boolean | 21 | @Consume showCommentList: boolean |
| 15 | @State publishCommentModel: publishCommentModel = new publishCommentModel() | 22 | @State publishCommentModel: publishCommentModel = new publishCommentModel() |
| @@ -24,31 +31,25 @@ export struct CommentComponentPage { | @@ -24,31 +31,25 @@ export struct CommentComponentPage { | ||
| 24 | this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle || '') | 31 | this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle || '') |
| 25 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') | 32 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') |
| 26 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') | 33 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') |
| 34 | + | ||
| 35 | + this.dialogController.open() | ||
| 27 | } | 36 | } |
| 28 | 37 | ||
| 29 | - build() { | 38 | + @Builder |
| 39 | + commentBuilder() { | ||
| 30 | Column() { | 40 | Column() { |
| 31 | - Scroll(this.scroller) { | ||
| 32 | - Stack() { | ||
| 33 | - CommentComponent({ | ||
| 34 | - publishCommentModel: this.publishCommentModel | ||
| 35 | - }) | ||
| 36 | - Image($r("app.media.ic_close_black")) | ||
| 37 | - .width(20) | ||
| 38 | - .height(20) | ||
| 39 | - .onClick(() => { | ||
| 40 | - this.showCommentList = false | ||
| 41 | - }) | ||
| 42 | - .margin({ top: 10, right: 30 }) | ||
| 43 | - .position({ x: '100%' }) | ||
| 44 | - .markAnchor({ x: '100%' }) | ||
| 45 | - | 41 | + CommentComponent({ |
| 42 | + publishCommentModel: this.publishCommentModel, | ||
| 43 | + showCloseIcon: true, | ||
| 44 | + onCloseClick: () => { | ||
| 45 | + this.dialogController.close() | ||
| 46 | + this.showCommentList = false | ||
| 46 | } | 47 | } |
| 47 | - } | ||
| 48 | - .layoutWeight(1) | ||
| 49 | - | 48 | + }) |
| 49 | + .layoutWeight(1) | ||
| 50 | OperRowListView({ | 50 | OperRowListView({ |
| 51 | componentType: 1, | 51 | componentType: 1, |
| 52 | + showBackIcon: false, | ||
| 52 | operationButtonList: ['comment', 'like', 'collect', 'share'], | 53 | operationButtonList: ['comment', 'like', 'collect', 'share'], |
| 53 | contentDetailData: this.contentDetailData, | 54 | contentDetailData: this.contentDetailData, |
| 54 | publishCommentModel: this.publishCommentModel, | 55 | publishCommentModel: this.publishCommentModel, |
| @@ -62,6 +63,10 @@ export struct CommentComponentPage { | @@ -62,6 +63,10 @@ export struct CommentComponentPage { | ||
| 62 | .zIndex(1000) | 63 | .zIndex(1000) |
| 63 | .backgroundColor(Color.White) | 64 | .backgroundColor(Color.White) |
| 64 | .height('60%') | 65 | .height('60%') |
| 66 | + } | ||
| 67 | + | ||
| 68 | + build() { | ||
| 69 | + | ||
| 65 | 70 | ||
| 66 | } | 71 | } |
| 67 | } | 72 | } |
-
Please register or login to post a comment