Improve iPad keyboard chat list navigation

This commit is contained in:
Elaine 2025-10-07 12:57:33 -04:00 committed by GitHub
parent 92588e9f28
commit 8654db782b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 3 deletions

View File

@ -175,7 +175,9 @@ struct CLVRenderState {
func indexPath(afterThread thread: TSThread?) -> IndexPath? {
let section: (index: Int, threadUniqueIds: KeyPath<CLVRenderState, [String]>)
if let thread = thread, pinnedThreadUniqueIds.contains(thread.uniqueId) {
let threadIsPinned = thread.map { pinnedThreadUniqueIds.contains($0.uniqueId) } == true
let noThreadSelectedAndHasPinnedThreads = thread == nil && !pinnedThreadUniqueIds.isEmpty
if threadIsPinned || noThreadSelectedAndHasPinnedThreads {
let index = sectionIndex(for: .pinned)!
section = (index, sections[index].threadUniqueIds!)
} else {
@ -193,6 +195,12 @@ struct CLVRenderState {
if index < (self[keyPath: section.threadUniqueIds].count - 1) {
return IndexPath(item: index + 1, section: section.index)
} else if
let nextSection = sections[safe: section.index + 1],
let nextSectionThreads = nextSection.threadUniqueIds,
!self[keyPath: nextSectionThreads].isEmpty
{
return IndexPath(item: 0, section: section.index + 1)
} else {
return nil
}
@ -201,7 +209,9 @@ struct CLVRenderState {
func indexPath(beforeThread thread: TSThread?) -> IndexPath? {
let section: (index: Int, threadUniqueIds: KeyPath<CLVRenderState, [String]>)
if let thread = thread, pinnedThreadUniqueIds.contains(thread.uniqueId) {
let threadIsPinned = thread.map { pinnedThreadUniqueIds.contains($0.uniqueId) } == true
let allChatsArePinned = unpinnedThreadUniqueIds.isEmpty
if threadIsPinned || allChatsArePinned {
let index = sectionIndex(for: .pinned)!
section = (index, sections[index].threadUniqueIds!)
} else {
@ -220,6 +230,12 @@ struct CLVRenderState {
if index > 0 {
return IndexPath(item: index - 1, section: section.index)
} else if
let previousSection = sections[safe: section.index - 1],
let previousSectionThreads = previousSection.threadUniqueIds,
!self[keyPath: previousSectionThreads].isEmpty
{
return IndexPath(item: self[keyPath: previousSectionThreads].count - 1, section: section.index - 1)
} else {
return nil
}

View File

@ -59,6 +59,7 @@ public class ChatListViewController: OWSViewController, HomeTabViewController {
tableView.estimatedRowHeight = 60
tableView.allowsSelectionDuringEditing = true
tableView.allowsMultipleSelectionDuringEditing = true
tableView.selectionFollowsFocus = false
if let filterControl {
filterControl.clearAction = .disableChatListFilter(target: self)

View File

@ -412,7 +412,29 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit
comment: "A keyboard command to jump to the next conversation in the list."
)
)
]
] + [
UIKeyCommand(
action: #selector(selectPreviousConversation),
input: "\t",
modifierFlags: [.control, .shift],
discoverabilityTitle: OWSLocalizedString(
"KEY_COMMAND_PREVIOUS_CONVERSATION",
comment: "A keyboard command to jump to the previous conversation in the list."
)
),
UIKeyCommand(
action: #selector(selectNextConversation),
input: "\t",
modifierFlags: .control,
discoverabilityTitle: OWSLocalizedString(
"KEY_COMMAND_NEXT_CONVERSATION",
comment: "A keyboard command to jump to the next conversation in the list."
)
),
].map {
$0.wantsPriorityOverSystemBehavior = true
return $0
}
var selectedConversationKeyCommands: [UIKeyCommand] {
return [