Coder Social home page Coder Social logo

mmmagiccoder / tabfinity Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 2.0 72 KB

πŸ“±β™ΎοΈ Tabfinity is highly adaptive and customizable iOS TabView / Tab bar for your SwiftUI application.

License: MIT License

Swift 100.00%
bar custom-tab-bar custom-tab-view custom-tabbar custom-tabview ios library swift swift-package-manager swift-ui swiftui tab tab-bar tabbar tabview uitabbar uitabbarcontroller view xcode

tabfinity's Introduction

Tabfinity

This library aims to enhance the flexibility of the standard TabView component in SwiftUI. Instead of being restricted by the limitations of the default TabView, users can now effortlessly customize their tab bars with a variety of stylish options provided by this library. Say goodbye to the hassle of modifying appearance proxies or building custom tab bars from scratch – with this solution, you'll have access to a range of sleek and impressive TabBar styles to elevate your projects.

Table of contents

Requirements

  • SwiftUI
  • iOS 14.0 or above

Installation

You can access Tabfinity through Swift Package Manager.

Swift Package Manager (SPM)

In xcode select:

File > Swift Packages > Add Package Dependency...

Then paste this URL:

https://github.com/MMMagicCoder/Tabfinity.git

Usage

To start using the Tabfinity, you need to define an enumeration that conforms to the Finitable protocol:

enum Item: Int, Finitable {
    case home, favorites, profile
    
    var icon: String {
        switch self {
        case .home: return "house"
        case .favorites: return "heart"
        case .profile: return "person"
        }
    }
    
    var title: String {
        switch self {
        case .home: return "Home"
        case .favorites: return "Favorites"
        case .profile: return "Profile"
        }
    }
    
    var color: Color {
        switch self {
        case .home: return Color.red
        case .favorites: return Color.blue
        case .profile: return Color.green
        }
    }
}

Afterward, you will be able to instantiate a Tabfinity:

struct ContentView: View {
    @State private var selection: Item = .home
    
    var body: some View {
        Tabfinity(selection: $selection) {
            Text("First Tab")
                .tabfinityItem(for: Item.home)
            
            Text("Second Tab")
                .tabfinityItem(for: Item.favorites)
            
            Text("Third Tab")
                .tabfinityItem(for: Item.profile)
        }
        .tabfinityContainer(style: DefaultContainerStyle())
        .tabfinityItem(style: DefaultItemStyle())
    }
}

Following these steps, a tabfinity with the default style will be generated.

Customization

The Tabfinity can be changed a lot. You can make it look however you want by using TabfinityContainerStyle and TabfinityItemStyle. You can easily adjust the size and position of items using the TabfinityItemSize class. This class helps you find out how big items are and where they are placed, so you can customize them exactly how you want. These let you create your own unique tab bar designs. When you make custom styles, the tabfinity automatically puts them at the bottom. Explore the examples provided in this package to learn how to customize your tab bar effectively with Tabfinity.

Once you've made your custom styles, you can easily use them in your tabfinity. Here's an example of what the default tab bar looks like, and some custom design you could use or make:

Show cases

Contribution

If you encounter any challenges, please feel free to open an issue. Additionally, we welcome and appreciate pull requests for any improvements or contributions.

License

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

MIT License

Copyright (c) 2024 Mohammad Mahdi Moayeri

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.

tabfinity's People

Contributors

mmmagiccoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.