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 {
|
|
|
|
|
2023-03-07 15:14:35 +00:00
|
|
|
convenience init(currentVisibility: Visibility?, completion: @escaping (Visibility?) -> Void) {
|
2018-10-26 01:54:07 +00:00
|
|
|
self.init(title: "Post Visibility", message: nil, preferredStyle: .actionSheet)
|
|
|
|
|
2023-03-07 15:14:35 +00:00
|
|
|
for visibility in Visibility.allCases {
|
2018-10-26 01:54:07 +00:00
|
|
|
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)
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|