• Stars
    star
    343
  • Rank 123,371 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ฑ TabBar โ€“ highly customizable tab bar (i.e. TabView) for your SwiftUI application.

TabBar

SwiftUI standard TabView component is not so flexible and to customize it you have to modify appearance proxy of UITabBar or implement your own one from scratch. The goal of this library is to solve this problem.

Table of contents

Requirements

  • SwiftUI
  • iOS 13.0 or above

Installation

TabBar is available through Swift Package Manager

Swift Package Manager

  • In Xcode select:

    File > Swift Packages > Add Package Dependency...
    
  • Then paste this URL:

    https://github.com/onl1ner/TabBar.git
    

Usage

To start using TabBar you have to create an enum which will implement Tabbable protocol:

enum Item: Int, Tabbable {
    case first = 0
    case second
    case third
    
    var icon: String {
        switch self {
            case .first:  // Name of icon of first item.
            case .second: // Name of icon of second item.
            case .third:  // Name of icon of third item.
        }
    }
    
    var title: String {
        switch self {
            case .first:  // Title of first item.
            case .second: // Title of second item.
            case .third:  // Title of third item.
        }
    }
}

After that you will be able to create TabBar instance:

struct ContentView: View {
    @State private var selection: Item = .first
    @State private var visibility: TabBarVisibility = .visible

    var body: some View {
        TabBar(selection: $selection, visibility: $visibility) {
            Text("First")
                .tabItem(for: Item.first)
            
            Text("Second")
                .tabItem(for: Item.second)
            
            Text("Third")
                .tabItem(for: Item.third)
        }
        .tabBar(style: CustomTabBarStyle())
        .tabItem(style: CustomTabItemStyle())
    }
}

After these actions tab bar with default style will be created.

Customization

TabBar component is highly customizable. This is achieved by introducing TabBarStyle and TabItemStyle protocols. By implementing each of the protocol you will be able to build your custom tab bar. NOTE that TabBar automaticaly pushes down to bottom any of tab bar styles.

After creating your custom styles you may inject them to your tab bar by using tabBar(style:) and tabItem(style:) functions. Here is the showcase of default style and one of the examples of what you can achieve by customizing tab bar:

Contribution

If you struggle with something feel free to open an issue. Pull requests are also appreciated.

License

TabBar is under the terms and conditions of the MIT license.

MIT License

Copyright (c) 2021 Tamerlan Satualdypov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

swiftui-mv-architecture

A more natural architectural approach on writing SwiftUI applications
45
star
2

STTextView

๐Ÿ“ STTextView is a light-weight library that adds a placeholder to the UITextView.
Swift
41
star
3

Hands

๐Ÿ– Memory game with hand gesture recognition that will keep your brain in a good shape!
Swift
39
star
4

ios-mvp-template

๐Ÿ›  A flexible and easy template created to speed up the development of your iOS application based on the MVP pattern.
Swift
25
star
5

awesome-aitu

๐Ÿ“„ A collaborative list of AITU student's projects.
24
star
6

Snitch

๐Ÿ” Snitch is a handy library to access useful information about your application from the Home Screen.
Swift
18
star
7

BarcodeScanner

๐Ÿ” Simple & easy application that helps you to scan both EAN8 and EAN13 barcodes.
Swift
17
star
8

STDiscreteSlider

๐ŸŽš๏ธ STDiscreteSlider โ€“ slider which allows user to choose value only from predefined set of data.
Swift
16
star
9

Java-Design-Patterns

Creational design patterns written in Java
Java
11
star
10

CovidKazakhstan

๐Ÿฆ  Application to track number of coronavirus COVID-19 cases in Kazakhstan.
Swift
11
star
11

Morse

๐Ÿ’ฌ English to Morse ะกode translator written in SwiftUI for WWDC Swift Student Challenge '22. Accepted submission.
Swift
10
star
12

Weather

๐ŸŒค Simple weather GUI-application written in Java using JavaFX.
Java
9
star
13

Java-IT-Company-CLI

Simple CLI application written in Java
Java
8
star
14

database-social-network

ICT project for Final Examination
6
star
15

onl1ner

4
star
16

cryygle

Python
4
star
17

NetworkKit

Swift
3
star
18

eth-parser

Python
2
star
19

weather-ios

Swift
2
star
20

python-permutations

Python
2
star
21

python-coingecko

Python
2
star
22

python-simple-flask

Python
2
star
23

onl1ner.github.io

Your time will come
2
star
24

musical-octo-eureka

My brand-new repository!
2
star
25

python-crypto-scraper

Python
1
star
26

django-image-classifier

Web-application that classifies given image by using Convolutional Neural Network
Python
1
star
27

todo-django

Python
1
star