PermissionSheets

1.0.0

A SwiftUI package for elegant, customizable permission request sheets with animated previews for notifications and location services.
Aayush9029/PermissionSheets

What's New

PermissionSheets

A SwiftUI package for elegant, customizable permission request sheets with animated previews for notifications and location services.

Swift 5.5+ iOS 16+ SwiftUI 3+

Features

  • 🎨 Beautiful pre-built permission request sheets
  • 🔔 Support for Notification and Location permissions
  • ✨ Animated native-looking preview screens
  • 🎯 Customizable titles and descriptions
  • ⚡️ Simple ViewModifier-based implementation
  • 📱 iOS-style design that matches system UI
  • 🔄 Configurable display frequency (immediate, once, etc.)

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/yourusername/PermissionSheets.git", from: "1.0.0")
]

Or add it directly in Xcode:

  1. Go to File > Add Packages
  2. Paste the repository URL
  3. Click Add Package

Quick Start

Notification Permission

import SwiftUI
import PermissionSheets

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
            .askNotificationPermission()
    }
}

Location Permission

import SwiftUI
import PermissionSheets

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
            .askLocationPermission()
    }
}

Customization

Custom Titles and Descriptions

Text("Hello, World!")
    .askNotificationPermission(
        config: PermissionConfig(
            title: "Stay Updated!",
            description: "Enable notifications to never miss important updates"
        )
    )

Display Frequency

Control how often the permission sheet appears:

Text("Hello, World!")
    .askLocationPermission(
        config: PermissionConfig(
            displayFrequency: .once,
            title: "Location Access",
            description: "We need your location to show nearby places"
        )
    )

Available display frequencies:

  • .immediate: Shows every time
  • .once: Shows only once
  • .daily: Shows once per day
  • .weekly: Shows once per week

Force Display

Force the permission sheet to show regardless of previous user interaction:

Text("Hello, World!")
    .askNotificationPermission(
        config: PermissionConfig(forceShow: true)
    )

Requirements

  • iOS 16.0+
  • Swift 5.5+
  • SwiftUI 3.0+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by native iOS permission requests
  • Built with SwiftUI
  • Created with ❤️

Author

[Aayush Pokharel]

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Jan 16 2025 14:41:51 GMT-1000 (Hawaii-Aleutian Standard Time)