Skip to content

Commit 73f0d7c

Browse files
committed
Reduce animation code
1 parent ac63eb1 commit 73f0d7c

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

Sources/BarcodeScannerController.swift

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -218,25 +218,11 @@ open class BarcodeScannerController: UIViewController {
218218

219219
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
220220
super.viewWillTransition(to: size, with: coordinator)
221-
222221
coordinator.animate(alongsideTransition: { (context) in
223222
self.setupFrame()
224223
}) { (context) in
225-
226224
self.focusView.layer.removeAllAnimations()
227-
228-
UIView.animate(withDuration: 0.3, animations: {
229-
if self.barCodeFocusViewType == .oneDimension {
230-
self.center(subview: self.focusView, inSize: CGSize(width: 280, height: 80))
231-
} else {
232-
self.center(subview: self.focusView, inSize: CGSize(width: 218, height: 150))
233-
}
234-
}, completion: { (finished) in
235-
if finished {
236-
self.animateFocusView()
237-
}
238-
})
239-
225+
self.animateFocusView()
240226
}
241227
}
242228

@@ -332,14 +318,13 @@ open class BarcodeScannerController: UIViewController {
332318
flashButton.alpha = alpha
333319
settingsButton.isHidden = status.state != .unauthorized
334320
}
335-
321+
336322
// MARK: - Layout
337-
338323
func setupFrame() {
339324
headerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 64)
340325
flashButton.frame = CGRect(x: view.frame.width - 50, y: 73, width: 37, height: 37)
341326
infoView.frame = infoFrame
342-
327+
343328
if let videoPreviewLayer = videoPreviewLayer {
344329
videoPreviewLayer.frame = view.layer.bounds
345330
if let connection = videoPreviewLayer.connection, connection.isVideoOrientationSupported {
@@ -362,7 +347,7 @@ open class BarcodeScannerController: UIViewController {
362347

363348
headerView.isHidden = !isBeingPresented
364349
}
365-
350+
366351
/**
367352
Sets a new size and center aligns subview's position.
368353

0 commit comments

Comments
 (0)