ios: group chat preview (#235)

This commit is contained in:
Efim Poberezkin 2022-01-30 00:35:20 +04:00 committed by GitHub
parent 8425be0612
commit 7e2f365c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 15 deletions

View File

@ -45,13 +45,13 @@ struct ChatPreview: Identifiable, Codable {
enum ChatInfo: Identifiable, Codable {
case direct(contact: Contact)
// case group()
case group(groupInfo: GroupInfo)
var displayName: String {
get {
switch self {
case let .direct(contact): return "@\(contact.localDisplayName)"
// case let .group(groupInfo, _): return "#\(groupInfo.localDisplayName)"
case let .group(groupInfo): return "#\(groupInfo.localDisplayName)"
}
}
}
@ -60,7 +60,7 @@ enum ChatInfo: Identifiable, Codable {
get {
switch self {
case let .direct(contact): return "@\(contact.contactId)"
// case let .group(contact): return group.id
case let .group(groupInfo): return "#\(groupInfo.groupId)"
}
}
}
@ -69,7 +69,7 @@ enum ChatInfo: Identifiable, Codable {
get {
switch self {
case .direct(_): return "direct"
// case let .group(_): return "group"
case .group(_): return "group"
}
}
}
@ -78,7 +78,7 @@ enum ChatInfo: Identifiable, Codable {
get {
switch self {
case let .direct(contact): return contact.contactId
// case let .group(contact): return group.id
case let .group(groupInfo): return groupInfo.groupId
}
}
}

View File

@ -18,16 +18,30 @@ struct ChatPreviewView: View {
struct ChatPreviewView_Previews: PreviewProvider {
static var previews: some View {
ChatPreviewView(chatPreview: ChatPreview(
chatInfo: .direct(contact: Contact(
contactId: 123,
localDisplayName: "ep",
profile: Profile(
displayName: "ep",
fullName: "Ep"
),
viaGroup: nil
Group{
ChatPreviewView(chatPreview: ChatPreview(
chatInfo: .direct(contact: Contact(
contactId: 123,
localDisplayName: "ep",
profile: Profile(
displayName: "ep",
fullName: "Ep"
),
viaGroup: nil
))
))
))
ChatPreviewView(chatPreview: ChatPreview(
chatInfo: .group(groupInfo: GroupInfo(
groupId: 123,
localDisplayName: "team",
groupProfile: GroupProfile(
displayName: "team",
fullName: "My Team"
)
))
))
}
.previewLayout(.fixed(width: 300, height: 70))
}
}