Skip to content

Commit

Permalink
Add more haptic feedback to favorites drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
thealpa committed Apr 21, 2022
1 parent 4a6b0ff commit ae7f7ba
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CVAG/Views/FavoritesDrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ struct FavoritesDrawerView: View {
@State var restingHeight: [CGFloat] = drawerDefault
@State var currentDrawerHeight: CGFloat = drawerDefault[1]

/// Haptics
var impactGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
var dislodgeGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)

//Workaround
@State var showGrid: Bool = true

Expand Down Expand Up @@ -95,8 +99,14 @@ struct FavoritesDrawerView: View {
.onChange(of: showFavoritesView) { showView in
if showView == false {
restingHeight = [-100]
DispatchQueue.main.async {
dislodgeGenerator.impactOccurred()
}
} else if showView == true {
restingHeight = drawerDefault
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
impactGenerator.impactOccurred()
}
}
}.ignoresSafeArea(.all)
}
Expand Down

0 comments on commit ae7f7ba

Please sign in to comment.