Apply image editor design.

pull/2/head
Matthew Chen 7 years ago
parent 0e806ea630
commit e01f39e8e1

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "marker-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "marker-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "marker-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "add-caption-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "add-caption-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "add-caption-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkmark-circle-outline-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkmark-circle-outline-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "checkmark-circle-outline-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkmark-circle-filled-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkmark-circle-filled-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "checkmark-circle-filled-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "crop-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "crop-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "crop-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "crop-lock-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "crop-lock-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "crop-lock-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "crop-unlock-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "crop-unlock-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "crop-unlock-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "flip-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "flip-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "flip-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "rotate-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "rotate-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "rotate-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "text-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "text-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "text-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "undo-32@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "undo-32@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "undo-32@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -82,26 +82,32 @@ class ImageEditorCropViewController: OWSViewController {
self.view = UIView()
self.view.backgroundColor = .black
self.view.layoutMargins = .zero
// MARK: - Buttons
// TODO: Apply icons.
let doneButton = OWSButton(title: "Done") { [weak self] in
let doneButton = OWSButton(imageName: "image_editor_checkmark_full",
tintColor: UIColor.white) { [weak self] in
self?.didTapBackButton()
}
let rotate90Button = OWSButton(title: "Rotate 90°") { [weak self] in
let rotate90Button = OWSButton(imageName: "image_editor_rotate",
tintColor: UIColor.white) { [weak self] in
self?.rotate90ButtonPressed()
}
let rotate45Button = OWSButton(title: "Rotate 45°") { [weak self] in
self?.rotate45ButtonPressed()
}
let resetButton = OWSButton(title: "Reset") { [weak self] in
// TODO: Myles may change this asset.
let resetButton = OWSButton(imageName: "image_editor_undo",
tintColor: UIColor.white) { [weak self] in
self?.resetButtonPressed()
}
let zoom2xButton = OWSButton(title: "Zoom 2x") { [weak self] in
self?.zoom2xButtonPressed()
}
let flipButton = OWSButton(title: "Flip") { [weak self] in
let flipButton = OWSButton(imageName: "image_editor_flip",
tintColor: UIColor.white) { [weak self] in
self?.flipButtonPressed()
}
@ -171,7 +177,7 @@ class ImageEditorCropViewController: OWSViewController {
stackView.axis = .vertical
stackView.alignment = .fill
stackView.spacing = 24
stackView.layoutMargins = UIEdgeInsets(top: 16, left: 20, bottom: 16, right: 20)
stackView.layoutMargins = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20)
stackView.isLayoutMarginsRelativeArrangement = true
self.view.addSubview(stackView)
stackView.autoPinEdgesToSuperviewEdges()

@ -129,8 +129,8 @@ public class ImageEditorView: UIView {
}
}
// The model supports redo if we ever want to add it.
private let undoButton = UIButton(type: .custom)
private let redoButton = UIButton(type: .custom)
private let brushButton = UIButton(type: .custom)
private let cropButton = UIButton(type: .custom)
private let newTextButton = UIButton(type: .custom)
@ -140,26 +140,22 @@ public class ImageEditorView: UIView {
@objc
public func addControls(to containerView: UIView) {
configure(button: undoButton,
label: NSLocalizedString("BUTTON_UNDO", comment: "Label for undo button."),
imageName: "image_editor_undo",
selector: #selector(didTapUndo(sender:)))
configure(button: redoButton,
label: NSLocalizedString("BUTTON_REDO", comment: "Label for redo button."),
selector: #selector(didTapRedo(sender:)))
configure(button: brushButton,
label: NSLocalizedString("IMAGE_EDITOR_BRUSH_BUTTON", comment: "Label for brush button in image editor."),
imageName: "image_editor_brush",
selector: #selector(didTapBrush(sender:)))
configure(button: cropButton,
label: NSLocalizedString("IMAGE_EDITOR_CROP_BUTTON", comment: "Label for crop button in image editor."),
imageName: "image_editor_crop",
selector: #selector(didTapCrop(sender:)))
configure(button: newTextButton,
label: "Text",
imageName: "image_editor_text",
selector: #selector(didTapNewText(sender:)))
allButtons = [brushButton, cropButton, undoButton, redoButton, newTextButton]
allButtons = [brushButton, cropButton, undoButton, newTextButton]
let stackView = UIStackView(arrangedSubviews: allButtons)
stackView.axis = .vertical
@ -178,19 +174,26 @@ public class ImageEditorView: UIView {
}
private func configure(button: UIButton,
label: String,
imageName: String,
selector: Selector) {
button.setTitle(label, for: .normal)
if let image = UIImage(named: imageName) {
button.setImage(image.withRenderingMode(.alwaysTemplate), for: .normal)
} else {
owsFailDebug("Missing asset: \(imageName)")
}
button.tintColor = .white
button.setTitleColor(.white, for: .normal)
button.setTitleColor(.gray, for: .disabled)
button.setTitleColor(UIColor.ows_materialBlue, for: .selected)
button.titleLabel?.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight()
button.addTarget(self, action: selector, for: .touchUpInside)
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowRadius = 4
button.layer.shadowOpacity = 0.66
}
private func updateButtons() {
undoButton.isEnabled = model.canUndo()
redoButton.isEnabled = model.canRedo()
brushButton.isSelected = editorMode == .brush
cropButton.isSelected = false
newTextButton.isSelected = false
@ -211,15 +214,6 @@ public class ImageEditorView: UIView {
model.undo()
}
@objc func didTapRedo(sender: UIButton) {
Logger.verbose("")
guard model.canRedo() else {
owsFailDebug("Can't redo.")
return
}
model.redo()
}
@objc func didTapBrush(sender: UIButton) {
Logger.verbose("")

@ -29,6 +29,23 @@ public class OWSButton: UIButton {
setTitle(title, for: .normal)
}
@objc
init(imageName: String,
tintColor: UIColor,
block: @escaping () -> Void = { }) {
super.init(frame: .zero)
self.block = block
addTarget(self, action: #selector(didTap), for: .touchUpInside)
if let image = UIImage(named: imageName) {
setImage(image.withRenderingMode(.alwaysTemplate), for: .normal)
} else {
owsFailDebug("Missing asset: \(imageName)")
}
self.tintColor = tintColor
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Loading…
Cancel
Save