Skip to content

Improve usability by using content closures#6

Open
timfraedrich wants to merge 4 commits into
QuynhNguyen:masterfrom
timfraedrich:master
Open

Improve usability by using content closures#6
timfraedrich wants to merge 4 commits into
QuynhNguyen:masterfrom
timfraedrich:master

Conversation

@timfraedrich

Copy link
Copy Markdown

This pull request aims to use a more SwiftUI-like approach to content being displayed. With the help of content closures there is no need to update the content manually inside the hosting view.

To express the changes in code, this is how the usability is improved:

Before:

VStack(alignment: .leading) {
    SlidingTabView(
        selection: self.$selectedTabIndex,
        tabs: ["First", "Second"]
    ),
    (selectedTabIndex == 0 ? Text("First View") : Text("Second View")).padding()
    Spacer()
}

After:

SlidingTabView(
    selection: $selectedTab,
    tabs: SlidingTab(title: "Hello") {
        Text("Hello")
    },
    SlidingTab(title: "World!") {
        Text("World!")
    }
)

Note: Because I had problems debugging the code I also edited the Package.swift, to resolve the errors. This ensures a required platform of iOS 13 or above. The README was also updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant