SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

Related tags

UI SheetPresentation
Overview

SheetPresentation

GitHub code size in bytes GitHub GitHub release (latest by date including pre-releases) GitHub tag (latest by date)

SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

NOT UISheetPresentationController wapped version.

Screenshots

Overview

struct SheetPresentationDemo_Previews: PreviewProvider {
    
    struct SheetPresentationDemo: View {
        @State private var showsSheetPresentation: Bool = false
        
        @State private var hasGrabber: Bool = false
        @State private var hasMaskView: Bool = false
        @State private var isFullScreen: Bool = false
        
        @State private var detents: [SheetPresentationDetent] = DetentsType.m.detents
        
        @State private var detentsType: DetentsType = .m
        enum DetentsType: String {
            case m
            case l
            case ml
            case lm
            
            var detents: [SheetPresentationDetent] {
                switch self {
                case .m:
                    return [.medium]
                case .l:
                    return [.large]
                case .ml:
                    return [.medium, .large]
                case .lm:
                    return [.large, .medium]
                }
            }
        }
        
#if os(iOS)
        private var background = Color(UIColor.systemBackground)
#elseif os(macOS)
        private var background = Color(NSColor.windowBackgroundColor)
#else
        private var background = Color.black
#endif
        
        var body:  some View {
            List {
#if os(watchOS)
                let pickerStyle = WheelPickerStyle()
#else
                let pickerStyle = SegmentedPickerStyle()
#endif
                
                Section(footer: Text("M: medium, L: Large")) {
                    Toggle("Grabber", isOn: $hasGrabber)
                    Toggle("MaskView", isOn: $hasMaskView)
                    Toggle("FullScreen", isOn: $isFullScreen)
                    Picker("Detents Type", selection: $detentsType.animation()) {
                        Text("M").tag(DetentsType.m)
                        Text("L").tag(DetentsType.l)
                        Text("M,L").tag(DetentsType.ml)
                        Text("L,M").tag(DetentsType.lm)
                    }
                    .pickerStyle(pickerStyle)
                }
                Section {
                    Button {
                        showsSheetPresentation = true
                    } label: {
                        Text("Show SheetPresentation")
                    }
                }
            }
            .onChange(of: detentsType) { detentsType in
                detents = detentsType.detents
            }
            .sheetPresentation(isPresented: $showsSheetPresentation,
                               background: background,
                               hasGrabber: hasGrabber,
                               hasMaskView: hasMaskView,
                               isFullScreen: isFullScreen,
                               detents: detents) {
                VStack {
                    background.frame(height: 48)
                    List {
                        Button {
                            showsSheetPresentation = false
                        } label: {
                            Text("Close")
                        }
                        
                        ForEach(0..<100) { index in
                            Text("\(index)")
                        }
                    }
                }
            }
        }
    }
    
    static var previews: some View {
        SheetPresentationDemo()
#if !os(tvOS)
        SheetPresentationDemo()
            .preferredColorScheme(.dark)
#endif
    }
}

Demo App

DEMO

LICENSE

The MIT License (MIT)

You might also like...
SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!
SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

SAHistoryNavigationViewController Support 3D Touch for iOS9!! SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationConto

Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

An UITextView in Swift. Support auto growing, placeholder and length limit.
An UITextView in Swift. Support auto growing, placeholder and length limit.

GrowingTextView Requirements iOS 8.0 or above Installation CocoaPods GrowingTextView is available through CocoaPods. To install it, simply add the fol

A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features ✨ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

A UITextView subclass that adds support for multiline placeholder written in Swift.
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Powerful and easy-to-use vector graphics Swift library with SVG support
Powerful and easy-to-use vector graphics Swift library with SVG support

Macaw Powerful and easy-to-use vector graphics Swift library with SVG support We are a development agency building phenomenal apps. What is Macaw? Mac

🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!
🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction 🔍 Awesome search view, written in Swift 5.0, appears search view like Pinteres

High performance Swift treemap layout engine for iOS and macOS.
High performance Swift treemap layout engine for iOS and macOS.

Synopsis YMTreeMap is a high performance treemap layout engine for iOS and macOS, written in Swift. The input to YMTreeMap is a list of arbitrary numb

Demonstration of LegoArtFilter for iOS/macOS
Demonstration of LegoArtFilter for iOS/macOS

LegoArtFilterDemo Demonstration of LegoArtFilter for iOS/macOS. This project runs on both iOS (14≤) and macOS (11≤). Libraries LegoColors LegoArtFilte

Releases(1.0.2)
Owner
Aben
Full Stack Developer. Swift / SwiftUI / Objective-C / React.js / Node.js / Vue.js / BlockChain / PHP / Go / Docker / K8s
Aben
Pull up controller with multiple sticky points like in iOS Maps

PullUpController Create your own pull up controller with multiple sticky points like in iOS Maps Features Multiple sticky points Landscape support Scr

Mario Iannotta 1.2k Dec 22, 2022
A minimalistic looking banner library for iOS. It supports multiple customizable kinds of Banner types

A minimalistic looking banner library for iOS. It supports multiple customizable kinds of Banner types

Emre Armagan 12 Oct 10, 2022
Super awesome Swift minion for Core Data (iOS, macOS, tvOS)

⚠️ Since this repository is going to be archived soon, I suggest migrating to NSPersistentContainer instead (available since iOS 10). For other conven

Marko Tadić 306 Sep 23, 2022
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

Mohsan Khan 29 Sep 9, 2022
SwiftUI view enabling navigation between pages of content, imitating the behaviour of UIPageViewController for iOS and watchOS

PageView SwiftUI view enabling page-based navigation, imitating the behaviour of UIPageViewController in iOS. Why SwiftUI doesn't have any kind of pag

Kacper Rączy 365 Dec 29, 2022
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

MultiSelectSegmentedControl UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images. Feature

Yonat Sharon 286 Dec 15, 2022
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.

MultiSlider UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizo

Yonat Sharon 326 Dec 29, 2022
A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval.

MultiStepSlider A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval. Th

Susmita Horrow 25 Apr 28, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.

MZFormSheetPresentationController MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding sup

Michał Zaborowski 979 Nov 17, 2022