Giter Site home page Giter Site logo

bottomsheetui-ios's Introduction

BottomSheetUI

Requirements

BottomSheetUI is a SwiftUI package.

  • macOS 10.12 or Greater
  • iOS 14 or Greater

Installation

Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency

https://github.com/ayoubElhoucine/BottomSheetUI-iOS.git

Usage

  1. Import the package
import BottomSheetUI
  1. Create a bool varaiable that will show and hide the bottom sheet
@State private var showDialog = false
  1. Add .asBottomSheetUI(...) to the view you want your sheet on
YourViewScreen()
    .asBottomSheetUI(
        show: $showDialog, // a state or published bool variable to show and dissmiss the dialog
        content: { EmptyView() } // add your dialog content
    )
  1. Show and dissmiss the dialog:
  • To show the dialog self.showDialog = true
  • To hide the dialog self.showDialog = false

Example

Source Code <>
import SwiftUI
import BottomSheetUI

struct ContentView: View {
    
    @State private var showDialog = false
    
    var body: some View {
        ZStack(alignment: .center) {
            Button {
                showDialog.toggle()
            } label: {
                Text("Show dialog").foregroundColor(.white)
            }
            .padding(16)
            .background(.gray)
        }
        .background(Color.white)
        .asBottomSheetUI(show: $showDialog, content: BottomSheetContent)
    } 
    
    @ViewBuilder
    private func BottomSheetContent() -> some View {
        VStack(spacing: 20) {
            Spacer().frame(height: 0)
            ForEach(0 ..< 6) { index in
                HStack(spacing: 10) {
                    Image(systemName: "list.bullet.circle")
                        .resizable()
                        .frame(width: 20, height: 20)
                        .foregroundColor(.white)
                    Text("Menu item \(index + 1)").foregroundColor(.white)
                    Spacer()
                }
            }
            Spacer().frame(height: 0)
        }
        .padding(20)
        .background(.black)
        .clipShape(RoundedRectangle(cornerRadius: 16))
        .padding(20)
        .shadow(radius: 5)
    }
}

Contributions

Feel free to contribute via fork/pull request to main branch. If you want new feature or report a bug then start a new issue.

Author

ELHOUCINE AYOUB

bottomsheetui-ios's People

Contributors

ayoubelhoucine avatar rmehdid avatar

Stargazers

Elhadj Hocine avatar  avatar YoucefHedibel avatar Mohamed Abdelhakim Hacine  avatar jinhu avatar

Watchers

 avatar

Forkers

rmehdid

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.