Swiftpack.co - Vong3432/HalfModal as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Vong3432.
Vong3432/HalfModal v1.2.0
A reusable modal component for SwiftUI that can be half/full height and support necessarily properties from the UISheetPresentationController.
⭐️ 1
🕓 5 weeks ago
iOS
.package(url: "https://github.com/Vong3432/HalfModal.git", from: "v1.2.0")

HalfModal

A reusable modal component for SwiftUI that can be half/full height and support necessarily properties from the UISheetPresentationController.

Features

  • Customise modal height (support multiple detents).
  • Customise modal corner radius.
  • Customise dimmed area.
  • Default detent from array of detents.

Currently supported properties from UISheetPresentationController

To avoid confusion, most of the naming of the property variables will be the same with the properties in UISheetPresentationController, unless there is a better naming to replace it.

  • detents
  • selectedDetentIdentifier
  • largestUndimmedDetentIdentifier
  • preferredCornerRadius (cornerRadius in HalfModal)
  • prefersGrabberVisible (showGrabber in HalfModal)
  • prefersScrollingExpandsWhenScrolledToEdge
  • prefersEdgeAttachedInCompactHeight
  • widthFollowsPreferredContentSizeWhenEdgeAttached

Demo

Half height modal only

HalfModal(
    content: { DetailView() }, 
    isPresented: $show,
    detents: [.medium()],
    )

Half + Full height modal only

HalfModal(
    content: { DetailView() }, 
    isPresented: $show,
    detents: [.medium(), .large()],
    )

Half + Full height modal and other features from UISheetPresentationController.

HalfModal(
    content: { ... }, 
    isPresented: $presented, 
    detents: [.medium(), .large()], 
    selectedDetentIdentifier: .large, // default detent for the modal
    cornerRadius: 50.0, 
    showGrabber: true) 

Usage with modifiers

    NavigationView {
        VStack {
            Button("Tap") { presented = true }
        }
    }
    .sheet(
        isPresented: $presented,
        detents: [.medium(),.large()],
        selectedDetentIdentifier: .large
        ,
        cornerRadius: 50.0,
        showGrabber: true, 
        content: {
            Text("Detail")
        }
    )

GitHub

link
Stars: 1
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics