New "add caption" and "done" assets

This commit is contained in:
Michael Kirk 2018-11-23 18:03:01 -06:00
parent feb5a0c444
commit 8776dd1909
7 changed files with 71 additions and 12 deletions

View file

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

View file

@ -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)

View file

@ -1178,17 +1178,24 @@ class CaptionView: UIView {
super.init(frame: .zero)
self.captionText = attachmentItem.captionText
addSubview(placeholderTextView)
placeholderTextView.autoPinEdgesToSuperviewMargins()
backgroundColor = UIColor.black.withAlphaComponent(0.6)
addSubview(textView)
textView.autoPinEdgesToSuperviewMargins()
self.captionText = attachmentItem.captionText
textView.delegate = self
self.textViewHeightConstraint = textView.autoSetDimension(.height, toSize: kMinTextViewHeight)
let textContainer = UIView()
textContainer.addSubview(placeholderTextView)
placeholderTextView.autoPinEdgesToSuperviewEdges()
textContainer.addSubview(textView)
textView.autoPinEdgesToSuperviewEdges()
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)
}

View file

@ -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")