0

I'm trying to compose a view using a VStack that nests a HStack and a grid (https://github.com/spacenation/swiftui-grid). The expected outcome is that the HStack and all grid items should render. The actual outcome is that only one item of the grid renders. But when I change the HStack to VStack.The view renders as expected. Pls note that the grid renders a Geometry Reader which nests a ZStack Here's my code and an image. The blue frame in the image is the grid. It shrinked in height.

    ScrollView {
        VStack(spacing: 0) {
                HStack  {
                        ImageView(urlString: featuredItem.imageUrl, id: featuredItem.id)
                            VStack( alignment: .leading, spacing: 0) {
                                Text(featuredItem.title)
                                    .padding(.vertical, 16)
                                    .font(.custom("AbrilFatface-Regular", size: 48))
                                    .fixedSize(horizontal: false, vertical: true)
                                Rectangle()
                                    .fill(Color.red)
                                    .frame(width: 96, height: 8)
                                Text(featuredItem.quote)
                                    .font(.custom("Rubik-Regular", size: 14))
                                    .padding(.top, 16)
                                    .padding(.bottom, 32)
                                HStack {
                                    ImageView(urlString: featuredItem.storeAvatarUrl, id: 
                                        featuredItem.id, width: 32, height: 32, isClipped: true)
                                    Text(featuredItem.storeName)
                                        .font(.custom("Rubik-Medium", size: 14))
                                }

                            }
                            .frame(width: 246)

                }
                 .overlay(
                        GeometryReader { proxy in
                            VStack {
                                Text(self.featuredItem.price)
                                    .frame(width: 72, height: 48)
                            }
                            .frame(width: proxy.size.width, height: proxy.size.height, 
                            alignment: .topTrailing)
                        }
                )
                ShrineGrid(columns: 2, rowsHeight: .fixed(250))
        }
           
       }.edgesIgnoringSafeArea(.all)
        

The blue frame shows the grid.It shrinked in height

Community
  • 1
  • 1
Jobie J
  • 117
  • 5

0 Answers0