Skip to content

Commit eeafa3d

Browse files
authored
Merge pull request #88 from tumblr/stories/bug-fixes
A few minor Bug Fixes
2 parents 8e5d58b + bc6df66 commit eeafa3d

10 files changed

+125
-12
lines changed

Classes/Camera/CameraPermissionsViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CameraPermissionsView: UIView, CameraPermissionsViewable, MediaPickerButto
7272
private lazy var titleLabel: UILabel = {
7373
let label = UILabel()
7474
label.translatesAutoresizingMaskIntoConstraints = false
75-
label.text = NSLocalizedString("Post to Tumblr", comment: "Title of camera permissions screen")
75+
label.text = KanvasStrings.shared.cameraPermissionsTitleLabel
7676
label.font = Constants.titleFont
7777
label.textColor = Constants.textColor
7878
label.textAlignment = .center
@@ -83,7 +83,7 @@ class CameraPermissionsView: UIView, CameraPermissionsViewable, MediaPickerButto
8383
let label = UILabel()
8484
label.translatesAutoresizingMaskIntoConstraints = false
8585

86-
let description = NSLocalizedString("Allow access so you can start taking photos and videos", comment: "Message on camera permissions screen to explain why the Tumblr app needs camera and microphone permissions")
86+
let description = KanvasStrings.shared.cameraPermissionsDescriptionLabel
8787
let descriptionParagraphStyle = NSMutableParagraphStyle()
8888
descriptionParagraphStyle.lineSpacing = Constants.descriptionFont.pointSize * 0.5
8989
let descriptionAttributedString = NSMutableAttributedString(string: description)
@@ -108,7 +108,7 @@ class CameraPermissionsView: UIView, CameraPermissionsViewable, MediaPickerButto
108108
}()
109109

110110
private lazy var microphoneAccessButton: UIButton = {
111-
let title = NSLocalizedString("Allow access to microphone", comment: "Button on camera permissions screen to initiate the sytem prompt for microphone access")
111+
let title = NSLocalizedString("Allow access to microphone", comment: "Button on camera permissions screen to initiate the sytem prompt for microphone access.")
112112
let titleDisabled = NSLocalizedString("Microphone access granted", comment: "Label on camera permissions screen to indicate microphone access is granted")
113113
let button = CameraPermissionsView.makeButton(title: title, titleDisabled: titleDisabled)
114114
button.translatesAutoresizingMaskIntoConstraints = false

Classes/Constants/KanvasStrings.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import Foundation
88

99
// the values for common string throughout the module
10-
struct KanvasStrings {
10+
public struct KanvasStrings {
1111
// MARK: - Camera Modes
1212

1313
// photoModeName: used in the camera mode button
@@ -42,4 +42,18 @@ struct KanvasStrings {
4242
static func bundlePath(for aClass: AnyClass) -> String? {
4343
return Bundle(for: aClass).path(forResource: "Kanvas", ofType: "bundle")
4444
}
45+
46+
public var cameraPermissionsTitleLabel: String
47+
public var cameraPermissionsDescriptionLabel: String
48+
49+
public static var shared = KanvasStrings(
50+
cameraPermissionsTitleLabel: NSLocalizedString("Post to Tumblr", comment: "Title of camera permissions screen"),
51+
cameraPermissionsDescriptionLabel: NSLocalizedString("Allow access so you can start taking photos and videos", comment: "Message on camera permissions screen to explain why the Tumblr app needs camera and microphone permissions")
52+
)
53+
54+
public init(cameraPermissionsTitleLabel: String,
55+
cameraPermissionsDescriptionLabel: String) {
56+
self.cameraPermissionsTitleLabel = cameraPermissionsTitleLabel
57+
self.cameraPermissionsDescriptionLabel = cameraPermissionsDescriptionLabel
58+
}
4559
}

Classes/Editor/EditorView.swift

+12
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
237237
self.movableViewCanvas.delegate = self
238238
setupViews()
239239
}
240+
241+
func updateUI(forDraggingClip: Bool) {
242+
if forDraggingClip {
243+
self.movableViewCanvas.showTrash()
244+
} else {
245+
self.movableViewCanvas.hideTrash()
246+
}
247+
UIView.animate(withDuration: 0.5, animations: {
248+
self.collectionContainer.alpha = forDraggingClip ? 0.0 : 1.0
249+
self.collectionContainer.isHidden = forDraggingClip
250+
})
251+
}
240252

241253
private func setupViews() {
242254
setupPlayer()

Classes/Editor/MovableViews/MovableViewCanvas.swift

+33
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ final class MovableViewCanvas: IgnoreTouchesView, UIGestureRecognizerDelegate, M
7373
return movableViews.isEmpty
7474
}
7575

76+
var trashCompletion: (() -> Void)? {
77+
set {
78+
trashView.completion = newValue
79+
}
80+
get {
81+
return trashView.completion
82+
}
83+
}
84+
7685
var movableViews: [MovableView] {
7786
return subviews.compactMap { $0 as? MovableView }
7887
}
@@ -224,6 +233,30 @@ final class MovableViewCanvas: IgnoreTouchesView, UIGestureRecognizerDelegate, M
224233
selectedMovableView?.removeFromSuperview()
225234
selectedMovableView = nil
226235
}
236+
237+
/// shows the trash icon opened with its red background
238+
func openTrash() {
239+
trashView.open()
240+
}
241+
242+
/// shows the trash icon closed
243+
func showTrash() {
244+
showOverlay(true)
245+
trashView.superview?.bringSubviewToFront(trashView)
246+
movableViews.forEach { movableView in
247+
movableView.fadeOut()
248+
}
249+
trashView.close()
250+
}
251+
252+
/// hides the trash icon with its red background
253+
func hideTrash() {
254+
showOverlay(false)
255+
movableViews.forEach { movableView in
256+
movableView.fadeIn()
257+
}
258+
trashView.hide()
259+
}
227260

228261
// MARK: - Gesture recognizers
229262

Classes/Editor/MultiEditor/MultiEditorViewController.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class MultiEditorViewController: UIViewController {
144144
}
145145
editor.additionalSafeAreaInsets = UIEdgeInsets(top: 0, left: 0, bottom: bottom, right: 0)
146146
editor.delegate = self
147+
editor.editorView.movableViewCanvas.trashCompletion = { [weak self] in
148+
self?.clipsController.removeDraggingClip()
149+
}
147150
load(childViewController: editor, into: editorContainer)
148151
currentEditor = editor
149152
}
@@ -197,11 +200,11 @@ extension MultiEditorViewController: MediaPlayerController {
197200

198201
extension MultiEditorViewController: MediaClipsEditorDelegate {
199202
func mediaClipStartedMoving() {
200-
// No-op for the moment. UI is coming in a future commit.
203+
currentEditor?.editorView.updateUI(forDraggingClip: true)
201204
}
202205

203206
func mediaClipFinishedMoving() {
204-
// No-op for the moment. UI is coming in a future commit.
207+
currentEditor?.editorView.updateUI(forDraggingClip: false)
205208
}
206209

207210
func addButtonWasPressed() {

Classes/Editor/Text/EditorTextView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ final class EditorTextView: UIView, MainTextViewDelegate {
309309
}
310310

311311
private func refreshFontSelector() {
312-
if let attributedFont = font?.withSize(18) {
313-
fontSelector.setAttributedTitle(NSAttributedString(string: "Aa", attributes: [.font: attributedFont]), for: .normal)
312+
if let attributedFont = font?.withSize(20) {
313+
fontSelector.setAttributedTitle(NSAttributedString(string: "Aa", attributes: [.font: attributedFont, .foregroundColor: UIColor.white]), for: .normal)
314314
}
315315
}
316316

Classes/Utility/IgnoreTouches/IgnoreTouchesView.swift

+14-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ import UIKit
1515
/// This class is meant to be subclassed.
1616
class IgnoreTouchesView: UIView {
1717

18+
/// Override this property to specifically select which types of events to ignore
19+
private(set) var ignoredTypes: [UIEvent.EventType]? = nil
20+
1821
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
1922
let hitView = super.hitTest(point, with: event)
20-
return hitView == self ? nil : hitView
23+
let ignored: Bool
24+
if let type = event?.type, let ignoredTypes = ignoredTypes {
25+
ignored = ignoredTypes.contains(type)
26+
} else {
27+
ignored = true
28+
}
29+
if ignored {
30+
return hitView == self ? nil : hitView
31+
} else {
32+
return hitView
33+
}
2134
}
2235

2336
}

Classes/Utility/TrashView.swift

+38
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ final class TrashView: IgnoreTouchesView {
3131
private let translucentBackgroundCircle: UIImageView
3232
private let openedTrash: UIImageView
3333
private let closedTrash: UIImageView
34+
35+
var completion: (() -> Void)?
36+
37+
override var ignoredTypes: [UIEvent.EventType]? {
38+
return [.touches, .presses]
39+
}
3440

3541
init() {
3642
self.borderCircle = UIImageView()
@@ -41,6 +47,11 @@ final class TrashView: IgnoreTouchesView {
4147
super.init(frame: .zero)
4248

4349
setUpViews()
50+
51+
let dropInteraction = UIDropInteraction(delegate: self)
52+
addInteraction(dropInteraction)
53+
54+
isUserInteractionEnabled = true
4455
}
4556

4657
required init?(coder aDecoder: NSCoder) {
@@ -230,3 +241,30 @@ final class TrashView: IgnoreTouchesView {
230241
}
231242
}
232243
}
244+
245+
extension TrashView: UIDropInteractionDelegate {
246+
// MARK: - UIDropInteractionDelegate
247+
248+
func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal {
249+
return UIDropProposal(operation: .move)
250+
}
251+
252+
func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
253+
UINotificationFeedbackGenerator().notificationOccurred(.success)
254+
completion?()
255+
}
256+
257+
func dropInteraction(_ interaction: UIDropInteraction, sessionDidEnter session: UIDropSession) {
258+
UISelectionFeedbackGenerator().selectionChanged()
259+
open()
260+
}
261+
262+
func dropInteraction(_ interaction: UIDropInteraction, sessionDidExit session: UIDropSession) {
263+
UISelectionFeedbackGenerator().selectionChanged()
264+
close()
265+
}
266+
267+
func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool {
268+
return true
269+
}
270+
}

Kanvas.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = "Kanvas"
3-
spec.version = "1.2.0"
3+
spec.version = "1.2.1"
44
spec.summary = "A custom camera built for iOS."
55
spec.homepage = "https://github.com/tumblr/kanvas-ios"
66
spec.license = "MPLv2"

KanvasExample/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PODS:
44
- FBSnapshotTestCase/Core (2.1.4)
55
- FBSnapshotTestCase/SwiftSupport (2.1.4):
66
- FBSnapshotTestCase/Core
7-
- Kanvas (1.1.1)
7+
- Kanvas (1.2.1)
88

99
DEPENDENCIES:
1010
- FBSnapshotTestCase (= 2.1.4)
@@ -20,7 +20,7 @@ EXTERNAL SOURCES:
2020

2121
SPEC CHECKSUMS:
2222
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
23-
Kanvas: 565caff19d90e883194e6e646f6ea994e14fcde5
23+
Kanvas: 257eab9c9e3666f990a202e73ff793f399d8dd13
2424

2525
PODFILE CHECKSUM: 14b28dd726149c0d01dba9154d5bb095d9ba6a18
2626

0 commit comments

Comments
 (0)