mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-28 01:56:25 +00:00
744c451927
* ios: add context menu to messages * ios: UI for replies with quotes * fix: scrolling crashing in chat * ios: UI for message replies with quotes * android: UI for message replies * android: messages with quotes * android: update imports * android: refactor ChatItemView * remove comments
50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
//
|
|
// QuotedItemView.swift
|
|
// SimpleX
|
|
//
|
|
// Created by Evgeny on 13/03/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct QuotedItemView: View {
|
|
@Environment(\.colorScheme) var colorScheme
|
|
@Binding var quotedItem: ChatItem?
|
|
|
|
var body: some View {
|
|
if let qi = quotedItem {
|
|
HStack {
|
|
quoteText(qi).lineLimit(3)
|
|
Spacer()
|
|
Button {
|
|
withAnimation { quotedItem = nil }
|
|
} label: {
|
|
Image(systemName: "multiply")
|
|
}
|
|
}
|
|
.padding(12)
|
|
.frame(maxWidth: .infinity)
|
|
.background(chatItemFrameColor(qi, colorScheme))
|
|
.padding(.top, 8)
|
|
} else {
|
|
EmptyView()
|
|
}
|
|
}
|
|
|
|
func quoteText(_ qi: ChatItem) -> some View {
|
|
if let s = qi.memberDisplayName {
|
|
return (Text(s).fontWeight(.medium) + Text(": \(qi.content.text)"))
|
|
} else {
|
|
return Text(qi.content.text)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct QuotedItemView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
@State var quotedItem: ChatItem? = ChatItem.getSample(1, .directSnd, .now, "hello")
|
|
return QuotedItemView(quotedItem: $quotedItem)
|
|
}
|
|
}
|