playOrPauseAudioAction for FeedVoiceContainerView

This commit is contained in:
nixzhu
2015-12-16 15:12:43 +08:00
parent 202a2d563a
commit d6f1338c0b
2 changed files with 14 additions and 5 deletions
@@ -327,6 +327,12 @@ class FeedSocialWorkCell: FeedBasicCell {
})
}
}
voiceContainerView.playOrPauseAudioAction = { [weak self] in
if let strongSelf = self {
strongSelf.playOrPauseAudioAction?(strongSelf)
}
}
}
}
}
@@ -387,11 +393,6 @@ class FeedSocialWorkCell: FeedBasicCell {
// MARK: Actions
@IBAction func playOrPauseAudio(sender: UIButton) {
playOrPauseAudioAction?(self)
}
func tapDribbbleMedia(sender: UITapGestureRecognizer) {
guard let feed = feed, attachment = feed.attachment else {
@@ -10,6 +10,8 @@ import UIKit
class FeedVoiceContainerView: UIView {
var playOrPauseAudioAction: (() -> Void)?
var audioPlaying: Bool = false {
willSet {
if newValue != audioPlaying {
@@ -34,6 +36,8 @@ class FeedVoiceContainerView: UIView {
button.setImage(UIImage(named: "icon_play"), forState: .Normal)
button.tintColor = UIColor.lightGrayColor()
button.tintAdjustmentMode = .Normal
button.addTarget(self, action: "playOrPauseAudio:", forControlEvents: .TouchUpInside)
return button
}()
@@ -95,5 +99,9 @@ class FeedVoiceContainerView: UIView {
NSLayoutConstraint.activateConstraints([playButtonCenterY])
}
@objc private func playOrPauseAudio(sender: UIButton) {
playOrPauseAudioAction?()
}
}