Skip to content

Commit

Permalink
Make viewer easier to dismiss. (eu-digital-green-certificates#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 3, 2021
1 parent e446a84 commit dc54d60
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions DGCAVerifier/ViewControllers/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ScanVC: SwiftDGC.ScanVC {
fpc.layout = FullFloatingPanelLayout()
fpc.surfaceView.layer.cornerRadius = 24.0
fpc.surfaceView.clipsToBounds = true
fpc.delegate = self
viewer.hCert = certificate
viewer.childDismissedDelegate = self
presentingViewer = viewer
Expand All @@ -89,3 +90,23 @@ extension ScanVC: CertViewerDelegate {
presentingViewer = nil
}
}

extension ScanVC: FloatingPanelControllerDelegate {
func floatingPanel(_ fpc: FloatingPanelController, shouldRemoveAt location: CGPoint, with velocity: CGVector) -> Bool {
let pos = location.y / view.bounds.height
if pos >= 0.33 {
return true
}
let threshold: CGFloat = 5.0
switch fpc.layout.position {
case .top:
return (velocity.dy <= -threshold)
case .left:
return (velocity.dx <= -threshold)
case .bottom:
return (velocity.dy >= threshold)
case .right:
return (velocity.dx >= threshold)
}
}
}

0 comments on commit dc54d60

Please sign in to comment.