Created
April 9, 2025 08:53
-
-
Save iAmVishal16/7c9d409b08affc6f0fae5ab830bd08a7 to your computer and use it in GitHub Desktop.
Sheet is always visible and not dismissible. Background buttons & text field remain interactive. Works with dynamic sheet sizing (small & medium heights).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct HomeView: View { | |
| @State private var isSheetPresented = true | |
| @State private var textInput: String = "" | |
| @State private var tapCount = 0 | |
| var body: some View { | |
| ZStack { | |
| Color.purple | |
| .edgesIgnoringSafeArea(.all) | |
| // Interactive background elements | |
| VStack(spacing: 20) { | |
| Text("Background Content") | |
| .font(.title) | |
| .foregroundColor(.white) | |
| Text("Tap count: \(tapCount)") | |
| .foregroundColor(.white) | |
| Button(action: { | |
| tapCount += 1 | |
| }) { | |
| Text("Tap Me!") | |
| .padding() | |
| .background(Color.white) | |
| .foregroundColor(.purple) | |
| .cornerRadius(10) | |
| } | |
| TextField("Type something...", text: $textInput) | |
| .textFieldStyle(.roundedBorder) | |
| .padding() | |
| } | |
| .padding() | |
| } | |
| .sheet(isPresented: $isSheetPresented) { | |
| Text("Half screen content here") | |
| .presentationDetents([.fraction(0.35), .medium]) | |
| .interactiveDismissDisabled(true) | |
| .presentationBackgroundInteraction(.enabled(upThrough: .medium)) | |
| } | |
| } | |
| } | |
| #Preview { | |
| HomeView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment