Skip to content

Commit

Permalink
Bookmarks view #59: Sort bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Dec 6, 2019
1 parent 813094b commit 7041ec5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ReaderTranslator/Extentions/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ extension Array where Element: Equatable {
remove(at: index)
}
func chunked(into size: Int) -> [[Element]] {
return stride(from: 0, to: count, by: size).map {
stride(from: 0, to: count, by: size)
.map {
Array(self[$0 ..< Swift.min($0 + size, count)])
}
}
Expand Down
4 changes: 4 additions & 0 deletions ReaderTranslator/Stores/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ extension Array where Element == Bookmark {
}
.chunked(into: into)
}

var sorted: [Element] {
self.sorted { $0.text < $1.text }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct BookmarksView_List: View {
bookmarks = bookmarks.filter { $0.text.contains(filter) }
}

return bookmarks.chunked(into: 3)
return bookmarks.sorted.chunked(into: 3)
}

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>452</string>
<string>457</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.education</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorSafari/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>706</string>
<string>711</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppleEventsUsageDescription</key>
Expand Down

0 comments on commit 7041ec5

Please sign in to comment.