-1

I am trying to do something like this:

public struct FlowHStack<Data, ID, Content>: View where Data: RandomAccessCollection, Content: View, ID: Hashable {

    let data: Data
    let dataId: KeyPath<Data.Element, ID>
    let content: (Data.Element) -> Content
    let spacing: CGFloat
    
    private let alignment: VerticalAlignment
    
    public var body: some View {
        if #available(iOS 16.0, *) {
            /*HorizontalFlowLayout(spacing: spacing, alignment: alignment) {
             ForEach(data, id: dataId, content: content)
             }*/
            //legacyBody
            contentFactory()
        } else {
            LegacyHorizontalFlowLayout(spacing: spacing) {
                ForEach(data, id: dataId, content: content)
            }
        }
    }
    
    private func contentFactory() -> some View where Data.Element == ID, Data.Element: Hashable {
        LegacyHorizontalFlowLayout(spacing: spacing) {
            ForEach(data, id: dataId, content: content)
        }
    }
}
HangarRash
  • 7,314
  • 5
  • 5
  • 32
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143

0 Answers0