add search field to labels list in share ext

This commit is contained in:
Satindar Dhillon
2022-07-20 10:06:09 -07:00
parent 1b93d63008
commit f3d2b6c89f
3 changed files with 22 additions and 18 deletions

View File

@ -151,10 +151,10 @@ public struct ShareExtensionView: View {
previewCard
.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
Spacer()
if let item = viewModel.linkedItem {
ApplyLabelsListView(linkedItem: item)
} else {
Spacer()
}
HStack {
@ -202,19 +202,18 @@ struct ApplyLabelsListView: View {
var body: some View {
List {
// Section {
// Button(
// action: { viewModel.showCreateLabelModal = true },
// label: {
// HStack {
// Image(systemName: "plus.circle.fill").foregroundColor(.green)
// Text("Create a new Label").foregroundColor(.appGrayTextContrast)
// Spacer()
// }
// }
// )
// .disabled(viewModel.isLoading)
// }
Section(
content: {
SearchBar(searchTerm: $viewModel.labelSearchFilter, horizontalPadding: 0)
.listRowSeparator(.hidden)
},
header: {
Text("Apply Labels")
.font(.appFootnote)
.foregroundColor(.appGrayText)
}
)
.listRowSeparator(.hidden)
Section {
ForEach(viewModel.labels.applySearchFilter(viewModel.labelSearchFilter), id: \.self) { label in
Button(
@ -242,6 +241,8 @@ struct ApplyLabelsListView: View {
}
}
}
.listStyle(PlainListStyle())
.padding(.vertical, 0)
.task {
await viewModel.loadLabels(dataService: dataService, item: linkedItem)
}

View File

@ -1,13 +1,16 @@
import SwiftUI
public struct SearchBar: View {
private let horizontalPadding: Double
@Binding var searchTerm: String
@FocusState private var isFocused: Bool
public init(
searchTerm: Binding<String>
searchTerm: Binding<String>,
horizontalPadding: Double = 10
) {
self._searchTerm = searchTerm
self.horizontalPadding = horizontalPadding
}
public var body: some View {
@ -39,7 +42,7 @@ public struct SearchBar: View {
}
}
)
.padding(.horizontal, 10)
.padding(.horizontal, horizontalPadding)
if isFocused {
Button(

View File

@ -12,7 +12,7 @@ import Utils
embed(
childViewController: UIViewController.makeShareExtensionController(extensionContext: extensionContext),
heightRatio: 0.55
heightRatio: 0.75
)
}
}