wwf
3 天以前 23fa268f56dcd99c8dcd46f50f3ffcaa4cdcbc49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { router } from '@kit.ArkUI'
 
class Message {
  avatar: string | Resource = ''
  content: string = ''
  isMe: boolean = false
}
 
@Entry
@Component
struct MessageDetailsPage {
  @State messageList: Message[] = [
    { avatar: '', content: '请发一下你的简历给我。', isMe: false },
    { avatar: '', content: '这个岗位我十分感兴趣,请看一下我的简历,我觉得我可以胜任这个岗位', isMe: true },
  ]
  @State avatar: string | Resource = ''
  @State name: string = ''
  @State company: string = ''
  @State pageHeight: number = 0
  @State chatHeight: number = 0
  @State inputText: string = ''
 
  aboutToAppear(): void {
    interface Params {
      avatar: string | Resource
      name: string
      company: string
    }
    const params: Params = router.getParams() as Params
    this.name = params.name
    this.company = params.company
    this.avatar = params.avatar
  }
 
  build() {
    Flex({ direction: FlexDirection.Column }) {
      Row() {
        Image($r('app.media.left_icon'))
          .width(20)
          .height(20)
          .onClick(() => {
            router.back()
          })
        Column() {
          Text(this.name)
            .fontSize(16)
            .fontWeight(700)
          Text(this.company)
            .fontSize(12)
            .fontColor('#666666')
            .margin({ top: 4 })
        }
        Row()
      }
      .width('100%')
      .padding(10)
      .justifyContent(FlexAlign.SpaceBetween)
      .backgroundColor('#fff')
      .expandSafeArea()
 
      Column() {
        List({ space: 20, initialIndex: 0 }){
          ForEach(this.messageList, (item: Message) => {
            ListItem() {
              if (item.isMe) {
                Row({ space: 10 }) {
                  Text(item.content)
                    .fontSize(14)
                    .fontColor(Color.White)
                    .fontWeight(500)
                    .backgroundColor('#1761f4')
                    .padding(10)
                    .borderRadius({ topLeft: 12, topRight: 12, bottomLeft: 12 })
                    .constraintSize({ maxWidth: 250 })
                  Image($r('app.media.me_icon'))
                    .width(32)
                    .height(32)
                }
                .width('100%')
                .justifyContent(FlexAlign.End)
                .alignItems(VerticalAlign.Bottom)
              } else {
                Row({ space: 10 }) {
                  Image(this.avatar)
                    .width(32)
                    .height(32)
                  Text(item.content)
                    .fontSize(14)
                    .fontColor(Color.Black)
                    .fontWeight(500)
                    .backgroundColor('#FFF')
                    .padding(10)
                    .borderRadius({ topLeft: 12, topRight: 12, bottomRight: 12 })
                    .constraintSize({ maxWidth: 250 })
                }
                .width('100%')
                .alignItems(VerticalAlign.Bottom)
                .justifyContent(FlexAlign.Start)
              }
            }
          })
        }
        .listDirection(Axis.Vertical) // 排列方向
        .scrollBar(BarState.Off)
        .friction(0.6)
        .edgeEffect(EdgeEffect.Spring)
        .width('100%')
      }
      .layoutWeight(1)
      .padding(16)
      .width('100%')
      .expandSafeArea()
 
      Row({ space: 8 }) {
        Image($r('app.media.audio_icon'))
          .width(24)
          .height(24)
        TextInput({ text: $$this.inputText })
          .layoutWeight(1)
          .placeholderColor('#999999')
          .backgroundColor('#f3f7fe')
        Image($r('app.media.expression_icon'))
          .width(24)
          .height(24)
        if (this.inputText) {
          Button('发送')
            .type(ButtonType.Normal)
            .borderRadius(6)
            .onClick(() => {
              this.messageList.push({
                avatar: '', content: this.inputText, isMe: true
              })
              this.inputText = ''
            })
        } else {
          Image($r('app.media.add_icon'))
            .width(24)
            .height(24)
        }
      }
      .backgroundColor('#FFF')
      .width('100%')
      .height(60)
      .padding(10)
      .alignItems(VerticalAlign.Center)
    }
    .width('100%')
    .height('100%')
    .backgroundColor('#f5f5f7')
  }
}