large emojis, full contact names, contact createdAt, process profile updates, etc. (#268)

This commit is contained in:
Evgeny Poberezkin
2022-02-04 22:13:52 +00:00
committed by GitHub
parent 214ecf605b
commit e424e9328b
13 changed files with 270 additions and 92 deletions

View File

@@ -12,36 +12,14 @@ private var dateFormatter: DateFormatter?
struct ChatItemView: View {
var chatItem: ChatItem
var width: CGFloat
var body: some View {
let sent = chatItem.chatDir.sent
return VStack {
Group {
Text(chatItem.content.text)
.padding(.top, 8)
.padding(.horizontal, 12)
.frame(minWidth: 200, maxWidth: 300, alignment: .leading)
.foregroundColor(sent ? .white : .primary)
.textSelection(.enabled)
Text(getDateFormatter().string(from: chatItem.meta.itemTs))
.font(.subheadline)
.foregroundColor(sent ? .white : .secondary)
.padding(.bottom, 8)
.padding(.horizontal, 12)
.frame(minWidth: 200, maxWidth: 300, alignment: .trailing)
}
if (isShortEmoji(chatItem.content.text)) {
EmojiItemView(chatItem: chatItem)
} else {
TextItemView(chatItem: chatItem, width: width)
}
.background(sent ? .blue : Color(uiColor: .tertiarySystemGroupedBackground))
.cornerRadius(10)
.padding(.horizontal)
.frame(
minWidth: 200,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity,
alignment: sent ? .trailing : .leading
)
}
}
@@ -56,9 +34,12 @@ func getDateFormatter() -> DateFormatter {
struct ChatItemView_Previews: PreviewProvider {
static var previews: some View {
Group{
ChatItemView(chatItem: chatItemSample(1, .directSnd, Date.now, "hello"))
ChatItemView(chatItem: chatItemSample(2, .directRcv, Date.now, "hello there too"))
ChatItemView(chatItem: chatItemSample(1, .directSnd, .now, "hello"), width: 360)
ChatItemView(chatItem: chatItemSample(2, .directRcv, .now, "hello there too"), width: 360)
ChatItemView(chatItem: chatItemSample(1, .directSnd, .now, "🙂"), width: 360)
ChatItemView(chatItem: chatItemSample(2, .directRcv, .now, "👍👍👍"), width: 360)
ChatItemView(chatItem: chatItemSample(2, .directRcv, .now, "👍👍👍👍"), width: 360)
}
.previewLayout(.fixed(width: 300, height: 70))
.previewLayout(.fixed(width: 360, height: 70))
}
}