diff --git a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings index b82e1e1b..212fb0b6 100644 --- a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings @@ -346,6 +346,10 @@ "explore.section.trending.posts" = "Трэндавыя допісы"; "explore.section.trending.tags" = "Трэндавыя тэгі"; "explore.section.users" = "Карыстальнікі"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Адзін голас"; diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index 57976319..541b04b6 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -340,6 +340,10 @@ "explore.section.trending.posts" = "Publicacions populars"; "explore.section.trending.tags" = "Etiquetes populars"; "explore.section.users" = "Usuaris"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Vot únic"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 58860e61..2d5d568a 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Beiträge im Trend"; "explore.section.trending.tags" = "Hashtags im Trend"; "explore.section.users" = "Profile"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Einfache Auswahl"; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 5c55221c..089f37b1 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -343,6 +343,10 @@ "explore.section.trending.posts" = "Trending Posts"; "explore.section.trending.tags" = "Trending Tags"; "explore.section.users" = "Users"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "One Vote"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index 6b8516ac..3c3d4598 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -342,6 +342,10 @@ "explore.section.trending.posts" = "Trending Posts"; "explore.section.trending.tags" = "Trending Tags"; "explore.section.users" = "Users"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "One Vote"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index e3f93ee5..ef0eae8f 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -342,6 +342,10 @@ "explore.section.trending.posts" = "Publicaciones que son tendencia"; "explore.section.trending.tags" = "Etiquetas que son tendencia"; "explore.section.users" = "Usuarios"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Un voto"; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index ed10738b..c0007048 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Bogan dauden bidalketak"; "explore.section.trending.tags" = "Pil-pilean dauden traolak"; "explore.section.users" = "Erabiltzaileak"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Boto bakarra"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index cc7d48ab..64b8d3d6 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Publications tendance"; "explore.section.trending.tags" = "Étiquettes tendance"; "explore.section.users" = "Utilisateurs"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Un vote"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index 5a2e1b24..7454a659 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Post di tendenza"; "explore.section.trending.tags" = "Tag di tendenza"; "explore.section.users" = "Utenti"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Voto singolo"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index cdd358ca..283534e6 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "人気の投稿"; "explore.section.trending.tags" = "人気のタグ"; "explore.section.users" = "ユーザー"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "単一投票"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index 1a4e30db..3d739080 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -343,6 +343,10 @@ "explore.section.trending.posts" = "뜨고 있는 글"; "explore.section.trending.tags" = "뜨고 있는 태그"; "explore.section.users" = "사용자"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "하나만 선택 가능"; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 83652fce..f5e76854 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Trendende innlegg"; "explore.section.trending.tags" = "Trendende tagger"; "explore.section.users" = "Brukere"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Én stemme"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index b3a0509c..9db1fc45 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -339,6 +339,10 @@ "explore.section.trending.posts" = "Trending posts"; "explore.section.trending.tags" = "Trending hashtags"; "explore.section.users" = "Gebruikers"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Eén stem"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index ea8fb2f2..23b511a9 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -338,6 +338,10 @@ "explore.section.trending.posts" = "Popularne posty"; "explore.section.trending.tags" = "Popularne hasztagi"; "explore.section.users" = "Osoby"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Jeden głos"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index d182ba03..bb432593 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -341,6 +341,10 @@ "explore.section.trending.posts" = "Postagens em Tendência"; "explore.section.trending.tags" = "Hashtags em Tendência"; "explore.section.users" = "Usuários"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Um Voto"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 0b6edfa0..7620b142 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -337,6 +337,10 @@ "explore.section.trending.posts" = "Yükselişteki Gönderiler"; "explore.section.trending.tags" = "Yükselişteki Etiketler"; "explore.section.users" = "Kullanıcılar"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Bir oy"; diff --git a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings index 890dc6d7..96757b29 100644 --- a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings @@ -342,6 +342,10 @@ "explore.section.trending.posts" = "Популярні дописи"; "explore.section.trending.tags" = "Популярні хештеґи"; "explore.section.users" = "Користувачі"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "Лише один варіант"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index 692cd2eb..2d64492e 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -340,6 +340,10 @@ "explore.section.trending.posts" = "当下流行的嘟文"; "explore.section.trending.tags" = "当下流行的标签"; "explore.section.users" = "用户"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "单个投票"; diff --git a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings index f32f0d50..81fb7e29 100644 --- a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings @@ -343,6 +343,10 @@ "explore.section.trending.posts" = "流行嘟文"; "explore.section.trending.tags" = "流行標籤"; "explore.section.users" = "用戶"; +"explore.scope.all" = "All"; +"explore.scope.people" = "People"; +"explore.scope.hashtags" = "Hashtags"; +"explore.scope.posts" = "Posts"; // MARK: Package: Env "env.poll-vote-frequency.one" = "單一選擇"; diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index 24559527..4ec73bc9 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -84,6 +84,11 @@ public struct ExploreView: View { .searchable(text: $viewModel.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: Text("explore.search.prompt")) + .searchScopes($viewModel.searchScope) { + ForEach(ExploreViewModel.SearchScope.allCases, id: \.self) { scope in + Text(scope.localizedString) + } + } } private var quickAccessView: some View { @@ -121,7 +126,7 @@ public struct ExploreView: View { @ViewBuilder private func makeSearchResultsView(results: SearchResults) -> some View { - if !results.accounts.isEmpty { + if !results.accounts.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .people) { Section("explore.section.users") { ForEach(results.accounts) { account in if let relationship = results.relationships.first(where: { $0.id == account.id }) { @@ -131,7 +136,7 @@ public struct ExploreView: View { } } } - if !results.hashtags.isEmpty { + if !results.hashtags.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .hashtags) { Section("explore.section.tags") { ForEach(results.hashtags) { tag in TagRowView(tag: tag) @@ -140,7 +145,7 @@ public struct ExploreView: View { } } } - if !results.statuses.isEmpty { + if !results.statuses.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .posts) { Section("explore.section.posts") { ForEach(results.statuses) { status in StatusRowView(viewModel: { .init(status: status, client: client, routerPath: routerPath) }) diff --git a/Packages/Explore/Sources/Explore/ExploreViewModel.swift b/Packages/Explore/Sources/Explore/ExploreViewModel.swift index 69b50bca..3eb066aa 100644 --- a/Packages/Explore/Sources/Explore/ExploreViewModel.swift +++ b/Packages/Explore/Sources/Explore/ExploreViewModel.swift @@ -5,6 +5,23 @@ import SwiftUI @MainActor class ExploreViewModel: ObservableObject { + enum SearchScope: String, CaseIterable { + case all, people, hashtags, posts + + var localizedString: LocalizedStringKey { + switch self { + case .all: + return .init("explore.scope.all") + case .people: + return .init("explore.scope.people") + case .hashtags: + return .init("explore.scope.hashtags") + case .posts: + return .init("explore.scope.posts") + } + } + } + var client: Client? { didSet { if oldValue != client { @@ -36,6 +53,7 @@ class ExploreViewModel: ObservableObject { @Published var trendingTags: [Tag] = [] @Published var trendingStatuses: [Status] = [] @Published var trendingLinks: [Card] = [] + @Published var searchScope: SearchScope = .all private var searchTask: Task? private var cancellables = Set()