yama_HD
yama_HD

Reputation: 568

Swift List looks too big

I have a List in my App. When I click on an Item in the List it opens another List. The First List looks fine, but the second List looks too big. Here is how it looks normal(good):

enter image description here

And here is the List that looks not good:

enter image description here

On the second Picture, the Problems I have are:

Thats the Code, the Code looks the same in both Lists. The only difference is that I used some different variable names in the second one.

    return VStack {
        ZStack {
            NavigationView {

                List {
                    ForEach(zettelArr) { x in
                        NavigationLink(destination: ZettelViewDetails(passedVar: x)) {
                                Text("\(x.name)")
                            }
                    }
                    
                }.navigationBarTitle(alertVariable)
                .navigationBarItems(trailing: Button(action: {
                    
                    alertView()
                    
                    //self.isShown = true
                }) {
                    Image(systemName: "plus")
                })
                
                
                  
            }
            
            //SwiftUIAlertViewWithTextBox(isShown: $isShown, message: $msg, title: $title)
            
        }

    
    }

My goal is, that the second List looks exactly like the Main List.

How is this possible ?

Okay I don't know why the formatting from the pictures are not working, maybe I am just dumb. The first Picture is the MainList that looks like I want it to look and the second one is the list that is formatted differently, even though its quite the same Code.

Upvotes: 1

Views: 196

Answers (1)

Ouail Bellal
Ouail Bellal

Reputation: 1794

You are using NavigationView for both lists view , while only the first one should be inside a NavigationView

Your ZettelViewDetails shouldn't have NavigationView as parent

Example :

Main

NavigationView {
  List {
        ForEach(zettelArr) { x in
          NavigationLink(destination: ZettelViewDetails(passedVar: x)) 
           {
             Text("\(x.name)")
            }
        }
                    
      }.navigationBarTitle(alertVariable)
}

Details

VStack {
 ForEach(zettelArr) { x in
  NavigationLink(destination: ZettelViewDetails(passedVar: x)) {
      Text("\(x.name)")
  }
 }
}

Upvotes: 1

Related Questions