/TabStack

TabStack implemented by pure SwiftUI

Primary LanguageSwiftMIT LicenseMIT

TabStack

TabStack is a SwiftUI-based library for iOS app development that makes it easy to implement tab-based navigation. It makes it easy to configure multi-tabbed interfaces with just a few lines of code, without the need for complex tab management logic.

Installation

  1. Xcode, select from the menu File > Swift Packages > Add Package Dependency
  2. Specify the URL https://github.com/hyukggun/TabStack

Usage

//
//  TabHStackExamplePage.swift

import SwiftUI
import TabStack

enum MovieSections: CaseIterable {
    case nowPlaying
    case popular
    case upcoming
    
    var title: String {
        switch self {
        case .nowPlaying:
            "Now Playing Movies"
        case .popular:
            "Popular Movies"
        case .upcoming:
            "Upcoming Movies"
        }
    }
}


struct TabHStackExamplePage: View {
    
    let sections = MovieSections.allCases
    
    @State
    var selectedTab: MovieSections? = .nowPlaying
    
    var body: some View {
        TabHStack(tabValues: sections, selectedTab: $selectedTab) { currentTab, isSelected in
            HStack {
                Text(currentTab.title)
                if isSelected {
                    Image(systemName: "checkmark")
                }
            }
        }
    }
}

License

TabStack is distributed under the MIT license. For more information, see the LICENSE file.

Author

hyukggunechoe@gmail.com