Skip to content

Commit

Permalink
sheet finally complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Zahlkovsk1 committed Jul 14, 2024
1 parent ec4ce35 commit 8875972
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
18 changes: 1 addition & 17 deletions Bilbary for iPhone/Viiews/BilbaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ struct BilbaryView: View {
@State
private var coordinator = SheetCoordinator()

@State
private var tabBarShown: Bool = false

@State
private var sheetOffset: Double = 100

var body: some View {
ZStack {
ZStack {
Expand All @@ -27,20 +21,10 @@ struct BilbaryView: View {
// Spacer()
}.padding()
.onTapGesture {
tabBarShown.toggle()
if tabBarShown {
withAnimation(.easeInOut(duration: 0.2)) {
sheetOffset = 0
}
} else {
withAnimation(.easeInOut(duration: 0.2)) {
sheetOffset = 100
}
}
coordinator.tabBarShown.toggle()
}
}
CustomSheetView()
.offset(y: sheetOffset)
.environment(coordinator)
}
}
Expand Down
14 changes: 14 additions & 0 deletions Bilbary for iPhone/Viiews/CustomSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ struct CustomSheetView: View {
appUsageTracker.endSession(to: context)
}
}
.onChange(of: coordinator.tabBarShown) {
if coordinator.tabBarShown {

withAnimation(.easeInOut(duration: 0.2)) {
coordinator.offset = UIScreen.main.bounds.height * 0.85
}
} else {

withAnimation(.easeInOut(duration: 0.2)) {
coordinator.offset = UIScreen.main.bounds.height * 1.1

}
}
}
.background(.ultraThinMaterial)
.cornerRadius(20.0)
.offset(y: coordinator.offset)
Expand Down
3 changes: 2 additions & 1 deletion Bilbary for iPhone/iiPhone Models/SheetCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class SheetCoordinator {
case top
}

var tabBarShown: Bool = false
var sheetOffset: Double = 0

var offset: Double = UIScreen.main.bounds.height * 0.8
var offset: Double = UIScreen.main.bounds.height * 1.1
var offsetAnchor: CGFloat?

var deltaOffset: CGFloat = 0
Expand Down

0 comments on commit 8875972

Please sign in to comment.