2018-10-26 01:54:07 +00:00
|
|
|
//
|
|
|
|
// UIAlertController+Visibility.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 10/25/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import Pachyderm
|
|
|
|
|
|
|
|
extension UIAlertController {
|
|
|
|
|
|
|
|
convenience init(currentVisibility: Status.Visibility?, completion: @escaping (Status.Visibility?) -> Void) {
|
|
|
|
self.init(title: "Post Visibility", message: nil, preferredStyle: .actionSheet)
|
|
|
|
|
|
|
|
for visibility in Status.Visibility.allCases {
|
|
|
|
let action = UIAlertAction(title: visibility.displayName, style: .default) { (_) in
|
|
|
|
completion(visibility)
|
|
|
|
}
|
|
|
|
if visibility == currentVisibility {
|
|
|
|
action.setValue(true, forKey: "checked")
|
|
|
|
}
|
2019-06-14 00:53:17 +00:00
|
|
|
action.setValue(UIImage(systemName: visibility.imageName), forKey: "image")
|
2018-10-26 01:54:07 +00:00
|
|
|
addAction(action)
|
|
|
|
}
|
|
|
|
|
|
|
|
addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in
|
|
|
|
completion(nil)
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|