Skip to content

Instantly share code, notes, and snippets.

@jordansinger
Last active May 16, 2021 09:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jordansinger/f4ae5283425258ff1faa86c0386a02ff to your computer and use it in GitHub Desktop.
Save jordansinger/f4ae5283425258ff1faa86c0386a02ff to your computer and use it in GitHub Desktop.
import SwiftUI
import MapKit // be sure to import MapKit
import PlaygroundSupport
struct ContentView: View {
var body: some View {
ZStack {
MapView()
VStack {
HStack {
Spacer()
Controls()
}
Spacer()
Sheet()
}
}
.cornerRadius(24)
}
}
struct Sheet: View {
@State var search = ""
var body: some View {
VStack {
RoundedRectangle(cornerRadius: 5)
.frame(width: 32, height: 5)
.foregroundColor(Color(UIColor.tertiaryLabel))
HStack {
Image(systemName: "magnifyingglass")
TextField("Search for a place or address", text: $search)
.foregroundColor(.primary)
Image(systemName: "mic.fill")
}
.foregroundColor(Color(UIColor.tertiaryLabel))
.padding(12)
.background(Color(UIColor.tertiarySystemGroupedBackground))
.cornerRadius(12)
}
.padding(24)
.padding(.top, -16)
.background(Color(UIColor.secondarySystemGroupedBackground))
.cornerRadius(12)
}
}
struct Controls: View {
var body: some View {
VStack(spacing: 6) {
VStack(spacing: 12) {
Image(systemName: "info.circle")
Divider()
Image(systemName: "location.fill")
}
.frame(width: 40)
.padding(.vertical, 12)
.background(Color(UIColor.secondarySystemGroupedBackground))
.cornerRadius(8)
Image(systemName: "binoculars.fill")
.frame(width: 40)
.padding(.vertical, 12)
.background(Color(UIColor.secondarySystemGroupedBackground))
.cornerRadius(8)
}
.font(.system(size: 20))
.foregroundColor(.blue)
.padding()
.shadow(color: Color(UIColor.black.withAlphaComponent(0.1)), radius: 4)
}
}
struct MapView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
return MKMapView(frame: .zero)
}
func updateUIView(_ view: MKMapView, context: Context) {
// do nothing
}
}
PlaygroundPage.current.setLiveView(ContentView())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment