mirror of
https://github.com/UrbanApps/Armchair.git
synced 2026-07-16 17:51:18 +02:00
Add custom dialog closure
Added an optional closure to allow developers to present their own dialog once all criteria for the dialog are filled. Passes closures for 'Rate', 'Remind', and 'No thanks'
This commit is contained in:
committed by
GitHub
parent
24b4f4ab8f
commit
61f124d82c
@@ -357,6 +357,8 @@ public func resetDefaults() {
|
|||||||
Manager.defaultManager.didOptToRateClosure = nil
|
Manager.defaultManager.didOptToRateClosure = nil
|
||||||
Manager.defaultManager.didOptToRemindLaterClosure = nil
|
Manager.defaultManager.didOptToRemindLaterClosure = nil
|
||||||
|
|
||||||
|
Manager.defaultManager.customAlertClosure = nil
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
Manager.defaultManager.usesAnimation = true
|
Manager.defaultManager.usesAnimation = true
|
||||||
Manager.defaultManager.tintColor = nil
|
Manager.defaultManager.tintColor = nil
|
||||||
@@ -562,6 +564,7 @@ public func rateApp() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public typealias ArmchairClosure = () -> ()
|
public typealias ArmchairClosure = () -> ()
|
||||||
|
public typealias ArmchairClosureCustomAlert = (_ rateAppClosure: ArmchairClosure, _ remindLaterClosure: ArmchairClosure, _ noThanksClosure: ArmchairClosure) -> ()
|
||||||
public typealias ArmchairAnimateClosure = (Bool) -> ()
|
public typealias ArmchairAnimateClosure = (Bool) -> ()
|
||||||
public typealias ArmchairShouldPromptClosure = (ArmchairTrackingInfo) -> Bool
|
public typealias ArmchairShouldPromptClosure = (ArmchairTrackingInfo) -> Bool
|
||||||
public typealias ArmchairShouldIncrementClosure = () -> Bool
|
public typealias ArmchairShouldIncrementClosure = () -> Bool
|
||||||
@@ -920,6 +923,8 @@ open class Manager : ArmchairManager {
|
|||||||
var didOptToRateClosure: ArmchairClosure?
|
var didOptToRateClosure: ArmchairClosure?
|
||||||
var didOptToRemindLaterClosure: ArmchairClosure?
|
var didOptToRemindLaterClosure: ArmchairClosure?
|
||||||
|
|
||||||
|
var customAlertClosure: ArmchairClosureCustomAlert?
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
var willPresentModalViewClosure: ArmchairAnimateClosure?
|
var willPresentModalViewClosure: ArmchairAnimateClosure?
|
||||||
var didDismissModalViewClosure: ArmchairAnimateClosure?
|
var didDismissModalViewClosure: ArmchairAnimateClosure?
|
||||||
@@ -1184,6 +1189,12 @@ open class Manager : ArmchairManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func showRatingAlert() {
|
fileprivate func showRatingAlert() {
|
||||||
|
if let customClosure = customAlertClosure {
|
||||||
|
customClosure({[weak self] in self?._rateApp()}, {[weak self] in self?.remindMeLater()}, {[weak self] in self?.dontRate()})
|
||||||
|
if let closure = self.didDisplayAlertClosure {
|
||||||
|
closure()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if (operatingSystemVersion >= 8 && usesAlertController) || operatingSystemVersion >= 9 {
|
if (operatingSystemVersion >= 8 && usesAlertController) || operatingSystemVersion >= 9 {
|
||||||
/* iOS 8 uses new UIAlertController API*/
|
/* iOS 8 uses new UIAlertController API*/
|
||||||
@@ -1263,6 +1274,8 @@ open class Manager : ArmchairManager {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
// MARK: PRIVATE Alert View / StoreKit Delegate Methods
|
// MARK: PRIVATE Alert View / StoreKit Delegate Methods
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user