Files
simplex-chat/apps/ios/Shared/Views/Chat/ChatItem/CIEventView.swift

51 lines
1.2 KiB
Swift
Raw Normal View History

2022-07-21 17:01:13 +04:00
//
// CIEventView.swift
2022-07-21 17:01:13 +04:00
// SimpleX (iOS)
//
// Created by JRoberts on 20.07.2022.
// Copyright © 2022 SimpleX Chat. All rights reserved.
//
import SwiftUI
import SimpleXChat
struct CIEventView: View {
2022-07-21 17:01:13 +04:00
var chatItem: ChatItem
var body: some View {
HStack(alignment: .bottom, spacing: 0) {
if let member = chatItem.memberDisplayName {
Text(member)
.font(.caption)
.foregroundColor(.secondary)
.fontWeight(.light)
+ Text(" ")
+ chatEventText(chatItem)
2022-07-21 17:01:13 +04:00
} else {
chatEventText(chatItem)
2022-07-21 17:01:13 +04:00
}
}
.padding(.leading, 6)
.padding(.bottom, 6)
.textSelection(.disabled)
}
}
2022-07-21 17:01:13 +04:00
func chatEventText(_ ci: ChatItem) -> Text {
Text(ci.content.text)
.font(.caption)
.foregroundColor(.secondary)
.fontWeight(.light)
+ Text(" ")
+ ci.timestampText
.font(.caption)
.foregroundColor(Color.secondary)
.fontWeight(.light)
2022-07-21 17:01:13 +04:00
}
struct CIEventView_Previews: PreviewProvider {
2022-07-21 17:01:13 +04:00
static var previews: some View {
CIEventView(chatItem: ChatItem.getGroupEventSample())
2022-07-21 17:01:13 +04:00
}
}