0

I'm trying to make it so when I click on the username button a new view pops up that's full screen with what I've created for the username view. I've tried navigationView but I don't like having the title show up on the main view. I've tried using sheets which works but it doesn't cover the full screen. Is there any way to go between the different views that I have like MainScreen.swift, Username.swift, and Data.swift Thanks!

//Creating booleans to show sheets of different menus
@State var showUser: Bool = false
@State var showData: Bool = false


var body: some View {
    //Making
    ScrollView(.vertical){
        VStack{
            //User button
           
                Button(action: {
                    withAnimation{
                        self.showUser = true
                    }
                })
                {
                    // Creating Hstack for name of button and image
                    HStack{
                        //Text of button
                        Text("Username")
                            .font(.custom("Futura", size: 17))
                            .fontWeight(.ultraLight)
                        //Image of button
                        Image(systemName: "person.crop.circle.fill")
                        
                    } //Hstack
                        .aspectRatio(contentMode: .fit)
                        .frame(minWidth: 0, maxWidth: 300)
                        .padding()
                        .background(RoundedRectangle(cornerRadius: 10).stroke(Color.blue, lineWidth: 2))
                        .padding(.top, 5)
                        .padding(.bottom, 5)
                    
                    //username button settings
                } //user button
        
        
        
                //Data button
                if showData {
                    Data()
                        .animation(.spring())
                        .transition(.slide)
                }  else {
                Button(action:{
                    withAnimation{
                    self.showData = true
                    }
                    
                })
                {
                    // Creating Hstack for data and image
                    HStack{
                        // Text of button
                        Text("Data")
                            .font(.custom("Futura", size: 17))
                            .fontWeight(.ultraLight)
                        // Image of button
                        Image(systemName: "chart.pie")
                        
                    } //Hstack
                        .padding(.top, 180.0)
                        .padding(.bottom, 2)
                        .aspectRatio(contentMode: .fit)
                        .frame(minWidth: 0, maxWidth: 300)
                        .frame(minHeight: 0, maxHeight: 200)
                        .padding()
                        .background(RoundedRectangle(cornerRadius: 10).stroke(Color.blue, lineWidth: 2))
                        .padding(.bottom, 50)
                    //Data button settings
                } //data button
            }//showing data sheet
        
mbarab2
  • 1
  • 4
  • Consider this solution [SwiftUI Animation Slide In and Out](https://stackoverflow.com/questions/63223542/swiftui-animation-slide-in-and-out/63223600#) or [How do I add Animations to Transitons between custom NavigationItems](https://stackoverflow.com/a/59087574/12299030) – Asperi Aug 17 '20 at 15:10
  • Thank you I'll check those out! – mbarab2 Aug 17 '20 at 15:19

0 Answers0