Giter Site home page Giter Site logo

sheetui's Introduction

SheetUI

example workflow

Easily present SwiftUI content in a bottom sheet fit for the content it's presenting. No more worrying about SwiftUI hierarchy. SheetUI provides a ViewModifier for presenting content that will always be presented above all SwiftUI views.

Features

  • iPhone and iPad support
  • isModalInPresentation support
  • Presents over tab bar, regardless of UIKit or SwiftUI tab layout
  • Adapts to SwiftUI content size, with customizable top offset
  • Swipe to dismiss
  • Tap outter content to dismiss

Installation

iphone ipad

Requirements

  • iOS 14.0+

Installation via Swift Package Manager

In Xcode click on your project in the Project Navigator pane. Select your project and then click on the Package Depdendencies tab. Click on the plus button and add this via searching for "[email protected]:tguidon/SheetUI.git".

Example

import SheetUI

/// `SheetItem` is defined as
/// public protocol SheetItem: Equatable, Identifiable { }

enum DisplayItem: Int, SheetItem {
    var id: Int { return self.rawValue }

    case menu
    case settings
}

struct ContentView: View {
    @State private var isPresented: Bool = false
    @State private var selectedItem: DisplayItem? = nil
    
    var body: some View {
        VStack {
            Text("Hello, world!")
                .padding()
            Button {
                self.isPresented = true
                // Can also set Equatable type, helpful with enums
                // self.selectedItem = DisplayItem.settings
            } label: {
                Text("Present")
            }
        }
        .presentSheet(
            isPresented: $isPresented
        ) {
            Text("Hello, sheet world!").padding()
        }
        .presentSheet(
            selectedItem: $selectedItem,
            style: .standard,
            onDismiss: nil
        ) { item in
            switch item {
            case .menu:
                Text("This is the menu!!!").padding()
            case .settings:
                Text("Settings!!!").padding()
            }
        }
    }
}

sheetui's People

Contributors

tguidon 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.