From 91c75340567793d9737aa16a9b0f4044db1f87cf Mon Sep 17 00:00:00 2001 From: Jevon Mao Date: Fri, 3 Sep 2021 09:01:18 -0700 Subject: [PATCH] Fix where dialog don't have restrictDismissal configuration (#98) --- .../Store/PermissionSchemaStore.swift | 5 ++++- .../SwiftUI/Dialog-style/DialogStyleViews.swift | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/CorePermissionsSwiftUI/Store/PermissionSchemaStore.swift b/Sources/CorePermissionsSwiftUI/Store/PermissionSchemaStore.swift index 3118a9f..a268131 100644 --- a/Sources/CorePermissionsSwiftUI/Store/PermissionSchemaStore.swift +++ b/Sources/CorePermissionsSwiftUI/Store/PermissionSchemaStore.swift @@ -32,7 +32,10 @@ public class PermissionSchemaStore: ObservableObject { if configStore.restrictDismissal || ((permissionViewStyle == .modal && store.restrictModalDismissal) || (permissionViewStyle == .alert && store.restrictAlertDismissal)) { - //Empty means all permissions interacted, so should no longer stay in presentation + // 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 diff --git a/Sources/CorePermissionsSwiftUI/SwiftUI/Dialog-style/DialogStyleViews.swift b/Sources/CorePermissionsSwiftUI/SwiftUI/Dialog-style/DialogStyleViews.swift index 3e44e5d..5d072b3 100644 --- a/Sources/CorePermissionsSwiftUI/SwiftUI/Dialog-style/DialogStyleViews.swift +++ b/Sources/CorePermissionsSwiftUI/SwiftUI/Dialog-style/DialogStyleViews.swift @@ -113,8 +113,15 @@ public extension View { */ - func JMAlert(showModal: Binding, for permissions: [PermissionType.PermissionManager], autoDismiss: Bool?=nil, autoCheckAuthorization: Bool?=nil) -> some CustomizableView { - initializeJMAlert(showModal: showModal, for: permissions, autoDismiss: autoDismiss, autoCheckAuthorization: autoCheckAuthorization) + func JMAlert(showModal: Binding, for permissions: [PermissionType.PermissionManager], + restrictDismissal: Bool?=nil, + autoDismiss: Bool?=nil, + autoCheckAuthorization: Bool?=nil) -> some CustomizableView { + initializeJMAlert(showModal: showModal, + for: permissions, + autoDismiss: autoDismiss, + autoCheckAuthorization: autoCheckAuthorization, + restrictDismissal: restrictDismissal) } /**