Skip to content

Commit

Permalink
style: run swiftformat
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorErrorError committed Dec 27, 2023
1 parent ccf1004 commit 52c1ca2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
94 changes: 47 additions & 47 deletions Sources/Features/Search/SearchFeature+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
11 changes: 6 additions & 5 deletions Sources/Shared/Styling/NavStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct NavStack<State: Equatable, Action, Root: View, Destination: View>:
.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)
Expand Down Expand Up @@ -104,6 +104,8 @@ public struct NavStack<State: Equatable, Action, Root: View, Destination: View>:
}
}

// MARK: - DrilledView

@MainActor
private struct DrilledView<Destination: View>: View {
typealias Elements = OrderedSet<StackElementID>
Expand All @@ -113,21 +115,20 @@ private struct DrilledView<Destination: View>: 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)
}
}
)
Expand Down

0 comments on commit 52c1ca2

Please sign in to comment.