Git Product home page Git Product logo

bottombar-swiftui's Introduction

BottomBar-SwiftUI

BottomBar component for SwiftUI inspired by this concept

Preview

Requirements

  • Xcode 11
  • iOS 13

Installation

In Xcode go to File -> Swift Packages -> Add Package Dependency and paste this repo url https://github.com/smartvipere75/bottombar-swiftui then Next -> Branch: master -> Next

Usage

  1. import BottomBar_SwiftUI
  2. Create array of BottomBarItem (maximum 4)
  3. Create @State private var selectedIndex within a View to keep track of BottomBar selected index
  4. Create BottomBarlike BottomBar(selectedIndex: $selectedIndex, items: items)

Example

import SwiftUI
import BottomBar_SwiftUI

let items: [BottomBarItem] = [
    BottomBarItem(icon: "house.fill", title: "Home", color: .purple),
    BottomBarItem(icon: "heart", title: "Likes", color: .pink),
    BottomBarItem(icon: "magnifyingglass", title: "Search", color: .orange),
    BottomBarItem(icon: "person.fill", title: "Profile", color: .blue)
]

struct BasicView: View {
    let item: BottomBarItem

    var detailText: String {
    "\(item.title) Detail"
}

var followButton: some View {
    Button(action: openTwitter) {
        VStack {
            Text("Developed by Bezhan Odinaev")
                .font(.headline)
                .foregroundColor(item.color)

            Text("@smartvipere75")
                .font(.subheadline)
                .foregroundColor(.gray)
        }
    }
}

var destination: some View {
    Text(detailText)
        .navigationBarTitle(Text(detailText))
}

var navigateButton: some View {
    NavigationLink(destination: destination) {
        ZStack {
            Rectangle()
                .fill(item.color)
                .cornerRadius(8)
                .frame(height: 52)
                .padding(.horizontal)

            Text("Navigate")
                .font(.headline)
                .foregroundColor(.white)
        }
    }
}

func openTwitter() {
    guard let url = URL(string: "https://twitter.com/smartvipere75") else {
        return
    }
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

var body: some View {
    VStack {
        Spacer()

        followButton

        Spacer()

        navigateButton
        }
    }
}

struct ContentView : View {
    @State private var selectedIndex: Int = 0

    var selectedItem: BottomBarItem {
        items[selectedIndex]
    }

var body: some View {
        NavigationView {
            VStack {
                BasicView(item: selectedItem)
                    .navigationBarTitle(Text(selectedItem.title))
                BottomBar(selectedIndex: $selectedIndex, items: items)
            }
        }
    }
}

Extra

Check out my app Spendy

Follow me on Twitter for latest updates.

bottombar-swiftui's People

Contributors

smartvipere75 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bottombar-swiftui's Issues

No such module 'BottomBar_SwiftUI'

When I am trying to import BottomBar_SwiftUI, I am getting this error:
No such module 'BottomBar_SwiftUI'

I have already added it to Swift Packages

Setting to avoid seeing the initial animation?

It would be great if there was a parameter that allowed to specify whether initial animation that moves the BottomBar from (0, 0) to it's final resting place didn't happen. IMHO, while cool, it's a bit distracting.

Contributing

Apparently, this small toy/tool got a little bit of attention from the community. Could the owner of the repo please clarify under which conditions pull requests that add or modify features (i.e. not just bug fixes) will be accepted/considered?

BottomBarItem for each View

Hi, I don't know if this is possible but I'm not able to see it in the Wiki.

I have to link every BottomBarItem to an specific View, in the Wiki the only example is a Dynamic view which takes the selected bar item title and place it into the dynamic View.

Is it possible?

Thanks!

Does this still work?

I tested on my device , did not work, I don't know why.

the tab item did not switch

iShot2020-05-07下午08 17 18

xcode version: 11.4.1 (11E503a)

License?

Hello, wonderful work. I don't believe you have chosen a license for this code. If you choose to open source it I suggest using the MIT license. We are interested in integrating some of this, but need your license to be defined.

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.