diff --git a/Tusker/Extensions/Visibility+Helpers.swift b/Tusker/Extensions/Visibility+Helpers.swift index ab7fe15f26..445c418a44 100644 --- a/Tusker/Extensions/Visibility+Helpers.swift +++ b/Tusker/Extensions/Visibility+Helpers.swift @@ -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: diff --git a/Tusker/Screens/Compose/ComposeHostingController.swift b/Tusker/Screens/Compose/ComposeHostingController.swift index a3d3b41639..81e2a14815 100644 --- a/Tusker/Screens/Compose/ComposeHostingController.swift +++ b/Tusker/Screens/Compose/ComposeHostingController.swift @@ -250,7 +250,7 @@ class ComposeHostingController: UIHostingController { 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 { 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) + } + } +}