From 52c1ca23697bc076da1503d89a82dad67314ac38 Mon Sep 17 00:00:00 2001 From: ErrorErrorError <16653389+ErrorErrorError@users.noreply.github.com> Date: Wed, 27 Dec 2023 01:03:59 -0600 Subject: [PATCH] style: run swiftformat --- .../Features/Search/SearchFeature+View.swift | 94 +++++++++---------- Sources/Shared/Styling/NavStack.swift | 11 ++- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/Sources/Features/Search/SearchFeature+View.swift b/Sources/Features/Search/SearchFeature+View.swift index be42526..a69b14d 100644 --- a/Sources/Features/Search/SearchFeature+View.swift +++ b/Sources/Features/Search/SearchFeature+View.swift @@ -113,63 +113,63 @@ extension SearchFeature.View: View { .task { store.send(.view(.didAppear)) } .safeAreaInset(edge: .top, spacing: 0) { filters } #if os(iOS) - .navigationBarHidden(true) - .navigationTitle("") - .safeAreaInset(edge: .top, spacing: 0) { - HStack(spacing: 12) { - SwiftUI.Button { - store.send(.view(.didTapBackButton)) - } label: { - Image(systemName: "chevron.left") - } - .buttonStyle(.materialToolbarItem) + .navigationBarHidden(true) + .navigationTitle("") + .safeAreaInset(edge: .top, spacing: 0) { + HStack(spacing: 12) { + SwiftUI.Button { + store.send(.view(.didTapBackButton)) + } label: { + Image(systemName: "chevron.left") + } + .buttonStyle(.materialToolbarItem) - WithViewStore(store, observe: \.`self`) { viewStore in - HStack(spacing: 8) { - Image(systemName: "magnifyingglass") - .foregroundColor(.gray) + WithViewStore(store, observe: \.`self`) { viewStore in + HStack(spacing: 8) { + Image(systemName: "magnifyingglass") + .foregroundColor(.gray) - TextField("Search...", text: viewStore.$query.removeDuplicates()) - .textFieldStyle(.plain) - .font(.body) - .frame(maxWidth: .infinity) + TextField("Search...", text: viewStore.$query.removeDuplicates()) + .textFieldStyle(.plain) + .font(.body) + .frame(maxWidth: .infinity) - Button { - viewStore.send(.didTapClearQuery) - } label: { - Image(systemName: "xmark.circle.fill") - .foregroundColor(.gray) + Button { + viewStore.send(.didTapClearQuery) + } label: { + Image(systemName: "xmark.circle.fill") + .foregroundColor(.gray) + } + .disabled(viewStore.query.isEmpty) + .opacity(viewStore.query.isEmpty ? 0 : 1.0) + .animation(.easeInOut, value: viewStore.query.isEmpty) } - .disabled(viewStore.query.isEmpty) - .opacity(viewStore.query.isEmpty ? 0 : 1.0) - .animation(.easeInOut, value: viewStore.query.isEmpty) - } - .font(.callout) - .padding(.horizontal, 12) - .padding(.vertical, 4) - .background { - RoundedRectangle(cornerRadius: 12, style: .continuous) - .style( - withStroke: Color.gray.opacity(0.16), - fill: .thickMaterial - ) + .font(.callout) + .padding(.horizontal, 12) + .padding(.vertical, 4) + .background { + RoundedRectangle(cornerRadius: 12, style: .continuous) + .style( + withStroke: Color.gray.opacity(0.16), + fill: .thickMaterial + ) + } + .frame(maxWidth: .infinity) } - .frame(maxWidth: .infinity) } + .padding(.horizontal) } - .padding(.horizontal) - } #elseif os(macOS) - .navigationTitle("Search") - .toolbar { - ToolbarItem(placement: .automatic) { - WithViewStore(store, observe: \.`self`) { viewStore in - TextField("Search...", text: viewStore.$query.removeDuplicates()) - .textFieldStyle(.roundedBorder) - .frame(minWidth: 200) + .navigationTitle("Search") + .toolbar { + ToolbarItem(placement: .automatic) { + WithViewStore(store, observe: \.`self`) { viewStore in + TextField("Search...", text: viewStore.$query.removeDuplicates()) + .textFieldStyle(.roundedBorder) + .frame(minWidth: 200) + } } } - } #endif } } diff --git a/Sources/Shared/Styling/NavStack.swift b/Sources/Shared/Styling/NavStack.swift index 517f477..0349c4a 100644 --- a/Sources/Shared/Styling/NavStack.swift +++ b/Sources/Shared/Styling/NavStack.swift @@ -51,7 +51,7 @@ public struct NavStack: .themeable() .background { WithViewStore(store, observe: \.ids, removeDuplicates: areOrderedSetsDuplicates) { viewStore in - // Simulate "drilling down" for iOS 15 + // Simulate "drilling down" for iOS 15 DrilledView(set: viewStore.state, index: viewStore.startIndex) { id, transaction in if viewStore.state.contains(id) { viewStore.send(.popFrom(id: id), transaction: transaction) @@ -104,6 +104,8 @@ public struct NavStack: } } +// MARK: - DrilledView + @MainActor private struct DrilledView: View { typealias Elements = OrderedSet @@ -113,21 +115,20 @@ private struct DrilledView: View { let destination: (Elements.Element) -> Destination var id: Elements.Element? { - if set.startIndex <= index && index < set.endIndex { + if set.startIndex <= index, index < set.endIndex { set[index] } else { nil } } - @MainActor - var body: some View { + @MainActor var body: some View { NavigationLink( isActive: .init( get: { id.flatMap(set.contains) ?? false }, set: { isActive, transaction in if let id, !isActive { - popped(id, transaction) + popped(id, transaction) } } )