mirror of
https://github.com/UrbanApps/Armchair.git
synced 2026-03-27 11:51:40 +01:00
Working Migration to Swift 3
This commit is contained in:
@@ -141,6 +141,9 @@ extension ViewController {
|
||||
#if os(iOS)
|
||||
// Explicitly disable the storeKit as the default may be true if on iOS 8
|
||||
Armchair.opensInStoreKit(false)
|
||||
|
||||
// This sets a custom tint color (applies only to UIAlertController).
|
||||
Armchair.tintColor(UIColor.brownColor())
|
||||
#endif
|
||||
|
||||
// This sets the Affiliate code you want to use, but is not required.
|
||||
|
||||
@@ -329,6 +329,15 @@ Armchair.usesAnimation() -> Bool
|
||||
Armchair.usesAnimation(usesAnimation: Bool)
|
||||
```
|
||||
|
||||
The `tintColor` configuration specifies a tint color that is applied to UIAlertController when `usesAlertController` is true. Its default value is `nil`, which means that tint color is not customized.
|
||||
|
||||
```swift
|
||||
// GETTER
|
||||
Armchair.tintColor() -> UIColor?
|
||||
// SETTER
|
||||
Armchair.tintColor(tintColor: UIColor?)
|
||||
```
|
||||
|
||||
The `usesAlertController` configuration determines whether or not Armchair uses a UIAlertController when presenting an alert on iOS 8. By default, we do not use it because the reordering of buttons is not possible in the alert controller as of iOS 8.0. It's default value is `false`. Changing this value does not affect iOS 7 at all.
|
||||
|
||||
```swift
|
||||
|
||||
@@ -356,15 +356,16 @@ public func resetDefaults() {
|
||||
Manager.defaultManager.didDisplayAlertClosure = nil
|
||||
Manager.defaultManager.didOptToRateClosure = nil
|
||||
Manager.defaultManager.didOptToRemindLaterClosure = nil
|
||||
|
||||
#if os(iOS)
|
||||
Manager.defaultManager.usesAnimation = true
|
||||
Manager.defaultManager.usesAlertController = Manager.defaultManager.defaultUsesAlertController()
|
||||
Manager.defaultManager.opensInStoreKit = Manager.defaultManager.defaultOpensInStoreKit()
|
||||
Manager.defaultManager.willPresentModalViewClosure = nil
|
||||
Manager.defaultManager.didDismissModalViewClosure = nil
|
||||
#endif
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
Manager.defaultManager.usesAnimation = true
|
||||
Manager.defaultManager.tintColor = nil
|
||||
Manager.defaultManager.usesAlertController = Manager.defaultManager.defaultUsesAlertController()
|
||||
Manager.defaultManager.opensInStoreKit = Manager.defaultManager.defaultOpensInStoreKit()
|
||||
Manager.defaultManager.willPresentModalViewClosure = nil
|
||||
Manager.defaultManager.didDismissModalViewClosure = nil
|
||||
#endif
|
||||
|
||||
Manager.defaultManager.armchairKeyFirstUseDate = Manager.defaultManager.defaultArmchairKeyFirstUseDate()
|
||||
Manager.defaultManager.armchairKeyUseCount = Manager.defaultManager.defaultArmchairKeyUseCount()
|
||||
Manager.defaultManager.armchairKeySignificantEventCount = Manager.defaultManager.defaultArmchairKeySignificantEventCount()
|
||||
@@ -396,11 +397,22 @@ public func resetDefaults() {
|
||||
}
|
||||
|
||||
/*
|
||||
* Set whether or not Armchair uses a UIAlertController when presenting on iOS 8
|
||||
* We prefer not to use it so that the Rate button can be on the bottom and the cancel button on the top,
|
||||
* Something not possible as of iOS 8.0
|
||||
* Default => false
|
||||
*/
|
||||
* Set a tint color to apply to UIAlertController
|
||||
* Default => nil (the default tint color is used)
|
||||
*/
|
||||
public func tintColor() -> UIColor? {
|
||||
return Manager.defaultManager.tintColor
|
||||
}
|
||||
public func tintColor(tintColor: UIColor?) {
|
||||
Manager.defaultManager.tintColor = tintColor
|
||||
}
|
||||
|
||||
/*
|
||||
* Set whether or not Armchair uses a UIAlertController when presenting on iOS 8
|
||||
* We prefer not to use it so that the Rate button can be on the bottom and the cancel button on the top,
|
||||
* Something not possible as of iOS 8.0
|
||||
* Default => false
|
||||
*/
|
||||
public func usesAlertController() -> Bool {
|
||||
return Manager.defaultManager.usesAlertController
|
||||
}
|
||||
@@ -846,12 +858,13 @@ open class Manager : ArmchairManager {
|
||||
// It is my affiliate code. It is better that somebody's code is used rather than nobody's.
|
||||
fileprivate var affiliateCode: String = "11l7j9"
|
||||
fileprivate var affiliateCampaignCode: String = "Armchair"
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
#if os(iOS)
|
||||
fileprivate var usesAnimation: Bool = true
|
||||
fileprivate var tintColor: UIColor? = nil
|
||||
fileprivate lazy var usesAlertController: Bool = self.defaultUsesAlertController()
|
||||
fileprivate lazy var opensInStoreKit: Bool = self.defaultOpensInStoreKit()
|
||||
|
||||
|
||||
fileprivate func defaultOpensInStoreKit() -> Bool {
|
||||
return operatingSystemVersion >= 8
|
||||
}
|
||||
@@ -1197,6 +1210,8 @@ open class Manager : ArmchairManager {
|
||||
print("presentViewController() completed")
|
||||
}
|
||||
}
|
||||
// note that tint color has to be set after the controller is presented in order to take effect (last checked in iOS 9.3)
|
||||
alertView.view.tintColor = tintColor
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user