Skip to content

Commit

Permalink
Add pulse animation for capture button
Browse files Browse the repository at this point in the history
  • Loading branch information
akarataev committed Nov 10, 2018
1 parent 6ba1bff commit 2587156
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Gleam/Components/CaptureButton/CaptureButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class CaptureButton: UIButton {

extension CaptureButton {

func startPulseAnimation(tacts: Int) {
guard tacts > 0 else { return }
func repeatPulseAnimation(count: Int) {
guard count > 0 else { return }
UIView.animate(withDuration: 0.3, animations: {
self.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}, completion: { finished in
UIView.animate(withDuration: 0.3, animations: {
self.transform = .identity
}, completion: { finished in
self.startPulseAnimation(tacts: tacts - 1)
self.repeatPulseAnimation(count: count - 1)
})
})

Expand Down
11 changes: 10 additions & 1 deletion Gleam/Modules/Screening/View/ScreeningViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,19 @@ extension ScreeningViewController {
extension ScreeningViewController {

@objc func captureButtonDidTap(_ sender: CaptureButton) {
print("tap")
self.statusPanel.indicate()
self.selectCaptureButtonAnimation(for: sender)
self.output.userRequestImageProcessing(mode: modeSegmented.mode)
}

func selectCaptureButtonAnimation(for sender: CaptureButton) {
switch self.modeSegmented.mode {
case .live:
captureButton.repeatPulseAnimation(count: 9)
case .photo:
captureButton.repeatPulseAnimation(count: 1)
}
}
}


Expand Down

0 comments on commit 2587156

Please sign in to comment.