* Add API boilerplate for new calendar and reminder Addresses iOS 17 API changes * Abstract calendar/reminder into event manager * Fix obsolete API mark and revise message * Squashed commit of the following: commit 5ecef99e3b2ef04a2a05b34509e8a449031d92c4 Author: Jevon Mao <woodburyjevonmao@gmail.com> Date: Tue Aug 8 20:13:01 2023 -0400 Add documentation snippet for permission managers commit44e3f41313Author: Jevon Mao <woodburyjevonmao@gmail.com> Date: Mon Aug 7 14:41:46 2023 -0400 Implement custom permission description color (#137) commitf3ed32ce20Author: Jevon Mao <woodburyjevonmao@gmail.com> Date: Mon Aug 7 12:58:42 2023 -0400 Disable stale check CICD * Erase type for custom foreground color * Add NSLog warning deprecated EventKit permissisons * Remove available limitation
62 lines
2.1 KiB
Swift
62 lines
2.1 KiB
Swift
//
|
|
// File.swift
|
|
//
|
|
//
|
|
// Created by Jevon Mao on 3/25/21.
|
|
//
|
|
|
|
import Combine
|
|
|
|
/**
|
|
The schema storage class that coordinates PermissionsSwiftUI's internal functions
|
|
*/
|
|
|
|
@available(iOS 13.0, tvOS 13.0, *)
|
|
public class PermissionSchemaStore: ObservableObject {
|
|
|
|
//MARK: Filtered permission arrays
|
|
var undeterminedPermissions: [PermissionManager] {
|
|
FilterPermissions.filterForShouldAskPermission(for: permissions)
|
|
}
|
|
var interactedPermissions: [PermissionManager] {
|
|
//Filter for permissions that are not interacted
|
|
permissions.filter {
|
|
permissionComponentsStore.getPermissionComponent(for: $0.permissionType).interacted
|
|
}
|
|
}
|
|
var successfulPermissions: [JMResult]?
|
|
var erroneousPermissions: [JMResult]?
|
|
|
|
//MARK: Controls dismiss restriction
|
|
var shouldStayInPresentation: Bool {
|
|
if configStore.restrictDismissal ||
|
|
((permissionViewStyle == .modal && store.restrictModalDismissal) ||
|
|
(permissionViewStyle == .alert && store.restrictAlertDismissal)) {
|
|
// number of interacted permissions equal to number
|
|
// of all permissions means means everything has been
|
|
// interacted with, thus if so, shouldStayInPresentation
|
|
// will be false and dismissal is allowed
|
|
return !(interactedPermissions.count == permissions.count)
|
|
}
|
|
return false
|
|
}
|
|
//MARK: Initialized configuration properties
|
|
var configStore: ConfigStore
|
|
var store: PermissionStore
|
|
@Published var permissions: [PermissionManager]
|
|
var permissionViewStyle: PermissionViewStyle
|
|
@usableFromInline var permissionComponentsStore: PermissionComponentsStore
|
|
init(store: PermissionStore, permissionViewStyle: PermissionViewStyle) {
|
|
self.configStore = store.configStore
|
|
self.permissions = store.permissions
|
|
self.permissionComponentsStore = store.permissionComponentsStore
|
|
self.store = store
|
|
self.permissionViewStyle = permissionViewStyle
|
|
}
|
|
|
|
}
|
|
|
|
@usableFromInline enum PermissionViewStyle {
|
|
case alert, modal
|
|
}
|