聊天气泡背景图

This commit is contained in:
xiaoxiao 2025-08-12 13:30:54 +08:00
parent 5212bfee2c
commit f5a31e1ffa
8 changed files with 68 additions and 39 deletions

View File

@ -1173,6 +1173,7 @@ export struct ChatP2PPage {
.expandSafeArea([SafeAreaType.KEYBOARD]) .expandSafeArea([SafeAreaType.KEYBOARD])
.zIndex(1) .zIndex(1)
} }
.backgroundColor('#f4f4f4')
// } // }

View File

@ -196,28 +196,37 @@ export struct SenderMessageComponent {
} }
} }
} }
Row() {
messageContent({ messageContent({
message: this.message, message: this.message,
onMessageClick: this.onMessageClick, onMessageClick: this.onMessageClick,
chatInfo: this.chatUserInfo chatInfo: this.chatUserInfo
}) })
.backgroundColor($r('app.color.color_chat_send_message_bg')) .backgroundImage(this.message.getMessageType() !== 100?$r('app.media.im_my_message_back_icon'):$r('app.media.im_my_message_white_back_icon'))
.borderRadius(6) .backgroundImageSize({ width: '100%', height: '100%' })
// .backgroundImage($r('app.media.green_bg')) .backgroundImageResizable({
// .backgroundImageSize({ width: '100%', height: '100%' }) // 背景覆盖整个组件区域 slice:{
// .backgroundImageResizable({ top:24,right:36,bottom:24,left:24
// slice: { top: 100, left: 50, bottom: 2, right: 60 } // 圆角区域不拉伸 }
// })
// })
.onClick((event: ClickEvent) => { .onClick((event: ClickEvent) => {
if (this.showRadio) { if (this.showRadio) {
this.radioOn = !this.radioOn this.radioOn = !this.radioOn
} }
this.onMessageClick?.onItemClick?.(event, this.message) this.onMessageClick?.onItemClick?.(event, this.message)
}) })
.margin({ top: 4, right: 6 }) .margin({top:2})
.flexShrink(1) .flexShrink(1)
.id("msgContainer") .id("msgContainer")
Image(this.message.getMessageType() !== 100?$r('app.media.im_my_message_jiantou_icon'):$r('app.media.im_my_message_white_jiantou_icon'))
.width(7)
.height(14)
.alignSelf(ItemAlign.Start)
.margin({top:17,left:-1})
.visibility(this.message.getMessageType() !== 1?Visibility.Visible:Visibility.Hidden)
}
} }
.justifyContent(FlexAlign.End) .justifyContent(FlexAlign.End)
.alignItems(VerticalAlign.Bottom) .alignItems(VerticalAlign.Bottom)
@ -261,13 +270,15 @@ export struct SenderMessageComponent {
}) })
} }
.width('100%') .width('100%')
.backgroundColor(this.message.isPinMsg ? $r('app.color.color_chat_pin_bg') : // .backgroundColor(this.message.isPinMsg ? $r('app.color.color_chat_pin_bg') :
$r('app.color.color_chat_page_bg')) // $r('app.color.color_chat_page_bg'))
.backgroundColor('#f4f4f4')
.justifyContent(FlexAlign.End) .justifyContent(FlexAlign.End)
.alignItems(VerticalAlign.Top) .alignItems(VerticalAlign.Top)
} }
} }
.width('100%').margin({ top: 6, bottom: 6 }) .width('100%').margin({ top: 6, bottom: 6 })
.backgroundColor('#f4f4f4')
} }
} }
@ -351,15 +362,29 @@ export struct ReceiveMessageComponent {
} }
Column() { Column() {
Row() {
Image($r('app.media.im_from_message_white_jiantou_icon'))
.width(7)
.height(14)
.alignSelf(ItemAlign.Start)
.margin({top:10})
.visibility(this.message.getMessageType() !== 1?Visibility.Visible:Visibility.Hidden)
messageContent({ messageContent({
message: this.message, message: this.message,
onMessageClick: this.onMessageClick, onMessageClick: this.onMessageClick,
chatInfo: this.chatUserInfo chatInfo: this.chatUserInfo
}) })
.backgroundColor($r('app.color.color_chat_receive_message_bg')) .backgroundImage($r('app.media.im_my_message_white_back_icon'))
.borderRadius(6) .backgroundImageSize({ width: '100%', height: '100%' })
.backgroundImageResizable({
slice:{
top:24,right:36,bottom:24,left:24
}
})
.id("msgContainer") .id("msgContainer")
.alignRules(this.AlignLeft) .alignRules(this.AlignLeft)
.margin({top:-2})
.onClick((event: ClickEvent) => { .onClick((event: ClickEvent) => {
if (this.showRadio) { if (this.showRadio) {
this.radioOn = !this.radioOn this.radioOn = !this.radioOn
@ -367,6 +392,7 @@ export struct ReceiveMessageComponent {
this.onMessageClick?.onItemClick?.(event, this.message) this.onMessageClick?.onItemClick?.(event, this.message)
}) })
} }
}
.width('100%') .width('100%')
//.height(this.message?.getMessageHeight(this.getUIContext())) //.height(this.message?.getMessageHeight(this.getUIContext()))
.alignItems(HorizontalAlign.Start) .alignItems(HorizontalAlign.Start)
@ -390,11 +416,13 @@ export struct ReceiveMessageComponent {
} }
.width('100%') .width('100%')
.alignItems(VerticalAlign.Top) .alignItems(VerticalAlign.Top)
.backgroundColor(this.message?.isPinMsg ? $r('app.color.color_chat_pin_bg') : // .backgroundColor(this.message?.isPinMsg ? $r('app.color.color_chat_pin_bg') :
$r('app.color.color_chat_page_bg')) // $r('app.color.color_chat_page_bg'))
.backgroundColor('#f4f4f4')
.id('itemContainer') .id('itemContainer')
} }
}.width('100%').padding({ top: 6, bottom: 6 }) }.width('100%').padding({ top: 6, bottom: 6 })
.backgroundColor('#f4f4f4')
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B