Skip to content

Commit

Permalink
feat: Natural navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
charlella committed Mar 8, 2024
1 parent 8d7e790 commit 60f438d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Mail/Views/Settings/Appearance/SettingsAutoAdvanceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ enum AutoAdvanceSection: CaseIterable {
var options: [AutoAdvance] {
switch self {
case .compact:
return [.previousThread, .followingThread, .listOfThread]
return [.previousThread, .followingThread, .listOfThread, .naturalThread]
case .regular:
return [.previousThread, .followingThread]
return [.previousThread, .followingThread, .naturalThread]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread List/ThreadListCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct ThreadListCell: View {
} else {
splitViewManager.adaptToProminentThreadView()

// Update both viewModel and navigationState on the truth.
viewModel.detectDirection(from: thread)
mainViewState.selectedThread = thread
}
}
Expand Down
18 changes: 18 additions & 0 deletions Mail/Views/Thread List/ThreadListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ final class DateSection: Identifiable, Equatable {
}
}

private var movingUp = false

// MARK: Init

init(
Expand Down Expand Up @@ -224,6 +226,14 @@ final class DateSection: Identifiable, Equatable {
selectedThreadOwner.selectedThread = newThreads[validIndex]
case .listOfThread:
selectedThreadOwner.selectedThread = nil
case .naturalThread:
if movingUp {
let validIndex = max(oldSelectedThreadIndex - 1, 0)
selectedThreadOwner.selectedThread = newThreads[validIndex]
} else {
let validIndex = min(oldSelectedThreadIndex, newThreads.count - 1)
selectedThreadOwner.selectedThread = newThreads[validIndex]
}
}
}

Expand All @@ -245,6 +255,14 @@ final class DateSection: Identifiable, Equatable {
selectedThreadOwner.selectedThread = filteredThreads[newIndex]
}

func detectDirection(from newThread: Thread) {
guard !filteredThreads.isEmpty,
let initialThread = selectedThreadOwner.selectedThread,
let initialThreadIndex = filteredThreads.firstIndex(where: { $0.uid == initialThread.uid }),
let newThreadIndex = filteredThreads.firstIndex(where: { $0.uid == newThread.uid }) else { return }
movingUp = newThreadIndex < initialThreadIndex
}

func resetFilterIfNeeded(filteredThreads: [Thread]) {
if filteredThreads.isEmpty && filterUnreadOn {
DispatchQueue.main.sync {
Expand Down
5 changes: 5 additions & 0 deletions MailCore/Models/Settings/AutoAdvance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum AutoAdvance: String, CaseIterable, SettingsOptionEnum {
case previousThread
case followingThread
case listOfThread
case naturalThread

public var title: String {
switch self {
Expand All @@ -33,6 +34,8 @@ public enum AutoAdvance: String, CaseIterable, SettingsOptionEnum {
return MailResourcesStrings.Localizable.settingsAutoAdvanceFollowingThreadTitle
case .listOfThread:
return MailResourcesStrings.Localizable.settingsAutoAdvanceListOfThreadsTitle
case .naturalThread:
return MailResourcesStrings.Localizable.settingsAutoAdvanceNaturalThreadTitle
}
}

Expand All @@ -44,6 +47,8 @@ public enum AutoAdvance: String, CaseIterable, SettingsOptionEnum {
return MailResourcesStrings.Localizable.settingsAutoAdvanceFollowingThreadDescription
case .listOfThread:
return MailResourcesStrings.Localizable.settingsAutoAdvanceListOfThreadsDescription
case .naturalThread:
return MailResourcesStrings.Localizable.settingsAutoAdvanceNaturalThreadDescription
}
}

Expand Down
8 changes: 7 additions & 1 deletion MailResources/Localizable/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Locale: de, German
* Tagged: ios
* Exported by: Charlene Hoareau
* Exported at: Tue, 27 Feb 2024 11:36:19 +0100
* Exported at: Wed, 28 Feb 2024 10:59:43 +0100
*/

/* loco:62bb154d7513e127cb2e9c94 */
Expand Down Expand Up @@ -1130,6 +1130,12 @@
/* loco:65b2780c2b7256da8b038512 */
"settingsAutoAdvanceListOfThreadsTitle" = "Liste der Themen";

/* loco:65df003b996ecfc40c0d9962 */
"settingsAutoAdvanceNaturalThreadDescription" = "Anzeige von Threads basierend auf natürlicher Navigation beim Archivieren oder Löschen";

/* loco:65defeba6cb9206d3f0d4392 */
"settingsAutoAdvanceNaturalThreadTitle" = "Natürliche Navigation";

/* loco:65b27d1e0565d99b930ae142 */
"settingsAutoAdvancePreviousThreadDescription" = "Vorheriges Thema beim Archivieren oder Löschen anzeigen";

Expand Down
8 changes: 7 additions & 1 deletion MailResources/Localizable/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Locale: en, English
* Tagged: ios
* Exported by: Charlene Hoareau
* Exported at: Tue, 27 Feb 2024 11:36:19 +0100
* Exported at: Wed, 28 Feb 2024 10:59:43 +0100
*/

/* loco:62bb154d7513e127cb2e9c94 */
Expand Down Expand Up @@ -1130,6 +1130,12 @@
/* loco:65b2780c2b7256da8b038512 */
"settingsAutoAdvanceListOfThreadsTitle" = "List of threads";

/* loco:65df003b996ecfc40c0d9962 */
"settingsAutoAdvanceNaturalThreadDescription" = "Display thread based on natural navigation when archiving or deleting";

/* loco:65defeba6cb9206d3f0d4392 */
"settingsAutoAdvanceNaturalThreadTitle" = "Natural navigation";

/* loco:65b27d1e0565d99b930ae142 */
"settingsAutoAdvancePreviousThreadDescription" = "Display previous thread when archiving or deleting";

Expand Down
8 changes: 7 additions & 1 deletion MailResources/Localizable/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Locale: es, Spanish
* Tagged: ios
* Exported by: Charlene Hoareau
* Exported at: Tue, 27 Feb 2024 11:36:19 +0100
* Exported at: Wed, 28 Feb 2024 10:59:43 +0100
*/

/* loco:62bb154d7513e127cb2e9c94 */
Expand Down Expand Up @@ -1130,6 +1130,12 @@
/* loco:65b2780c2b7256da8b038512 */
"settingsAutoAdvanceListOfThreadsTitle" = "Lista de temas";

/* loco:65df003b996ecfc40c0d9962 */
"settingsAutoAdvanceNaturalThreadDescription" = "Hilo de visualización basado en la navegación natural al archivar o borrar";

/* loco:65defeba6cb9206d3f0d4392 */
"settingsAutoAdvanceNaturalThreadTitle" = "Navegación natural";

/* loco:65b27d1e0565d99b930ae142 */
"settingsAutoAdvancePreviousThreadDescription" = "Mostrar el hilo anterior al archivar o borrar";

Expand Down
10 changes: 8 additions & 2 deletions MailResources/Localizable/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Locale: fr, French
* Tagged: ios
* Exported by: Charlene Hoareau
* Exported at: Tue, 27 Feb 2024 11:36:19 +0100
* Exported at: Wed, 28 Feb 2024 10:59:43 +0100
*/

/* loco:62bb154d7513e127cb2e9c94 */
Expand Down Expand Up @@ -1130,14 +1130,20 @@
/* loco:65b2780c2b7256da8b038512 */
"settingsAutoAdvanceListOfThreadsTitle" = "Liste des conversations";

/* loco:65df003b996ecfc40c0d9962 */
"settingsAutoAdvanceNaturalThreadDescription" = "Afficher la conversation selon le sens naturel de navigation après archivage ou suppression";

/* loco:65defeba6cb9206d3f0d4392 */
"settingsAutoAdvanceNaturalThreadTitle" = "Sens naturel de navigation";

/* loco:65b27d1e0565d99b930ae142 */
"settingsAutoAdvancePreviousThreadDescription" = "Afficher la conversation précédente après archivage ou suppression";

/* loco:65b277b504a5c5b4710041f3 */
"settingsAutoAdvancePreviousThreadTitle" = "Conversation précédente";

/* loco:65b274f8719e4e08b103c7f4 */
"settingsAutoAdvanceTitle" = "Avance Automatique";
"settingsAutoAdvanceTitle" = "Avance automatique";

/* loco:62c693f572adfe66fd2a82b7 */
"settingsCancellationPeriodDescription" = "Vous avez la possibilité d’annuler l’envoi de votre e-mail jusqu’à 30 secondes";
Expand Down
8 changes: 7 additions & 1 deletion MailResources/Localizable/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Locale: it, Italian
* Tagged: ios
* Exported by: Charlene Hoareau
* Exported at: Tue, 27 Feb 2024 11:36:19 +0100
* Exported at: Wed, 28 Feb 2024 10:59:43 +0100
*/

/* loco:62bb154d7513e127cb2e9c94 */
Expand Down Expand Up @@ -1130,6 +1130,12 @@
/* loco:65b2780c2b7256da8b038512 */
"settingsAutoAdvanceListOfThreadsTitle" = "Elenco delle discussioni";

/* loco:65df003b996ecfc40c0d9962 */
"settingsAutoAdvanceNaturalThreadDescription" = "Visualizzazione della conversazione nella direzione naturale di navigazione dopo l’archiviazione o la cancellazione";

/* loco:65defeba6cb9206d3f0d4392 */
"settingsAutoAdvanceNaturalThreadTitle" = "Navigazione naturale";

/* loco:65b27d1e0565d99b930ae142 */
"settingsAutoAdvancePreviousThreadDescription" = "Visualizzazione della discussione precedente quando si archivia o si elimina";

Expand Down

0 comments on commit 60f438d

Please sign in to comment.