|
@@ -5,6 +5,7 @@ import DcCore
|
|
public class QuotePreview: DraftPreview {
|
|
public class QuotePreview: DraftPreview {
|
|
|
|
|
|
public weak var delegate: DraftPreviewDelegate?
|
|
public weak var delegate: DraftPreviewDelegate?
|
|
|
|
+ private var compactView = false
|
|
|
|
|
|
lazy var quoteView: QuoteView = {
|
|
lazy var quoteView: QuoteView = {
|
|
let view = QuoteView()
|
|
let view = QuoteView()
|
|
@@ -27,7 +28,8 @@ public class QuotePreview: DraftPreview {
|
|
override public func configure(draft: DraftModel) {
|
|
override public func configure(draft: DraftModel) {
|
|
if let quoteText = draft.quoteText {
|
|
if let quoteText = draft.quoteText {
|
|
quoteView.quote.text = quoteText
|
|
quoteView.quote.text = quoteText
|
|
- quoteView.quote.numberOfLines = draft.draftAttachment != nil ? 1 : 3
|
|
|
|
|
|
+ compactView = draft.draftAttachment != nil
|
|
|
|
+ calculateQuoteHeight(compactView: compactView)
|
|
if let quoteMessage = draft.quoteMessage {
|
|
if let quoteMessage = draft.quoteMessage {
|
|
let contact = quoteMessage.fromContact
|
|
let contact = quoteMessage.fromContact
|
|
quoteView.senderTitle.text = contact.displayName
|
|
quoteView.senderTitle.text = contact.displayName
|
|
@@ -41,4 +43,21 @@ public class QuotePreview: DraftPreview {
|
|
isHidden = true
|
|
isHidden = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func calculateQuoteHeight(compactView: Bool) {
|
|
|
|
+ let vertical = traitCollection.verticalSizeClass == .regular
|
|
|
|
+ if vertical {
|
|
|
|
+ quoteView.quote.numberOfLines = compactView ? 1 : 3
|
|
|
|
+ } else {
|
|
|
|
+ quoteView.quote.numberOfLines = 1
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
|
|
+ super.traitCollectionDidChange(previousTraitCollection)
|
|
|
|
+ if (self.traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass)
|
|
|
|
+ || (self.traitCollection.horizontalSizeClass != previousTraitCollection?.horizontalSizeClass) {
|
|
|
|
+ calculateQuoteHeight(compactView: compactView)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|