Skip to content

If there are less than two images to be displayed, nothing will be displayed. #67

@yamanetaisei

Description

@yamanetaisei

Hi all, I have found a bug.

When using WaterdallGrid, if there are less than 2 data to display, nothing will be displayed.

Here is a piece of source code that reproduces the bug at my end

ScrollView {
                        WaterfallGrid(dataArray, id: \.self) { file in
                            VStack {
                                if let post = viewModel.posts.first(where: { $0.fileIds.contains(file.id) }) {
                                    NavigationLink(destination: ImageDetailView(item: post, file: file)) {
                                        // View to display images.
                                        ImageGridItem(url: file.url!)
                                    }
                                }
                            }
                        }
                    }
import SwiftUI
import Kingfisher

// View to display images.
struct ImageGridItem: View {
    
    private var url: String
    
    init(url: String) {
        self.url = url
    }
    
    var body: some View {
        KFImage.url(URL(string: url))
            .resizable()
            .placeholder{
                RoundedRectangle(cornerRadius: 30)
                    .fill(Color(0xe6e6e6))
            }
            .scaledToFit()
            .clipped()
            .cornerRadius(5)
            .aspectRatio(contentMode: .fit)
    }
}
3 or more less than two data

Please some advice or fix

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