• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { ChatBox } from '../appsampled/data/ChatBox';
16
17@Component
18export default struct ChatComponent {
19  private item: ChatBox | undefined = undefined;
20
21  build() {
22    Row() {
23      if (!this.item?.isSend) {
24        Image($r('app.media.app_icon'))
25          .width(50)
26          .height(50)
27          .objectFit(ImageFit.Contain)
28          .borderRadius(25)
29          .margin({ left: 10, right: 10 })
30      }
31      Column() {
32        Text(this.item?.message)
33          .maxLines(5)
34          .padding(10)
35          .fontSize(18)
36          .fontColor($r('app.color.COLOR_FFFFFF'))
37          .fontFamily($r('app.string.Font_family_regular'))
38          .borderRadius(14)
39          .alignSelf(this.item?.isSend ? ItemAlign.End : ItemAlign.Start)
40          .backgroundColor(this.item?.isSend ? $r('app.color.COLOR_3DA0F1') : $r('app.color.COLOR_393939'))
41      }
42      .width('85%')
43
44      if (this.item?.isSend) {
45        Image($r('app.media.app_icon'))
46          .width(50)
47          .height(50)
48          .objectFit(ImageFit.Contain)
49          .borderRadius(25)
50          .margin({ left: 10, right: 10 })
51      }
52    }
53    .width('100%')
54    .height(40)
55  }
56}
57