From cd03274a0146252454560ca569d8c185f77d8c38 Mon Sep 17 00:00:00 2001 From: "@feng-yu4279" Date: Tue, 27 May 2025 20:10:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=20(=E6=A0=87=E8=AF=86):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20CommentReply=20=E4=BB=93=E5=BA=93=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/view/CommentKeyboard.ets | 39 +++++++++++++------ .../src/main/ets/view/CommentSendDialog.ets | 1 + features/home/src/main/ets/view/Home.ets | 1 + .../src/main/ets/view/NavigationDialog.ets | 1 + 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/features/home/src/main/ets/view/CommentKeyboard.ets b/features/home/src/main/ets/view/CommentKeyboard.ets index 2b15b5d..e74c52c 100644 --- a/features/home/src/main/ets/view/CommentKeyboard.ets +++ b/features/home/src/main/ets/view/CommentKeyboard.ets @@ -34,6 +34,7 @@ interface ImageInfo { } // [Start rich_editor_span] +// features/home/src/main/ets/view/CommentKeyboard.ets export interface RichEditorSpan { value?: string resourceValue?: ResourceStr @@ -51,6 +52,8 @@ export struct CommentKeyboard { { id: '1', avatar: $r('app.media.friend_2'), nickname: this.getResourceString($r('app.string.friend_nickname_2')) }, ]; // [StartExclude comment_keyboard] + // [Start private] + // features/home/src/main/ets/view/CommentKeyboard.ets private builderSpans: RichEditorSpan[] = []; @State keyboardHeight: number = 0; @State isEmojiKeyboardVisible: boolean = false; @@ -81,14 +84,14 @@ export struct CommentKeyboard { this.keyboardHeight = this.getUIContext().px2vp(height); return; } - // [StartExclude close_keyboard] + // [StartExclude comment_keyboard1] // if close keyboard, don't set keyboardHeight, avoid EmojiKeyboard height is 0 if (!this.isEmojiKeyboardVisible) { // handle keyboard close button click console.info('click soft keyboard close button'); this.navDialogPageInfos.pop(); } - // [EndExclude close_keyboard] + // [EndExclude comment_keyboard1] }); } @@ -110,6 +113,7 @@ export struct CommentKeyboard { } // [Start comment_keyboard2] + // features/home/src/main/ets/view/CommentKeyboard.ets onAtButtonClick: (event?: ClickEvent) => void = event => { const controller = this.richEditorController; this.isAtFriendListVisible = true; @@ -126,18 +130,20 @@ export struct CommentKeyboard { } // [Start comment_keyboard3] + // features/home/src/main/ets/view/CommentKeyboard.ets onEmojiClick: (icon: Resource) => void = icon => { this.richEditorController.addImageSpan(icon, { offset: this.richEditorController.getCaretOffset(), imageStyle: { size: [20, 20] } }); - // [StartExclude onEmoji_click] + // [StartExclude comment_keyboard3] this.isAtFriendListVisible = false; - // [EndExclude onEmoji_click] + // [EndExclude comment_keyboard3] } // [End comment_keyboard3] // [Start comment_keyboard4] + // features/home/src/main/ets/view/CommentKeyboard.ets onSendComment: () => void = () => { let builderSpanIndex = 0; let richEditorSpan: RichEditorSpan; @@ -155,18 +161,21 @@ export struct CommentKeyboard { } richEditorSpans.push(richEditorSpan); }); - // [StartExclude rich_editor_content] + // [StartExclude comment_keyboard4] console.info('richEditorContent', JSON.stringify(richEditorSpans)); this.navDialogPageInfos.pop(); this.navDialogPageInfos.pushPathByName('CommentSendDialog', richEditorSpans); - // [EndExclude rich_editor_content] + // [EndExclude comment_keyboard4] } // [End comment_keyboard4] // [Start comment_keyboard5] // features/home/src/main/ets/view/CommentKeyboard.ets // [Start comment_keyboard6] + // [Start onatfriend_click] + // features/home/src/main/ets/view/CommentKeyboard.ets onAtFriendClick: (friend: User) => void = friend => { + // [StartExclude onatfriend_click] const controller = this.richEditorController; const offset = controller.getCaretOffset(); const range: RichEditorRange = { start: offset - 1, end: offset }; @@ -177,15 +186,18 @@ export struct CommentKeyboard { controller.addBuilderSpan(() => this.AtSpan(friend.nickname), { offset: controller.getCaretOffset() }); + // [EndExclude onatfriend_click] this.setBuilderSpans(controller, friend); } - // [End comment_keyboard6] + // [End onatfriend_click] @Builder AtSpan(nickname: string) { Text(`@${nickname}`) .fontColor(0xFF133667) } + // [End comment_keyboard6] + // [End comment_keyboard5] // [EndExclude comment_keyboard] @@ -206,9 +218,11 @@ export struct CommentKeyboard { return this.isBuilderSpan(span) ? count + 1 : count; }, 0); } + // [End private] // [End comment_keyboard7] // [Start comment_keyboard8] + // features/home/src/main/ets/view/CommentKeyboard.ets aboutToDelete: (value: RichEditorDeleteValue) => boolean = value => { const controller = this.richEditorController; const span = value.richEditorDeleteSpans[0]; @@ -280,9 +294,10 @@ export struct CommentKeyboard { ToolBar() { Column() { // [Start comment_keyboard9] + // features/home/src/main/ets/view/CommentKeyboard.ets RichEditor({ controller: this.richEditorController }) .customKeyboard(this.isEmojiKeyboardVisible ? this.EmojiKeyboard() : undefined) - // [StartExclude constraint_size] + // [StartExclude comment_keyboard9] .constraintSize({ maxHeight: 120 }) .placeholder($r('app.string.comment_button_text')) .defaultFocus(true) @@ -291,7 +306,7 @@ export struct CommentKeyboard { .onDeleteComplete(this.onDeleteComplete) .onIMEInputComplete(this.onIMEInputComplete) .aboutToIMEInput(this.aboutToIMEInput) - // [EndExclude constraint_size] + // [EndExclude comment_keyboard9] // [End comment_keyboard9] Row({ space: 15 }) { ForEach(this.getOperateButtons(), (operateButton: OperateButton) => { @@ -310,6 +325,7 @@ export struct CommentKeyboard { } // [Start comment_keyboard10] + // features/home/src/main/ets/view/CommentKeyboard.ets @Builder EmojiKeyboard() { Grid() { @@ -323,12 +339,12 @@ export struct CommentKeyboard { } .width('100%') .height(this.keyboardHeight + this.frequentEmojiListHeight) - // [StartExclude columns_template] + // [StartExclude comment_keyboard10] .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr') .rowsGap(15) .padding(10) .scrollBar(BarState.Off) - // [EndExclude columns_template] + // [EndExclude comment_keyboard10] } // [End comment_keyboard10] @@ -377,6 +393,7 @@ export struct CommentKeyboard { } // [Start comment_keyboard11] + // features/home/src/main/ets/view/CommentKeyboard.ets build() { NavigationDialog({ maskBackgroundColor: 'rgba(0, 0, 0, 0.1)' }) { Column() { diff --git a/features/home/src/main/ets/view/CommentSendDialog.ets b/features/home/src/main/ets/view/CommentSendDialog.ets index ecbe9c7..513026a 100644 --- a/features/home/src/main/ets/view/CommentSendDialog.ets +++ b/features/home/src/main/ets/view/CommentSendDialog.ets @@ -30,6 +30,7 @@ export struct CommentSendDialog { alignContent: Alignment.Center }) { // [Start comment_send_dialog] + // features/home/src/main/ets/view/CommentSendDialog.ets Column() { Text($r('app.string.send_title')) .margin({ bottom: 20 }) diff --git a/features/home/src/main/ets/view/Home.ets b/features/home/src/main/ets/view/Home.ets index 2c7a5c6..9996feb 100644 --- a/features/home/src/main/ets/view/Home.ets +++ b/features/home/src/main/ets/view/Home.ets @@ -85,6 +85,7 @@ export struct Home { this.selectedTabIndex = index } // [Start home] + // features/home/src/main/ets/view/Home.ets build() { Navigation(this.navDialogPageInfos) { // [StartExclude home] diff --git a/features/home/src/main/ets/view/NavigationDialog.ets b/features/home/src/main/ets/view/NavigationDialog.ets index 1d5502f..919f020 100644 --- a/features/home/src/main/ets/view/NavigationDialog.ets +++ b/features/home/src/main/ets/view/NavigationDialog.ets @@ -13,6 +13,7 @@ * limitations under the License. */ // [Start navigation_dialog] +// features/home/src/main/ets/view/NavigationDialog.ets @Component export struct NavigationDialog { @Consume navDialogPageInfos: NavPathStack; -- Gitee