WIP: fix original message rendering issues
This commit is contained in:
parent
f4b17c0f06
commit
3e0a4dec20
|
@ -19,6 +19,7 @@ struct MessageInfoView: View {
|
|||
var isMessageFailed: Bool {
|
||||
return [.failed, .failedToSync].contains(messageViewModel.state)
|
||||
}
|
||||
var snapshot: UIView?
|
||||
|
||||
var dismiss: (() -> Void)?
|
||||
|
||||
|
@ -37,33 +38,39 @@ struct MessageInfoView: View {
|
|||
spacing: 10
|
||||
) {
|
||||
// Message bubble snapshot
|
||||
if let body: String = messageViewModel.body, !body.isEmpty {
|
||||
let (bubbleBackgroundColor, bubbleTextColor): (ThemeValue, ThemeValue) = (
|
||||
messageViewModel.variant == .standardIncoming ||
|
||||
messageViewModel.variant == .standardIncomingDeleted
|
||||
) ?
|
||||
(.messageBubble_incomingBackground, .messageBubble_incomingText) :
|
||||
(.messageBubble_outgoingBackground, .messageBubble_outgoingText)
|
||||
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: Self.cornerRadius)
|
||||
.fill(themeColor: bubbleBackgroundColor)
|
||||
|
||||
Text(body)
|
||||
.foregroundColor(themeColor: bubbleTextColor)
|
||||
.padding(.vertical, Values.smallSpacing)
|
||||
.padding(.horizontal, Values.mediumSpacing)
|
||||
ZStack {
|
||||
if let snapshot = self.snapshot {
|
||||
UIView_SwiftUI(view: snapshot)
|
||||
} else {
|
||||
if let body: String = messageViewModel.body, !body.isEmpty {
|
||||
let (bubbleBackgroundColor, bubbleTextColor): (ThemeValue, ThemeValue) = (
|
||||
messageViewModel.variant == .standardIncoming ||
|
||||
messageViewModel.variant == .standardIncomingDeleted
|
||||
) ?
|
||||
(.messageBubble_incomingBackground, .messageBubble_incomingText) :
|
||||
(.messageBubble_outgoingBackground, .messageBubble_outgoingText)
|
||||
|
||||
RoundedRectangle(cornerRadius: Self.cornerRadius)
|
||||
.fill(themeColor: bubbleBackgroundColor)
|
||||
|
||||
Text(body)
|
||||
.foregroundColor(themeColor: bubbleTextColor)
|
||||
.padding(.vertical, Values.smallSpacing)
|
||||
.padding(.horizontal, Values.mediumSpacing)
|
||||
|
||||
}
|
||||
}
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
maxHeight: .infinity,
|
||||
alignment: .topLeading
|
||||
)
|
||||
.fixedSize(horizontal: true, vertical: true)
|
||||
.padding(.top, Values.smallSpacing)
|
||||
.padding(.bottom, Values.verySmallSpacing)
|
||||
.padding(.horizontal, Values.largeSpacing)
|
||||
}
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
maxHeight: .infinity,
|
||||
alignment: .topLeading
|
||||
)
|
||||
.fixedSize(horizontal: true, vertical: true)
|
||||
.padding(.top, Values.smallSpacing)
|
||||
.padding(.bottom, Values.verySmallSpacing)
|
||||
.padding(.horizontal, Values.largeSpacing)
|
||||
|
||||
|
||||
if isMessageFailed {
|
||||
let (image, statusText, tintColor) = messageViewModel.state.statusIconInfo(
|
||||
|
|
|
@ -35,3 +35,21 @@ extension UIViewController {
|
|||
self.present(toPresent, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
public struct UIView_SwiftUI: UIViewRepresentable {
|
||||
public typealias UIViewType = UIView
|
||||
|
||||
private let view: UIView
|
||||
|
||||
public init(view: UIView) {
|
||||
self.view = view
|
||||
}
|
||||
|
||||
public func makeUIView(context: Context) -> UIView {
|
||||
return self.view
|
||||
}
|
||||
|
||||
public func updateUIView(_ uiView: UIView, context: Context) {
|
||||
uiView.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue