forked from shadowfacts/Tusker
parent
eb9a5aeb42
commit
4dd8c1d692
|
@ -24,6 +24,19 @@ extension Status.Visibility {
|
|||
}
|
||||
}
|
||||
|
||||
var subtitle: String {
|
||||
switch self {
|
||||
case .public:
|
||||
return "Everyone"
|
||||
case .unlisted:
|
||||
return "Hidden from public timelines"
|
||||
case .private:
|
||||
return "Followers only"
|
||||
case .direct:
|
||||
return "Mentioned users only"
|
||||
}
|
||||
}
|
||||
|
||||
var imageName: String {
|
||||
switch self {
|
||||
case .public:
|
||||
|
|
|
@ -250,7 +250,7 @@ class ComposeHostingController: UIHostingController<ComposeContainerView> {
|
|||
item.accessibilityLabel = String(format: NSLocalizedString("Visibility: %@", comment: "compose visiblity accessibility label"), draft.visibility.displayName)
|
||||
let elements = Status.Visibility.allCases.map { (visibility) -> UIMenuElement in
|
||||
let state = visibility == newVisibility ? UIMenuElement.State.on : .off
|
||||
return UIAction(title: visibility.displayName, image: UIImage(systemName: visibility.unfilledImageName), identifier: nil, discoverabilityTitle: nil, attributes: [], state: state) { [unowned self] (_) in
|
||||
return UIAction(title: visibility.displayName, subtitle: visibility.subtitle, image: UIImage(systemName: visibility.unfilledImageName), state: state) { [unowned self] (_) in
|
||||
self.draft.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
@ -270,9 +270,9 @@ class ComposeHostingController: UIHostingController<ComposeContainerView> {
|
|||
item.image = UIImage(systemName: "link")
|
||||
item.accessibilityLabel = "Federated"
|
||||
}
|
||||
let instanceSubtitle = "Only \(mastodonController.accountInfo!.instanceURL.host!)"
|
||||
item.menu = UIMenu(children: [
|
||||
// todo: iOS 15, action subtitles
|
||||
UIAction(title: "Local-only", image: UIImage(named: "link.broken"), state: localOnly ? .on : .off) { [unowned self] (_) in
|
||||
UIAction(title: "Local-only", subtitle: instanceSubtitle, image: UIImage(named: "link.broken"), state: localOnly ? .on : .off) { [unowned self] (_) in
|
||||
self.draft.localOnly = true
|
||||
},
|
||||
UIAction(title: "Federated", image: UIImage(systemName: "link"), state: localOnly ? .off : .on) { [unowned self] (_) in
|
||||
|
@ -474,3 +474,13 @@ extension ComposeHostingController: ComposeDrawingViewControllerDelegate {
|
|||
dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension UIAction {
|
||||
convenience init(title: String, subtitle: String?, image: UIImage?, state: UIAction.State, handler: @escaping UIActionHandler) {
|
||||
if #available(iOS 15.0, *) {
|
||||
self.init(title: title, subtitle: subtitle, image: image, identifier: nil, discoverabilityTitle: nil, attributes: [], state: state, handler: handler)
|
||||
} else {
|
||||
self.init(title: title, image: image, identifier: nil, discoverabilityTitle: nil, attributes: [], state: state, handler: handler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue