Skip to content

Latest commit

 

History

History
153 lines (110 loc) · 3.99 KB

README.md

File metadata and controls

153 lines (110 loc) · 3.99 KB

PermissionSheets

Swift 5.5+ iOS 16+ SwiftUI 3+

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

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 NotificationPermissionSheet

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

Location Permission

import SwiftUI
import LocationPermissionSheet

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]


Inspiration + TODO.

Dear Apple designers, the designs are really nice, enough to have inspired me, but your design lacks consistency.

Wallet app Wallet transit Apple Store app Reminders app App Store app Apple Music