Home > Back-end >  How to make a SwiftUI view cover full screen
How to make a SwiftUI view cover full screen

Time:01-05

There is a SwiftUI file that is named Converter.swift that is opened when a button is clicked, the code is below, however how can I make the Converter SwiftUI cover the full screen when it is opened? I have tried .edgesIgnoringSafeArea(.all) which I put underneath

.sheet(isPresented: $converterSheetVisible) {
Converter()

however this is not working so I also tried

.frame(minWidth: .infinity, maxWidth: .infinity, minHeight: .infinity, maxHeight: .infinity)

but this is not working either.

import SwiftUI
import Firebase
import UIKit

struct ContentView: View {
    @State private var converterSheetVisible = false
    
    @AppStorage("log_status") var logStatus: Bool = false
    var body: some View {
        if logStatus{
            DemoHome()
        }else{
            Login()
        }
        
    }
    @ViewBuilder
    func DemoHome()->some View{
        
        
        VStack {
            NavigationView {
                NavigationStack{
                    
                    Button("Enter"){
                        print("clicked")
                        self.converterSheetVisible.toggle()
                        
                        
                    }
                    
                    
                    
                }
                
                .navigationTitle("Authenticated Account").font(.system(size: 15, weight: .regular))
                .toolbar {
                    ToolbarItem{
                        Button("Logout"){
                            try? Auth.auth().signOut()
                            withAnimation(.easeInOut){
                                logStatus = false
                                
                            }
                        }
                    }
                }
            }
            .sheet(isPresented: $converterSheetVisible) {
                Converter()
                   
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

CodePudding user response:

sheet(isPresented:onDismiss:content:) does by definition not cover the whole screen. You can use fullScreenCover(isPresented:onDismiss:content:) instead. Like this:

.fullScreenCover(isPresented: $converterSheetVisible) {
    Converter()
}
  • Related