|
|
|
@ -203,12 +203,12 @@ public class ConfirmationModal: Modal, UITextFieldDelegate {
|
|
|
|
|
closeButton.pin(.right, to: .right, of: contentView, withInset: -8)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func layoutExplanationLabel(showScroll: Bool = true) {
|
|
|
|
|
private func layoutExplanationLabel(_ canScroll: Bool = true) {
|
|
|
|
|
let labelWidth = view.frame.width - 4 * Values.veryLargeSpacing
|
|
|
|
|
let maxLabelSize = CGSize(width: labelWidth, height: CGFloat.greatestFiniteMagnitude)
|
|
|
|
|
let expectedLabelSize = explanationLabel.sizeThatFits(maxLabelSize)
|
|
|
|
|
let lineHeight = explanationLabel.font.lineHeight
|
|
|
|
|
if showScroll {
|
|
|
|
|
if canScroll {
|
|
|
|
|
explanationLabelContainerHeightConstraint.constant = min(expectedLabelSize.height, lineHeight * 5)
|
|
|
|
|
} else {
|
|
|
|
|
explanationLabelContainerHeightConstraint.constant = expectedLabelSize.height
|
|
|
|
@ -242,22 +242,23 @@ public class ConfirmationModal: Modal, UITextFieldDelegate {
|
|
|
|
|
case .none:
|
|
|
|
|
mainStackView.spacing = Values.smallSpacing
|
|
|
|
|
|
|
|
|
|
case .text(let text):
|
|
|
|
|
case .text(let text, let canScroll):
|
|
|
|
|
mainStackView.spacing = Values.smallSpacing
|
|
|
|
|
explanationLabel.text = text
|
|
|
|
|
explanationLabelContainer.isHidden = false
|
|
|
|
|
self.layoutExplanationLabel()
|
|
|
|
|
self.layoutExplanationLabel(canScroll)
|
|
|
|
|
|
|
|
|
|
case .attributedText(let attributedText):
|
|
|
|
|
case .attributedText(let attributedText, let canScroll):
|
|
|
|
|
mainStackView.spacing = Values.smallSpacing
|
|
|
|
|
explanationLabel.attributedText = attributedText
|
|
|
|
|
explanationLabelContainer.isHidden = false
|
|
|
|
|
self.layoutExplanationLabel()
|
|
|
|
|
self.layoutExplanationLabel(canScroll)
|
|
|
|
|
|
|
|
|
|
case .input(let explanation, let placeholder, let value, let clearButton, let onTextChanged):
|
|
|
|
|
explanationLabel.attributedText = explanation
|
|
|
|
|
explanationLabelContainer.isHidden = (explanation == nil)
|
|
|
|
|
self.layoutExplanationLabel(showScroll: false)
|
|
|
|
|
let canScroll: Bool = false
|
|
|
|
|
self.layoutExplanationLabel(canScroll)
|
|
|
|
|
textField.placeholder = placeholder
|
|
|
|
|
textField.text = (value ?? "")
|
|
|
|
|
textField.clearButtonMode = (clearButton ? .always : .never)
|
|
|
|
@ -515,8 +516,14 @@ public extension ConfirmationModal.Info {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case none
|
|
|
|
|
case text(String)
|
|
|
|
|
case attributedText(NSAttributedString)
|
|
|
|
|
case text(
|
|
|
|
|
_ text: String,
|
|
|
|
|
canScroll: Bool = false
|
|
|
|
|
)
|
|
|
|
|
case attributedText(
|
|
|
|
|
_ attributedText: NSAttributedString,
|
|
|
|
|
canScroll: Bool = false
|
|
|
|
|
)
|
|
|
|
|
case input(
|
|
|
|
|
explanation: NSAttributedString?,
|
|
|
|
|
placeholder: String,
|
|
|
|
@ -538,8 +545,8 @@ public extension ConfirmationModal.Info {
|
|
|
|
|
public static func == (lhs: ConfirmationModal.Info.Body, rhs: ConfirmationModal.Info.Body) -> Bool {
|
|
|
|
|
switch (lhs, rhs) {
|
|
|
|
|
case (.none, .none): return true
|
|
|
|
|
case (.text(let lhsText), .text(let rhsText)): return (lhsText == rhsText)
|
|
|
|
|
case (.attributedText(let lhsText), .attributedText(let rhsText)): return (lhsText == rhsText)
|
|
|
|
|
case (.text(let lhsText, _), .text(let rhsText, _)): return (lhsText == rhsText)
|
|
|
|
|
case (.attributedText(let lhsText, _), .attributedText(let rhsText, _)): return (lhsText == rhsText)
|
|
|
|
|
|
|
|
|
|
case (.input(let lhsExplanation, let lhsPlaceholder, let lhsInitialValue, let lhsClearButton, _), .input(let rhsExplanation, let rhsPlaceholder, let rhsInitialValue, let rhsClearButton, _)):
|
|
|
|
|
return (
|
|
|
|
@ -572,8 +579,8 @@ public extension ConfirmationModal.Info {
|
|
|
|
|
public func hash(into hasher: inout Hasher) {
|
|
|
|
|
switch self {
|
|
|
|
|
case .none: break
|
|
|
|
|
case .text(let text): text.hash(into: &hasher)
|
|
|
|
|
case .attributedText(let text): text.hash(into: &hasher)
|
|
|
|
|
case .text(let text, _): text.hash(into: &hasher)
|
|
|
|
|
case .attributedText(let text, _): text.hash(into: &hasher)
|
|
|
|
|
|
|
|
|
|
case .input(let explanation, let placeholder, let initialValue, let clearButton, _):
|
|
|
|
|
explanation.hash(into: &hasher)
|
|
|
|
|