0

This is my code:

struct CardView: View {
    var body: some View {
        Rectangle()
            .fill(Color.red)
            .frame(width: 170, height: 85)
    }
}

struct ListView: View {

    let data = (1...100).map { "Item \($0)" }

    let columns = [
        GridItem(.fixed(170), spacing: 12),
        GridItem(.fixed(170), spacing: 12)
        ]

    var body: some View {
        ScrollView {
            LazyVGrid(columns: columns, spacing: 12) {
                ForEach(data, id: \.self) { category in
                    NavigationLink(destination: ListView()) {
                        CardView()
                    }
                }
            }
        }
        .navigationTitle("Title")
    }
}

struct ContentView: View {

    var body: some View {
        NavigationView {
            ScrollView {
                Text("This is some text")
                ListView()
            }
        }
    }
}

When I'm on the first screen with it's title as large, like this: First screen with large title, then when I tap on a red rectangle, on the second screen the title is also large, that's what I want, like this: Second screen with large title

Now the problem is when I scroll down on the first screen to set its title inline, like this: First screen with inlined title, then when I tap on a red rectangle, on the second screen the title is also inlined, like this: Second screen with inlined tit and I have to scroll up and down to make it appear as large.

What I would like is that whatever (large or inlined) the title on the first screen is, when I tap on a red rectangle the title on the new Screen is large when the view appears. Do you have an idea?

Edward
  • 3
  • 4

0 Answers0