lucaszischka / BottomSheet

A sliding Sheet from the bottom of the Screen with 3 States build with SwiftUI.
MIT License
1.03k stars 138 forks source link

Main content appear when scroll begin #162

Open bfrolicher opened 4 months ago

bfrolicher commented 4 months ago

Describe the bug MainContent appear during scroll

Minimal reproduce-able code

struct ContentView: View {

    @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
    @State var bottomSheetPosition: BottomSheetPosition = .absoluteBottom(300) //1

    var body: some View {
        map()
            .ignoresSafeArea()
            .bottomSheet(bottomSheetPosition: $bottomSheetPosition,
                         switchablePositions: [.dynamicTop, .absoluteBottom(300)],
                         headerContent: header,
                         mainContent: list)
            .dragIndicatorColor(Color.gray)
            .customBackground(Color.white.cornerRadius(20))
    }

    func header() -> some View {
        Text("Head")
            .font(.title3)
            .frame(height: 50)
            .frame(maxWidth: .infinity)
            .background(Color.red)
    }

    func map() -> some View {
        Map(coordinateRegion: $region)
    }

    func list() -> some View {
            List(0..<200) { item in
                Text("Item \(item)")
            }
            .listStyle(.plain)
    }
}

Expected behavior Main content should be visible on initial state.

Screenshots

https://github.com/lucaszischka/BottomSheet/assets/211953/0f584c7a-38af-498c-ac99-ec4536c2ce2c