Skip to content

Demo project showing SwiftUI's new "subViewsOf" APIs

License

Notifications You must be signed in to change notification settings

danielctull-forks/XForm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XForm

An alternative "Form" API for SwiftUI highlighting Swift's new 'ForEach(subviewsOf:)' and 'Group(subViewsOf:)' APIs

further description forthcoming

struct XForm <Content>: View where Content: View {
    let content: Content

    init(@ViewBuilder content: () -> Content) {
        self.content = content()
    }

    var body: some View {
        ScrollView(.vertical) {
            VStack {
                Group(subviewsOf: content) { subviews in
                    ForEach(subviews.dropLast()) { subview in
                        subview
                        Divider()
                    }
                    subviews.last
                }
            }
            .padding([.leading, .trailing])
        }
    }
}

Screenshot

alt text

About

Demo project showing SwiftUI's new "subViewsOf" APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%