mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* wip * wip * wip * wip * wip * basics * wip * wip * wip got LocalSearchClient spm package * got a common spm package * basics of desktop * renamed * wip * clean up * Fix * clean up * formatting and remove deprecated * wip * move stuff around, readmes * fix * clean up * image * typo * docs * wip * typo * rename * wip * clean up * clean up * rename * wip * Update README.md * custom button * format * wip * fix * error info * public interface * set, alpha * add error * fix * alpha * internal * Revert "internal" This reverts commit97da6f3086. * wip * wip * docs * rename * cleanup * add fatal error messages to mock * fixes * fixes * clean up * 13.3 fixes * another fix * 13.3 fixes * wip * fix mac tests * wip * just use double * fix * Revert "fix" This reverts commit4565a6485f. * fix * Fix? * Fix * More fix Co-authored-by: Stephen Celis <stephen@stephencelis.com>
85 lines
2.3 KiB
Swift
85 lines
2.3 KiB
Swift
import Combine
|
|
import ComposableArchitecture
|
|
import ComposableCoreLocation
|
|
import MapKit
|
|
import SwiftUI
|
|
|
|
struct LocationManagerView: View {
|
|
@Environment(\.colorScheme) var colorScheme
|
|
let store: Store<AppState, AppAction>
|
|
|
|
var body: some View {
|
|
WithViewStore(self.store) { viewStore in
|
|
ZStack {
|
|
MapView(
|
|
pointsOfInterest: viewStore.pointsOfInterest,
|
|
region: viewStore.binding(get: { $0.region }, send: AppAction.updateRegion)
|
|
)
|
|
.edgesIgnoringSafeArea([.all])
|
|
|
|
VStack(alignment: .center) {
|
|
Spacer()
|
|
|
|
HStack(spacing: 16) {
|
|
ForEach(AppState.pointOfInterestCategories, id: \.rawValue) { category in
|
|
Button(category.displayName) { viewStore.send(.categoryButtonTapped(category)) }
|
|
.buttonStyle(PlainButtonStyle())
|
|
.padding([.all], 12)
|
|
.background(
|
|
category == viewStore.pointOfInterestCategory ? Color.blue : Color.secondary
|
|
)
|
|
.foregroundColor(.white)
|
|
.cornerRadius(8)
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Button(action: { viewStore.send(.currentLocationButtonTapped) }) {
|
|
Text("📍")
|
|
.font(.body)
|
|
.foregroundColor(Color.white)
|
|
.frame(width: 44, height: 44)
|
|
.background(Color.secondary)
|
|
.clipShape(Circle())
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
|
|
}
|
|
.padding([.leading, .trailing])
|
|
.padding([.bottom], 16)
|
|
}
|
|
}
|
|
.alert(
|
|
item: viewStore.binding(
|
|
get: { $0.alert.map(AppAlert.init(title:)) },
|
|
send: AppAction.dismissAlertButtonTapped
|
|
)
|
|
) { alert in
|
|
Alert(title: Text(alert.title))
|
|
}
|
|
.onAppear { viewStore.send(.onAppear) }
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
let appView = LocationManagerView(
|
|
store: Store(
|
|
initialState: AppState(),
|
|
reducer: appReducer,
|
|
environment: AppEnvironment(
|
|
localSearch: .live,
|
|
locationManager: .live
|
|
)
|
|
)
|
|
)
|
|
|
|
return Group {
|
|
appView
|
|
appView
|
|
.environment(\.colorScheme, .dark)
|
|
}
|
|
}
|
|
}
|