Skip to content

Commit 779901c

Browse files
committed
Add new sorting option on reading time
1 parent 66d2a84 commit 779901c

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

App/Features/Entry/EntriesListView.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ struct EntriesListView: View {
77
@Environment(AppSync.self) var appSync: AppSync
88
@FetchRequest var entries: FetchedResults<Entry>
99

10-
init(predicate: NSPredicate, entriesSortAscending: Bool) {
10+
init(
11+
predicate: NSPredicate,
12+
entriesSortedById: Bool,
13+
entriesSortedByReadingTime: Bool,
14+
entriesSortedByAscending: Bool
15+
) {
16+
var sortDescriptors: [NSSortDescriptor] = []
17+
if entriesSortedById {
18+
sortDescriptors.append(NSSortDescriptor(key: "id", ascending: entriesSortedByAscending))
19+
}
20+
21+
if entriesSortedByReadingTime {
22+
sortDescriptors.append(NSSortDescriptor(key: "readingTime", ascending: entriesSortedByAscending))
23+
}
24+
1125
_entries = FetchRequest(
1226
entity: Entry.entity(),
13-
sortDescriptors: [NSSortDescriptor(key: "id", ascending: entriesSortAscending)],
27+
sortDescriptors: sortDescriptors,
1428
predicate: predicate, animation: nil
1529
)
1630
}

App/Features/Entry/EntriesView.swift

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,37 @@ struct EntriesView: View {
66
@Environment(Router.self) var router: Router
77
@EnvironmentObject var appState: AppState
88
@StateObject var searchViewModel = SearchViewModel()
9-
@State var entriesSortAscending = false
9+
@State var entriesSortedById = true
10+
@State var entriesSortedByReadingTime = false
11+
@State var entriesSortedByAscending = false
1012

1113
var body: some View {
1214
VStack {
1315
#if os(iOS)
1416
PasteBoardView()
1517
#endif
1618
SearchView(searchViewModel: searchViewModel)
17-
EntriesListView(predicate: searchViewModel.predicate, entriesSortAscending: entriesSortAscending)
19+
EntriesListView(
20+
predicate: searchViewModel.predicate,
21+
entriesSortedById: entriesSortedById,
22+
entriesSortedByReadingTime: entriesSortedByReadingTime,
23+
entriesSortedByAscending: entriesSortedByAscending
24+
)
25+
}
26+
.onChange(of: entriesSortedByReadingTime) { _, _ in
27+
entriesSortedById = false
1828
}
1929
.toolbar {
20-
ToolbarItem(placement: .navigationBarTrailing) {
21-
HStack {
22-
Button(action: {
23-
entriesSortAscending.toggle()
24-
}, label: {
25-
Image(systemName: "line.3.horizontal.decrease.circle")
26-
.rotationEffect(.degrees(entriesSortAscending ? 180 : 0))
27-
})
28-
RefreshButton()
29-
}
30+
ToolbarItemGroup(placement: .navigationBarTrailing) {
31+
Menu(content: {
32+
Toggle("Order by id", systemImage: "line.3.horizontal.decrease.circle", isOn: $entriesSortedById)
33+
Toggle("Order by reading time", systemImage: "clock.arrow.circlepath", isOn: $entriesSortedByReadingTime)
34+
Divider()
35+
Toggle("Sorting", systemImage: entriesSortedByAscending ? "arrow.up.circle" : "arrow.down.circle", isOn: $entriesSortedByAscending)
36+
}, label: {
37+
Label("Sort options", systemImage: "line.3.horizontal.decrease.circle")
38+
})
39+
RefreshButton()
3040
}
3141
ToolbarItem(placement: .navigationBarLeading) {
3242
Menu(content: {

App/fr.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@
5050
//Player
5151
"Select one entry" = "Sélectionnez une entrée";
5252
"Confirm delete?" = "Confirmer la suppression ?";
53+
54+
"Order by id" = "Trier par id";
55+
"Order by reading time" = "Trier par temps de lecture";
56+
"Sorting" = "Tri";

wallabag.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@
12711271
GCC_WARN_UNUSED_FUNCTION = YES;
12721272
GCC_WARN_UNUSED_VARIABLE = YES;
12731273
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
1274-
MARKETING_VERSION = 7.2.4;
1274+
MARKETING_VERSION = 7.3.0;
12751275
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
12761276
MTL_FAST_MATH = YES;
12771277
ONLY_ACTIVE_ARCH = YES;
@@ -1330,7 +1330,7 @@
13301330
GCC_WARN_UNUSED_FUNCTION = YES;
13311331
GCC_WARN_UNUSED_VARIABLE = YES;
13321332
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
1333-
MARKETING_VERSION = 7.2.4;
1333+
MARKETING_VERSION = 7.3.0;
13341334
MTL_ENABLE_DEBUG_INFO = NO;
13351335
MTL_FAST_MATH = YES;
13361336
SWIFT_COMPILATION_MODE = wholemodule;

0 commit comments

Comments
 (0)