Skip to content

Can we have maxWidth infinity in side the Vflow? #36

@NishaTS19

Description

@NishaTS19

@tevelee

Here i am using VFlow and in that i have Header, now i want to expand header as much as it can, for that if i use maxWidth but it's not working so how can i do?

right now my Rectangle has fixed width but in real scenario it's not.

struct ContentView: View {

private var rectDetails: [(CGFloat, Color)] = [
    (400, .green),
    (100, .pink),
    (100, .blue),
    (100, .pink),
    (150, .cyan),
    (400, .purple),
    (150, .yellow),
    (200, .orange),
    (350, .red),
    (200, .red),
]

private var gridItemLayout = [GridItem(.adaptive(minimum: 50),
                                       spacing: 20,
                                       alignment: .top)
]

var body: some View {
    VFlow {
        ForEach(0 ..< rectDetails.count, id: \.self) { index in
            let data = rectDetails[index]
            VStack(alignment: .leading) {
                Text("This is Header!")
                // .frame(maxWidth: .infinity, alignment: .top)
                    .background(.pink)
                Rectangle()
                    .fill(data.1)
                    .frame(width: 200, height: data.0)
                    .background(data.1)
                    .cornerRadius(10)
                    .overlay {
                        Text("\(index)")
                            .padding(10)
                            .background(.white)
                            .clipShape(.circle)
                    }
            }
            .frame(alignment: .top)
        }
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions