-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use modern UIMenu #2545
use modern UIMenu #2545
Changes from all commits
d621c6e
7cb66c9
1c08ba4
23805a0
32b1bab
b37c139
64c11e3
8e1d5ca
d701cce
3748e08
f8c97d4
52b88ab
26c8499
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1031,10 +1031,10 @@ extension ChatListViewController: ChatListEditingBarDelegate { | |
setLongTapEditing(false) | ||
} | ||
|
||
func onMorePressed() { | ||
guard let userDefaults = UserDefaults.shared, let viewModel else { return } | ||
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .safeActionSheet) | ||
func onMorePressed() -> UIMenu { | ||
guard let userDefaults = UserDefaults.shared, let viewModel else { return UIMenu() } | ||
let chatIds = viewModel.chatIdsFor(indexPaths: tableView.indexPathsForSelectedRows) | ||
var actions = [UIMenuElement]() | ||
|
||
if #available(iOS 17.0, *), | ||
chatIds.count == 1, | ||
|
@@ -1051,33 +1051,34 @@ extension ChatListViewController: ChatListEditingBarDelegate { | |
} | ||
|
||
let chatPresentInHomescreenWidget = allHomescreenChatsIds.contains(chatId) | ||
let action: UIAlertAction | ||
let action: UIAction | ||
if chatPresentInHomescreenWidget { | ||
action = UIAlertAction(title: String.localized("remove_from_widget"), style: .default) { [weak self] _ in | ||
action = UIAction(title: String.localized("remove_from_widget"), image: UIImage(systemName: "minus.square")) { [weak self] _ in | ||
guard let self else { return } | ||
userDefaults.removeChatFromHomescreenWidget(accountId: self.dcContext.id, chatId: chatId) | ||
setLongTapEditing(false) | ||
} | ||
} else { | ||
action = UIAlertAction(title: String.localized("add_to_widget"), style: .default) { [weak self] _ in | ||
action = UIAction(title: String.localized("add_to_widget"), image: UIImage(systemName: "plus.square")) { [weak self] _ in | ||
guard let self else { return } | ||
userDefaults.addChatToHomescreenWidget(accountId: self.dcContext.id, chatId: chatId) | ||
setLongTapEditing(false) | ||
} | ||
} | ||
alert.addAction(action) | ||
actions.append(action) | ||
} | ||
|
||
let onlyPinndedSelected = viewModel.hasOnlyPinnedChatsSelected(in: tableView.indexPathsForSelectedRows) | ||
let pinTitle = String.localized(onlyPinndedSelected ? "unpin" : "pin") | ||
alert.addAction(UIAlertAction(title: pinTitle, style: .default) { [weak self] _ in | ||
let pinImage = UIImage(systemName: onlyPinndedSelected ? "pin.slash" : "pin") | ||
actions.append(UIAction(title: pinTitle, image: pinImage) { [weak self] _ in | ||
guard let self else { return } | ||
viewModel.pinChatsToggle(indexPaths: tableView.indexPathsForSelectedRows) | ||
setLongTapEditing(false) | ||
}) | ||
|
||
if viewModel.hasAnyUnmutedChatSelected(in: tableView.indexPathsForSelectedRows) { | ||
alert.addAction(UIAlertAction(title: String.localized("menu_mute"), style: .default) { [weak self] _ in | ||
actions.append(UIAction(title: String.localized("menu_mute"), image: UIImage(systemName: "speaker.slash")) { [weak self] _ in | ||
guard let self else { return } | ||
MuteDialog.show(viewController: self) { [weak self] duration in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could return a sub-menu instead maybe? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i also thouht about that, but the mute dialog is also available at other places, so it seems better to have the same UI everywhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe those other places could use the menu too? 🤔 But can be another PR, this already addresses a lot of them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, at least whatsapp and signal also use an actionSheet for the concrete setting. i also have rarely seen a UIMenu in response to a swipe-to-action gesture (where mute is also available) but yes, if, then it anyway would be another pr, so this is no blocker There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah I don't think swipe action is a great place for it. |
||
guard let self else { return } | ||
|
@@ -1086,14 +1087,13 @@ extension ChatListViewController: ChatListEditingBarDelegate { | |
} | ||
}) | ||
} else { | ||
alert.addAction(UIAlertAction(title: String.localized("menu_unmute"), style: .default) { [weak self] _ in | ||
actions.append(UIAction(title: String.localized("menu_unmute"), image: UIImage(systemName: "speaker.wave.2")) { [weak self] _ in | ||
zeitschlag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
guard let self else { return } | ||
viewModel.setMuteDurations(in: tableView.indexPathsForSelectedRows, duration: 0) | ||
setLongTapEditing(false) | ||
}) | ||
} | ||
|
||
alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil)) | ||
present(alert, animated: true, completion: nil) | ||
return UIMenu(children: actions) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably more of a UX-thing, but if we only have one entry a menu, does it make a lot of sense to show that menu -- and not the menu-entry itself? In other words: Why does the BarButtonItem show a menu and not the Proxy-button?
It feels like an extra step for the user to access the proxy-settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - as the symbol is not self-explaining for most users. therefore, an additional descriptive text is better.
when proxy is then enabled, the icon is shown directly - this is also what is done in the main app.