Skip to content

Commit

Permalink
Trim whitespace-only lines
Browse files Browse the repository at this point in the history
  • Loading branch information
delba committed Aug 17, 2019
1 parent 9986c58 commit e48d20f
Show file tree
Hide file tree
Showing 24 changed files with 300 additions and 303 deletions.
128 changes: 64 additions & 64 deletions Source/Permission.swift

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions Source/PermissionAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,55 +25,55 @@
open class PermissionAlert {
/// The permission.
fileprivate let permission: Permission

/// The status of the permission.
fileprivate var status: PermissionStatus { return permission.status }

/// The domain of the permission.
fileprivate var type: PermissionType { return permission.type }

fileprivate var callbacks: Permission.Callback { return permission.callbacks }

/// The title of the alert.
open var title: String?

/// Descriptive text that provides more details about the reason for the alert.
open var message: String?

/// The title of the cancel action.
open var cancel: String? {
get { return cancelActionTitle }
set { cancelActionTitle = newValue }
}

/// The title of the settings action.
open var settings: String? {
get { return defaultActionTitle }
set { defaultActionTitle = newValue }
}

/// The title of the confirm action.
open var confirm: String? {
get { return defaultActionTitle }
set { defaultActionTitle = newValue }
}

fileprivate var cancelActionTitle: String?
fileprivate var defaultActionTitle: String?

var controller: UIAlertController {
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)

let action = UIAlertAction(title: cancelActionTitle, style: .cancel, handler: cancelHandler)
controller.addAction(action)

return controller
}

internal init(permission: Permission) {
self.permission = permission
}

internal func present() {
DispatchQueue.main.async {
UIApplication.shared.presentViewController(self.controller)
Expand All @@ -88,7 +88,7 @@ open class PermissionAlert {
internal class DisabledAlert: PermissionAlert {
override init(permission: Permission) {
super.init(permission: permission)

title = "\(permission) is currently disabled"
message = "Please enable access to \(permission) in the Settings app."
cancel = "OK"
Expand All @@ -98,34 +98,34 @@ internal class DisabledAlert: PermissionAlert {
internal class DeniedAlert: PermissionAlert {
override var controller: UIAlertController {
let controller = super.controller

let action = UIAlertAction(title: defaultActionTitle, style: .default, handler: settingsHandler)
controller.addAction(action)

if #available(iOS 9.0, *) {
controller.preferredAction = action
}

return controller
}

override init(permission: Permission) {
super.init(permission: permission)

title = "Permission for \(permission) was denied"
message = "Please enable access to \(permission) in the Settings app."
cancel = "Cancel"
settings = "Settings"
}

@objc func settingsHandler() {
NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification)
callbacks(status)
}

private func settingsHandler(_ action: UIAlertAction) {
NotificationCenter.default.addObserver(self, selector: .settingsHandler, name: UIApplication.didBecomeActiveNotification)

if let URL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.openURL(URL)
}
Expand All @@ -135,26 +135,26 @@ internal class DeniedAlert: PermissionAlert {
internal class PrePermissionAlert: PermissionAlert {
override var controller: UIAlertController {
let controller = super.controller

let action = UIAlertAction(title: defaultActionTitle, style: .default, handler: confirmHandler)
controller.addAction(action)

if #available(iOS 9.0, *) {
controller.preferredAction = action
}

return controller
}

override init(permission: Permission) {
super.init(permission: permission)

title = "\(Bundle.main.name) would like to access your \(permission)"
message = "Please enable access to \(permission)."
cancel = "Cancel"
confirm = "Confirm"
}

fileprivate func confirmHandler(_ action: UIAlertAction) {
permission.requestAuthorization(callbacks)
}
Expand Down
Loading

0 comments on commit e48d20f

Please sign in to comment.