mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
Add state to visibility menu
This commit is contained in:
parent
1c295a1f5a
commit
833fad0353
1 changed files with 19 additions and 9 deletions
|
@ -74,14 +74,7 @@ private extension CompositionInputAccessoryView {
|
||||||
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayPoll.toggle() })
|
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayPoll.toggle() })
|
||||||
let visibilityButton = UIBarButtonItem(
|
let visibilityButton = UIBarButtonItem(
|
||||||
image: UIImage(systemName: parentViewModel.visibility.systemImageName),
|
image: UIImage(systemName: parentViewModel.visibility.systemImageName),
|
||||||
menu: UIMenu(children: Status.Visibility.allCasesExceptUnknown.reversed().map { visibility in
|
menu: visibilityMenu(selectedVisibility: parentViewModel.visibility))
|
||||||
UIAction(
|
|
||||||
title: visibility.title ?? "",
|
|
||||||
image: UIImage(systemName: visibility.systemImageName),
|
|
||||||
discoverabilityTitle: visibility.description) { [weak self] _ in
|
|
||||||
self?.parentViewModel.visibility = visibility
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
let contentWarningButton = UIBarButtonItem(
|
let contentWarningButton = UIBarButtonItem(
|
||||||
title: NSLocalizedString("status.content-warning-abbreviation", comment: ""),
|
title: NSLocalizedString("status.content-warning-abbreviation", comment: ""),
|
||||||
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayContentWarning.toggle() })
|
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayContentWarning.toggle() })
|
||||||
|
@ -143,7 +136,24 @@ private extension CompositionInputAccessoryView {
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
parentViewModel.$visibility
|
parentViewModel.$visibility
|
||||||
.sink { visibilityButton.image = UIImage(systemName: $0.systemImageName) }
|
.sink { [weak self] in
|
||||||
|
visibilityButton.image = UIImage(systemName: $0.systemImageName)
|
||||||
|
visibilityButton.menu = self?.visibilityMenu(selectedVisibility: $0)
|
||||||
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extension CompositionInputAccessoryView {
|
||||||
|
func visibilityMenu(selectedVisibility: Status.Visibility) -> UIMenu {
|
||||||
|
UIMenu(children: Status.Visibility.allCasesExceptUnknown.reversed().map { visibility in
|
||||||
|
UIAction(
|
||||||
|
title: visibility.title ?? "",
|
||||||
|
image: UIImage(systemName: visibility.systemImageName),
|
||||||
|
discoverabilityTitle: visibility.description,
|
||||||
|
state: visibility == selectedVisibility ? .on : .off) { [weak self] _ in
|
||||||
|
self?.parentViewModel.visibility = visibility
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue