diff options
| author | Fuwn <[email protected]> | 2025-02-28 03:33:21 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-02-28 03:33:21 -0800 |
| commit | e084ee2714c76f9081d4c57d07dec7ddd21783c2 (patch) | |
| tree | c0798a5d409bd320d89905952475298ee8bec79f | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-e084ee2714c76f9081d4c57d07dec7ddd21783c2.tar.xz sora-testing-e084ee2714c76f9081d4c57d07dec7ddd21783c2.zip | |
feat: Development commit
| -rw-r--r-- | Localizable.xcstrings | 15 | ||||
| -rw-r--r-- | Sora/Data/ItemViewModel.swift | 16 | ||||
| -rw-r--r-- | Sora/Views/Bookmarks/BookmarksListItemView.swift | 39 | ||||
| -rw-r--r-- | Sora/Views/BookmarksView.swift (renamed from Sora/Views/Bookmarks/BookmarksView.swift) | 5 | ||||
| -rw-r--r-- | Sora/Views/GenericItemView.swift | 40 | ||||
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridSearchHistoryView.swift (renamed from Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryView.swift) | 5 | ||||
| -rw-r--r-- | Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryItemView.swift | 39 |
7 files changed, 79 insertions, 80 deletions
diff --git a/Localizable.xcstrings b/Localizable.xcstrings index e540324..5d6c4f1 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -33,6 +33,9 @@ "Clear Cached Tags (%@)" : { }, + "Clear History" : { + + }, "Content Filtering" : { "localizations" : { "ja" : { @@ -104,6 +107,12 @@ "No bookmarks match your search" : { }, + "No History" : { + + }, + "No matching history found" : { + + }, "On %@ from %@" : { "localizations" : { "en" : { @@ -157,6 +166,9 @@ "Rabbit SVG created by Kim Sun Young" : { }, + "Recent searches will appear here." : { + + }, "Refresh" : { }, @@ -189,6 +201,9 @@ } } }, + "Search History" : { + + }, "Select a Post" : { }, diff --git a/Sora/Data/ItemViewModel.swift b/Sora/Data/ItemViewModel.swift new file mode 100644 index 0000000..4e97954 --- /dev/null +++ b/Sora/Data/ItemViewModel.swift @@ -0,0 +1,16 @@ +import Foundation + +protocol ItemViewModel { + var id: UUID { get } + var tags: [String] { get } + var provider: BooruProvider { get } + var date: Date { get } +} + +extension BooruSearchQuery: ItemViewModel { + var date: Date { searchedAt } +} + +extension SettingsBookmark: ItemViewModel { + var date: Date { createdAt } +} diff --git a/Sora/Views/Bookmarks/BookmarksListItemView.swift b/Sora/Views/Bookmarks/BookmarksListItemView.swift deleted file mode 100644 index e0973e6..0000000 --- a/Sora/Views/Bookmarks/BookmarksListItemView.swift +++ /dev/null @@ -1,39 +0,0 @@ -import SwiftUI - -struct BookmarksListItemView: View { - @EnvironmentObject var settings: SettingsManager - var bookmark: SettingsBookmark - - var body: some View { - #if os(macOS) - HStack { - VStack(alignment: .leading) { - Text(bookmark.tags.joined(separator: ", ").lowercased()) - - Spacer() - - Text("On \(bookmark.createdAt.formatted()) from \(bookmark.provider.rawValue)") - .font(.caption) - .foregroundStyle(Color.secondary) - } - - Spacer() - - Button { - settings.removeBookmark(withID: bookmark.id) - } label: { - Image(systemName: "trash") - } - } - .padding() - #else - VStack(alignment: .leading) { - Text(bookmark.tags.joined(separator: ", ").lowercased()) - - Text("On \(bookmark.createdAt.formatted()) from \(bookmark.provider.rawValue)") - .font(.caption) - .foregroundStyle(Color.secondary) - } - #endif - } -} diff --git a/Sora/Views/Bookmarks/BookmarksView.swift b/Sora/Views/BookmarksView.swift index 6c356b9..a84038d 100644 --- a/Sora/Views/Bookmarks/BookmarksView.swift +++ b/Sora/Views/BookmarksView.swift @@ -47,7 +47,10 @@ struct BookmarksView: View { manager.performSearch() } }) { - BookmarksListItemView(bookmark: bookmark) + GenericItemView( + item: bookmark, + removeAction: settings.removeBookmark + ) } #if os(macOS) .buttonStyle(.plain) diff --git a/Sora/Views/GenericItemView.swift b/Sora/Views/GenericItemView.swift new file mode 100644 index 0000000..f2d70cb --- /dev/null +++ b/Sora/Views/GenericItemView.swift @@ -0,0 +1,40 @@ +import SwiftUI + +struct GenericItemView<T: ItemViewModel>: View { + @EnvironmentObject var settings: SettingsManager + let item: T + let removeAction: (UUID) -> Void + + var body: some View { +#if os(macOS) + HStack { + VStack(alignment: .leading) { + Text(item.tags.joined(separator: ", ").lowercased()) + + Spacer() + + Text("On \(item.date.formatted()) from \(item.provider.rawValue)") + .font(.caption) + .foregroundStyle(Color.secondary) + } + + Spacer() + + Button { + removeAction(item.id) + } label: { + Image(systemName: "trash") + } + } + .padding() +#else + VStack(alignment: .leading) { + Text(item.tags.joined(separator: ", ").lowercased()) + + Text("On \(item.date.formatted()) from \(item.provider.rawValue)") + .font(.caption) + .foregroundStyle(Color.secondary) + } +#endif + } +} diff --git a/Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryView.swift b/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift index be2d2ea..2f95118 100644 --- a/Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryView.swift +++ b/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift @@ -47,7 +47,10 @@ struct PostGridSearchHistoryView: View { manager.performSearch() } }) { - PostGridSearchHistoryItemView(query: query) + GenericItemView( + item: query, + removeAction: settings.removeSearchHistoryEntry + ) } #if os(macOS) .buttonStyle(.plain) diff --git a/Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryItemView.swift b/Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryItemView.swift deleted file mode 100644 index 5e0b7ce..0000000 --- a/Sora/Views/Post/Grid/SearchHistory/PostGridSearchHistoryItemView.swift +++ /dev/null @@ -1,39 +0,0 @@ -import SwiftUI - -struct PostGridSearchHistoryItemView: View { - @EnvironmentObject var settings: SettingsManager - var query: BooruSearchQuery - - var body: some View { - #if os(macOS) - HStack { - VStack(alignment: .leading) { - Text(query.tags.joined(separator: ", ").lowercased()) - - Spacer() - - Text("On \(query.searchedAt.formatted()) from \(query.provider.rawValue)") - .font(.caption) - .foregroundStyle(Color.secondary) - } - - Spacer() - - Button { - settings.removeSearchHistoryEntry(withID: query.id) - } label: { - Image(systemName: "trash") - } - } - .padding() - #else - VStack(alignment: .leading) { - Text(query.tags.joined(separator: ", ").lowercased()) - - Text("On \(query.searchedAt.formatted()) from \(query.provider.rawValue)") - .font(.caption) - .foregroundStyle(Color.secondary) - } - #endif - } -} |