From f3d2b6c89f4ac04a008ecdc9ee7e06b7e28100a5 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 20 Jul 2022 10:06:09 -0700 Subject: [PATCH] add search field to labels list in share ext --- .../Share/Views/ShareExtensionView.swift | 31 ++++++++++--------- .../OmnivoreKit/Sources/Views/SearchBar.swift | 7 +++-- .../ShareExtensionViewController.swift | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift index cd69ebaf0..6a0420b36 100644 --- a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift @@ -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) } diff --git a/apple/OmnivoreKit/Sources/Views/SearchBar.swift b/apple/OmnivoreKit/Sources/Views/SearchBar.swift index 40dd39e73..be32bc3d1 100644 --- a/apple/OmnivoreKit/Sources/Views/SearchBar.swift +++ b/apple/OmnivoreKit/Sources/Views/SearchBar.swift @@ -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 + searchTerm: Binding, + 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( diff --git a/apple/Sources/ShareExtension/ShareExtensionViewController.swift b/apple/Sources/ShareExtension/ShareExtensionViewController.swift index 96a9c88ce..ab77d2750 100644 --- a/apple/Sources/ShareExtension/ShareExtensionViewController.swift +++ b/apple/Sources/ShareExtension/ShareExtensionViewController.swift @@ -12,7 +12,7 @@ import Utils embed( childViewController: UIViewController.makeShareExtensionController(extensionContext: extensionContext), - heightRatio: 0.55 + heightRatio: 0.75 ) } }