|
@@ -2,12 +2,8 @@ import UIKit
|
|
|
import InputBarAccessoryView
|
|
|
import DcCore
|
|
|
|
|
|
-public protocol QuotePreviewDelegate: class {
|
|
|
- func onCancel()
|
|
|
-}
|
|
|
+public class DraftPreview: UIView, InputItem {
|
|
|
|
|
|
-public class QuotePreview: UIView, InputItem {
|
|
|
-
|
|
|
public var inputBarAccessoryView: InputBarAccessoryView?
|
|
|
public var parentStackViewPosition: InputStackView.Position?
|
|
|
public func textViewDidChangeAction(with textView: InputTextView) {}
|
|
@@ -15,15 +11,6 @@ public class QuotePreview: UIView, InputItem {
|
|
|
public func keyboardEditingEndsAction() {}
|
|
|
public func keyboardEditingBeginsAction() {}
|
|
|
|
|
|
- public weak var delegate: QuotePreviewDelegate?
|
|
|
-
|
|
|
- lazy var quoteView: QuoteView = {
|
|
|
- let view = QuoteView()
|
|
|
- view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
-
|
|
|
- return view
|
|
|
- }()
|
|
|
-
|
|
|
lazy var cancelButton: UIView = {
|
|
|
let view = UIView()
|
|
|
view.isUserInteractionEnabled = true
|
|
@@ -49,6 +36,12 @@ public class QuotePreview: UIView, InputItem {
|
|
|
return view
|
|
|
}()
|
|
|
|
|
|
+ lazy var mainContentView: UIView = {
|
|
|
+ let view = UIView()
|
|
|
+ view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+
|
|
|
init() {
|
|
|
super.init(frame: .zero)
|
|
|
setupSubviews()
|
|
@@ -58,19 +51,19 @@ public class QuotePreview: UIView, InputItem {
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
}
|
|
|
|
|
|
- private func setupSubviews() {
|
|
|
+ func setupSubviews() {
|
|
|
addSubview(upperBorder)
|
|
|
- addSubview(quoteView)
|
|
|
+ addSubview(mainContentView)
|
|
|
addSubview(cancelButton)
|
|
|
addConstraints([
|
|
|
upperBorder.constraintAlignLeadingTo(self),
|
|
|
upperBorder.constraintAlignTrailingTo(self),
|
|
|
upperBorder.constraintHeightTo(1),
|
|
|
upperBorder.constraintAlignTopTo(self, paddingTop: 4),
|
|
|
- quoteView.constraintAlignTopTo(upperBorder, paddingTop: 4),
|
|
|
- quoteView.constraintAlignLeadingTo(self),
|
|
|
- quoteView.constraintAlignBottomTo(self, paddingBottom: 4),
|
|
|
- quoteView.constraintTrailingToLeadingOf(cancelButton, paddingTrailing: -2),
|
|
|
+ mainContentView.constraintAlignTopTo(upperBorder, paddingTop: 4),
|
|
|
+ mainContentView.constraintAlignLeadingTo(self),
|
|
|
+ mainContentView.constraintAlignBottomTo(self, paddingBottom: 4),
|
|
|
+ mainContentView.constraintTrailingToLeadingOf(cancelButton, paddingTrailing: -2),
|
|
|
cancelButton.constraintAlignTrailingTo(self, paddingTrailing: 14),
|
|
|
cancelButton.constraintWidthTo(36),
|
|
|
cancelButton.constraintHeightTo(36),
|
|
@@ -86,23 +79,10 @@ public class QuotePreview: UIView, InputItem {
|
|
|
}
|
|
|
|
|
|
@objc public func cancel() {
|
|
|
- quoteView.prepareForReuse()
|
|
|
- delegate?.onCancel()
|
|
|
+ safe_fatalError("cancel needs to be implemented in inheriting class")
|
|
|
}
|
|
|
|
|
|
public func configure(draft: DraftModel) {
|
|
|
- if let quoteText = draft.quoteText {
|
|
|
- quoteView.quote.text = quoteText
|
|
|
- if let quoteMessage = draft.quoteMessage {
|
|
|
- let contact = quoteMessage.fromContact
|
|
|
- quoteView.senderTitle.text = contact.displayName
|
|
|
- quoteView.senderTitle.textColor = contact.color
|
|
|
- quoteView.citeBar.backgroundColor = contact.color
|
|
|
- quoteView.imagePreview.image = quoteMessage.image
|
|
|
- }
|
|
|
- isHidden = false
|
|
|
- } else {
|
|
|
- isHidden = true
|
|
|
- }
|
|
|
+ safe_fatalError("configure needs to be implemented in inheriting class")
|
|
|
}
|
|
|
}
|