Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: search UI #30

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Screens/Browser/BrowserList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ struct BrowserList: View, LoadStateProvider, ViewDataProvider, TimerLifecycle, T
}
}
.listStyle(.inset)
.searchable(text: $searchText)
.onChange(of: searchText) {
browserStore.searchPublisher.send($1)
}
.navigationDestination(item: $tappedItem) {
Viewer($0)
}
Expand All @@ -80,6 +76,10 @@ struct BrowserList: View, LoadStateProvider, ViewDataProvider, TimerLifecycle, T
.refreshable {
browserStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
browserStore.searchPublisher.send($1)
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Screens/Browser/BrowserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BrowserStore: ObservableObject {
.debounce(for: .seconds(1), scheduler: RunLoop.main)
.removeDuplicates()
.sink {
self.query = .init(text: $0)
self.query = .init(text: $0, type: .folder)
}
.store(in: &cancellables)
}
Expand Down Expand Up @@ -73,11 +73,11 @@ class BrowserStore: ObservableObject {
}

private func fetchProbe(_ id: String, size: Int = Constants.pageSize) async throws -> VOFile.Probe? {
try await fileClient?.fetchProbe(id, options: .init(query: query, size: size, type: .folder))
try await fileClient?.fetchProbe(id, options: .init(query: query, size: size))
}

private func fetchList(_ id: String, page: Int = 1, size: Int = Constants.pageSize) async throws -> VOFile.List? {
try await fileClient?.fetchList(id, options: .init(query: query, page: page, size: size, type: .folder))
try await fileClient?.fetchList(id, options: .init(query: query, page: page, size: size))
}

func fetchNextPage(replace: Bool = false) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Screens/File/FileOverview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ struct FileOverview: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
}
}
}
.refreshable {
fileStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
fileStore.searchPublisher.send($1)
}
.refreshable {
fileStore.fetchNextPage(replace: true)
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion Sources/Screens/File/FileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ class FileStore: ObservableObject {
.debounce(for: .seconds(1), scheduler: RunLoop.main)
.removeDuplicates()
.sink {
self.query = .init(text: $0)
if $0.isEmpty {
self.query = nil
} else {
self.query = .init(text: $0)
}
}
.store(in: &cancellables)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Group/GroupList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ struct GroupList: View, ViewDataProvider, LoadStateProvider, TimerLifecycle, Tok
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
groupStore.searchPublisher.send($1)
}
}
}
.navigationTitle("Groups")
.refreshable {
groupStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
groupStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Group/GroupMemberList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ struct GroupMemberList: View, ViewDataProvider, LoadStateProvider, TimerLifecycl
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
}
}
.refreshable {
userStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Group/GroupSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ struct GroupSelector: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
groupStore.searchPublisher.send($1)
}
}
}
.refreshable {
groupStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
groupStore.searchPublisher.send($1)
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Insights/InsightsEntityList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ struct InsightsEntityList: View, ViewDataProvider, LoadStateProvider, TimerLifec
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
insightsStore.searchPublisher.send($1)
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Insights")
.refreshable {
insightsStore.fetchEntityNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
insightsStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") {
Expand Down
11 changes: 6 additions & 5 deletions Sources/Screens/Organization/OrganizationList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ struct OrganizationList: View, ViewDataProvider, LoadStateProvider, TimerLifecyc
}
}
}
.navigationTitle("Organizations")
.searchable(text: $searchText)
.onChange(of: searchText) {
organizationStore.searchPublisher.send($1)
}

}
}
.navigationTitle("Organizations")
.refreshable {
organizationStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
organizationStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
Expand Down
10 changes: 5 additions & 5 deletions Sources/Screens/Organization/OrganizationMemberList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct OrganizationMemberList: View, ViewDataProvider, LoadStateProvider, TimerL
if let entities = userStore.entities {
Group {
if entities.count == 0 {
Text("There are no items.")
Text("There are no users.")
} else {
List(entities, id: \.id) { member in
UserRow(
Expand All @@ -48,15 +48,15 @@ struct OrganizationMemberList: View, ViewDataProvider, LoadStateProvider, TimerL
onListItemAppear(member.id)
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
}
}
.refreshable {
userStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Organization/OrganizationSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ struct OrganizationSelector: View, ViewDataProvider, LoadStateProvider, TimerLif
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
organizationStore.searchPublisher.send($1)
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Select Organization")
.refreshable {
organizationStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
organizationStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
if organizationStore.entitiesIsLoading {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/User/UserSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ struct UserSelector: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
}
}
.refreshable {
userStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
userStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
if userStore.entitiesIsLoading {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Workspace/WorkspaceList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ struct WorkspaceList: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
}
}
}
.searchable(text: $searchText)
.onChange(of: searchText) {
workspaceStore.searchPublisher.send($1)
}
}
}
.navigationTitle("Home")
.refreshable {
workspaceStore.fetchNextPage(replace: true)
}
.searchable(text: $searchText)
.onChange(of: searchText) {
workspaceStore.searchPublisher.send($1)
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
if UIDevice.current.userInterfaceIdiom == .phone {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"location" : "https://github.com/kouprlabs/voltaserve-swift.git",
"state" : {
"branch" : "main",
"revision" : "da919d414bce6005a94e68c759799b9e49127d86"
"revision" : "8e7eca9e8cdc04c42cff9cd05ac41f1bfd61f881"
}
}
],
Expand Down