mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-15 07:45:55 +10:00
refactor VoiceRecordButton's actions
This commit is contained in:
@@ -151,20 +151,20 @@ class MessageToolbar: UIToolbar {
|
||||
button.layer.borderColor = UIColor.messageToolBarHighlightColor().CGColor
|
||||
button.tintColor = UIColor.messageToolBarHighlightColor()
|
||||
|
||||
button.yepTouchBegin = {
|
||||
self.trySendVoiceMessageBegin()
|
||||
button.touchesBegin = { [weak self] in
|
||||
self?.trySendVoiceMessageBegin()
|
||||
}
|
||||
|
||||
button.yepTouchesMoved = {
|
||||
button.touchesMoved = {
|
||||
|
||||
}
|
||||
|
||||
button.yepTouchesEnded = {
|
||||
self.trySendVoiceMessageEnd()
|
||||
button.touchesEnded = { [weak self] in
|
||||
self?.trySendVoiceMessageEnd()
|
||||
}
|
||||
|
||||
button.yepTouchesCancelled = {
|
||||
self.trySendVoiceMessageCancel()
|
||||
button.touchesCancelled = { [weak self] in
|
||||
self?.trySendVoiceMessageCancel()
|
||||
}
|
||||
|
||||
return button
|
||||
|
||||
@@ -10,53 +10,42 @@ import UIKit
|
||||
|
||||
class VoiceRecordButton: UIView {
|
||||
|
||||
var yepTouchBegin : (() -> ())?
|
||||
var touchesBegin : (() -> ())?
|
||||
|
||||
var yepTouchesEnded : (() -> ())?
|
||||
var touchesEnded : (() -> ())?
|
||||
|
||||
var yepTouchesCancelled : (() -> ())?
|
||||
var touchesCancelled : (() -> ())?
|
||||
|
||||
var yepTouchesMoved : (() -> ())?
|
||||
var touchesMoved : (() -> ())?
|
||||
|
||||
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
|
||||
super.touchesBegan(touches, withEvent: event)
|
||||
|
||||
if let yepTouchBegin = yepTouchBegin {
|
||||
yepTouchBegin()
|
||||
}
|
||||
touchesBegin?()
|
||||
}
|
||||
|
||||
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
|
||||
super.touchesEnded(touches, withEvent: event)
|
||||
|
||||
if let yepTouchesEnded = yepTouchesEnded {
|
||||
yepTouchesEnded()
|
||||
}
|
||||
touchesEnded?()
|
||||
}
|
||||
|
||||
override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
|
||||
super.touchesCancelled(touches, withEvent: event)
|
||||
|
||||
if let yepTouchesCancelled = yepTouchesCancelled {
|
||||
yepTouchesCancelled()
|
||||
}
|
||||
touchesCancelled?()
|
||||
}
|
||||
|
||||
override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
|
||||
super.touchesMoved(touches, withEvent: event)
|
||||
|
||||
if let yepTouchesMoved = yepTouchesMoved {
|
||||
yepTouchesMoved()
|
||||
}
|
||||
touchesMoved?()
|
||||
}
|
||||
|
||||
|
||||
|
||||
override func didMoveToSuperview() {
|
||||
|
||||
super.didMoveToSuperview()
|
||||
makeUI()
|
||||
|
||||
makeUI()
|
||||
}
|
||||
|
||||
private func makeUI() {
|
||||
|
||||
Reference in New Issue
Block a user