Compare commits
2 Commits
406685b399
...
c680b15eeb
Author | SHA1 | Date | |
---|---|---|---|
|
c680b15eeb | ||
|
1668cbfea9 |
|
@ -1,6 +1,20 @@
|
|||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
"signingConfigs": [
|
||||
{
|
||||
"name": "default",
|
||||
"type": "HarmonyOS",
|
||||
"material": {
|
||||
"certpath": "C:\\Users\\wps\\.ohos\\config\\default_himi_ZikZBgBxljB_K_Bxk-D2cAAnn7PtvbqmLsGmCt8Tywc=.cer",
|
||||
"storePassword": "0000001A324907DCD55F55682629687D2AECF782CD5EE7AFB5FD4E1CE3F410EBB601D67AC641B4072B46",
|
||||
"keyAlias": "debugKey",
|
||||
"keyPassword": "0000001A8EDEBEC4585D89D8F1A91107E51ECAE951E2849CB803CBA06C9E49A8A59CCB6CECAF7EA5DADA",
|
||||
"profile": "C:\\Users\\wps\\.ohos\\config\\default_himi_ZikZBgBxljB_K_Bxk-D2cAAnn7PtvbqmLsGmCt8Tywc=.p7b",
|
||||
"signAlg": "SHA256withECDSA",
|
||||
"storeFile": "C:\\Users\\wps\\.ohos\\config\\default_himi_ZikZBgBxljB_K_Bxk-D2cAAnn7PtvbqmLsGmCt8Tywc=.p12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
|
|
35
entry/src/main/cangjie/src/components/chat/ChatList.cj
Normal file
35
entry/src/main/cangjie/src/components/chat/ChatList.cj
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Created on 2024/9/10
|
||||
*/
|
||||
package ohos_app_cangjie_entry.components.chat
|
||||
|
||||
internal import ohos.component.*
|
||||
internal import ohos.state_manage.*
|
||||
internal import ohos.base.*
|
||||
import ohos.state_macro_manage.*
|
||||
|
||||
@Component
|
||||
public class ChatList {
|
||||
let array: Array<String> = Array<String>(20, item: "teststesstasdasdasdadasdasdsaesrfsfdfsfdsf")
|
||||
func build() {
|
||||
Column {
|
||||
List(space: 20, initialIndex: 0) {
|
||||
ForEach(
|
||||
this.array,
|
||||
itemGeneratorFunc: {
|
||||
item: String, index: Int64 => ListItem {
|
||||
ChatMessage(
|
||||
message: item,
|
||||
source: if (index % 2 == 0) {
|
||||
EChatSource.ME
|
||||
} else {
|
||||
EChatSource.YOU
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}.height(100.percent).width(100.percent).padding(top: 5.vp)
|
||||
}
|
||||
}
|
93
entry/src/main/cangjie/src/components/chat/ChatMessage.cj
Normal file
93
entry/src/main/cangjie/src/components/chat/ChatMessage.cj
Normal file
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Created on 2024/9/10
|
||||
*/
|
||||
package ohos_app_cangjie_entry.components.chat
|
||||
|
||||
import std.collection.*
|
||||
import ohos.component.*
|
||||
import ohos.state_macro_manage.*
|
||||
import ohos.state_manage.*
|
||||
import ohos.base.*
|
||||
|
||||
public enum EChatSource {
|
||||
| ME
|
||||
| YOU
|
||||
}
|
||||
|
||||
@Component
|
||||
public class ChatMessage {
|
||||
@Prop
|
||||
var message: String
|
||||
@Prop
|
||||
var source: EChatSource
|
||||
|
||||
@State
|
||||
var radiusMap: HashMap<String, Length> = HashMap<String, Length>()
|
||||
|
||||
protected func aboutToAppear() {
|
||||
this.radiusMap = this.messageRadius()
|
||||
}
|
||||
|
||||
func fontColor() {
|
||||
match (this.source) {
|
||||
case EChatSource.ME => Color.WHITE
|
||||
case EChatSource.YOU => Color.BLACK
|
||||
}
|
||||
}
|
||||
|
||||
func bgColor() {
|
||||
match (this.source) {
|
||||
case EChatSource.YOU => Color.WHITE
|
||||
case EChatSource.ME => Color.BLUE
|
||||
}
|
||||
}
|
||||
|
||||
func orient() {
|
||||
match (this.source) {
|
||||
case EChatSource.YOU => FlexAlign.Start
|
||||
case EChatSource.ME => FlexAlign.End
|
||||
}
|
||||
}
|
||||
|
||||
func messageRadius(): HashMap<String, Length> {
|
||||
match (this.source) {
|
||||
case EChatSource.YOU => HashMap<String, Length>(
|
||||
[
|
||||
("topLeft", 12.vp),
|
||||
("topRight", 12.vp),
|
||||
("bottomLeft", 0.vp),
|
||||
("bottomRight", 12.vp)
|
||||
]
|
||||
)
|
||||
case EChatSource.ME => HashMap<String, Length>(
|
||||
[
|
||||
("topLeft", 12.vp),
|
||||
("topRight", 12.vp),
|
||||
("bottomLeft", 12.vp),
|
||||
("bottomRight", 0.vp)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func build() {
|
||||
Row() {
|
||||
Row() {
|
||||
Text(message)
|
||||
.fontColor(this.fontColor())
|
||||
.backgroundColor(this.bgColor())
|
||||
.padding(top: 8, right: 16,bottom: 8, left: 16)
|
||||
.borderRadius(
|
||||
topLeft: this.radiusMap['topLeft'],
|
||||
topRight: this.radiusMap['topRight'],
|
||||
bottomLeft: this.radiusMap['bottomLeft'],
|
||||
bottomRight: this.radiusMap['bottomRight'],
|
||||
)
|
||||
}
|
||||
.width(60.percent)
|
||||
.justifyContent(this.orient())
|
||||
}
|
||||
.width(100.percent)
|
||||
.justifyContent(this.orient())
|
||||
}
|
||||
}
|
|
@ -9,9 +9,13 @@ import ohos_app_cangjie_entry.pages.*
|
|||
@Entry
|
||||
@Component
|
||||
class MyView {
|
||||
let TAG = "MyView"
|
||||
@State
|
||||
var message: String = "Hello Cangjie"
|
||||
|
||||
protected func aboutToAppear() {
|
||||
}
|
||||
|
||||
func build() {
|
||||
Row {
|
||||
HomePage()
|
||||
|
|
|
@ -7,13 +7,11 @@ internal import ohos.base.*
|
|||
internal import ohos.component.*
|
||||
internal import ohos.state_manage.*
|
||||
import ohos.state_macro_manage.*
|
||||
import ohos_app_cangjie_entry.utils.Logger
|
||||
|
||||
@Component
|
||||
public class HomePage {
|
||||
private let TAG = "HomePage"
|
||||
protected func aboutToAppear() {
|
||||
Logger(TAG).info("aboutToAppear")
|
||||
}
|
||||
func build() {
|
||||
Row()
|
||||
|
|
|
@ -7,13 +7,11 @@ internal import ohos.base.*
|
|||
internal import ohos.component.*
|
||||
internal import ohos.state_manage.*
|
||||
import ohos.state_macro_manage.*
|
||||
import ohos_app_cangjie_entry.utils.Logger
|
||||
|
||||
@Component
|
||||
public class SidePage {
|
||||
private let TAG: String = "SidePage"
|
||||
protected func aboutToAppear() {
|
||||
Logger(this.TAG).info("aboutToAppear")
|
||||
}
|
||||
func build() {
|
||||
Row()
|
||||
|
|
Loading…
Reference in New Issue
Block a user