diff --git a/Signal/Images.xcassets/ic_add_caption.imageset/Contents.json b/Signal/Images.xcassets/ic_add_caption.imageset/Contents.json new file mode 100644 index 000000000..0e4bd3f5c --- /dev/null +++ b/Signal/Images.xcassets/ic_add_caption.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "add-caption-24@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "add-caption-24@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "add-caption-24@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@1x.png b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@1x.png new file mode 100644 index 000000000..24a60cdc7 Binary files /dev/null and b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@1x.png differ diff --git a/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@2x.png b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@2x.png new file mode 100644 index 000000000..86a353471 Binary files /dev/null and b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@2x.png differ diff --git a/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@3x.png b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@3x.png new file mode 100644 index 000000000..ddc372a56 Binary files /dev/null and b/Signal/Images.xcassets/ic_add_caption.imageset/add-caption-24@3x.png differ diff --git a/Signal/src/ViewControllers/CropScaleImageViewController.swift b/Signal/src/ViewControllers/CropScaleImageViewController.swift index 08721b178..4ba967e14 100644 --- a/Signal/src/ViewControllers/CropScaleImageViewController.swift +++ b/Signal/src/ViewControllers/CropScaleImageViewController.swift @@ -444,8 +444,7 @@ import SignalMessaging cancelButton.autoPinEdge(toSuperviewEdge: .bottom) cancelButton.autoPinEdge(toSuperviewEdge: .left) - let doneButton = createButton(title: NSLocalizedString("BUTTON_DONE", - comment: "Label for generic done button."), + let doneButton = createButton(title: CommonStrings.doneButton, action: #selector(donePressed)) buttonRow.addSubview(doneButton) doneButton.autoPinEdge(toSuperviewEdge: .top) diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index d3dd9014d..2c43e3c6e 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -1178,17 +1178,24 @@ class CaptionView: UIView { super.init(frame: .zero) + backgroundColor = UIColor.black.withAlphaComponent(0.6) + self.captionText = attachmentItem.captionText + textView.delegate = self - addSubview(placeholderTextView) - placeholderTextView.autoPinEdgesToSuperviewMargins() + let textContainer = UIView() + textContainer.addSubview(placeholderTextView) + placeholderTextView.autoPinEdgesToSuperviewEdges() - backgroundColor = UIColor.black.withAlphaComponent(0.6) - addSubview(textView) - textView.autoPinEdgesToSuperviewMargins() - textView.delegate = self + textContainer.addSubview(textView) + textView.autoPinEdgesToSuperviewEdges() + textViewHeightConstraint = textView.autoSetDimension(.height, toSize: kMinTextViewHeight) - self.textViewHeightConstraint = textView.autoSetDimension(.height, toSize: kMinTextViewHeight) + let hStack = UIStackView(arrangedSubviews: [addCaptionButton, textContainer, doneButton]) + doneButton.isHidden = true + + addSubview(hStack) + hStack.autoPinEdgesToSuperviewMargins() } required init?(coder aDecoder: NSCoder) { @@ -1236,8 +1243,8 @@ class CaptionView: UIView { placeholderTextView.backgroundColor = .clear placeholderTextView.keyboardAppearance = Theme.keyboardAppearance placeholderTextView.font = UIFont.ows_dynamicTypeBody - // MJK FIXME always dark theme - placeholderTextView.textColor = Theme.placeholderColor + + placeholderTextView.textColor = Theme.darkThemePrimaryColor placeholderTextView.returnKeyType = .done return placeholderTextView @@ -1253,16 +1260,44 @@ class CaptionView: UIView { return textView }() + + lazy var addCaptionButton: UIButton = { + let addCaptionButton = OWSButton { [weak self] in + self?.textView.becomeFirstResponder() + } + + let icon = #imageLiteral(resourceName: "ic_add_caption").withRenderingMode(.alwaysTemplate) + addCaptionButton.setImage(icon, for: .normal) + addCaptionButton.tintColor = Theme.darkThemePrimaryColor + + return addCaptionButton + }() + + lazy var doneButton: UIButton = { + let doneButton = OWSButton { [weak self] in + self?.textView.resignFirstResponder() + } + doneButton.setTitle(CommonStrings.doneButton, for: .normal) + doneButton.tintColor = Theme.darkThemePrimaryColor + + return doneButton + }() } extension CaptionView: UITextViewDelegate { public func textViewDidBeginEditing(_ textView: UITextView) { updatePlaceholderTextViewVisibility() + doneButton.isHidden = false + addCaptionButton.isHidden = true + delegate?.captionViewDidBeginEditing(self) } public func textViewDidEndEditing(_ textView: UITextView) { updatePlaceholderTextViewVisibility() + doneButton.isHidden = true + addCaptionButton.isHidden = false + delegate?.captionViewDidEndEditing(self) } diff --git a/SignalMessaging/Views/CommonStrings.swift b/SignalMessaging/Views/CommonStrings.swift index af4e0d778..ac35634ad 100644 --- a/SignalMessaging/Views/CommonStrings.swift +++ b/SignalMessaging/Views/CommonStrings.swift @@ -14,6 +14,8 @@ import Foundation @objc static public let cancelButton = NSLocalizedString("TXT_CANCEL_TITLE", comment: "Label for the cancel button in an alert or action sheet.") @objc + static public let doneButton = NSLocalizedString("BUTTON_DONE", comment: "Label for generic done button.") + @objc static public let retryButton = NSLocalizedString("RETRY_BUTTON_TEXT", comment: "Generic text for button that retries whatever the last action was.") @objc static public let openSettingsButton = NSLocalizedString("OPEN_SETTINGS_BUTTON", comment: "Button text which opens the settings app")