Skip to content

Commit

Permalink
Chore:wrench:: #32 Modify searching variable
Browse files Browse the repository at this point in the history
- 검색용 변수를 searchQueryString에서 AddressSearcher의 queryString으로 변경
  • Loading branch information
taek0622 committed Jun 2, 2023
1 parent ef9b833 commit c3b868a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Nav/View/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import MapKit
import SwiftUI
struct MapView: View {
private var mockDatas: [MockDatum] = MockDatum.allData

@State var searchQueryString = ""
@ObservedObject var addressSearcher = AddressSearcher()
@State var isEditing = false

// 서울 좌표
Expand All @@ -18,6 +16,8 @@ struct MapView: View {
@State private var isClickedYes: Bool = false
@State private var isShowModal: Bool = false

private var mockDatas: [MockDatum] = MockDatum.allData

var body: some View {
NavigationView {
ZStack {
Expand All @@ -28,23 +28,36 @@ struct MapView: View {
}

if isEditing {
List {
Text(searchQueryString)
List(addressSearcher.completions) { completion in
Button {
// 핀 포커싱 기능 추가
addressSearcher.searchQuery = ""
} label: {
VStack(alignment: .leading) {
Text(completion.title)
if completion.subtitle != "" {
Text(completion.subtitle)
.font(.subheadline)
.foregroundColor(.gray)
}
}
}
}
}
}
.navigationTitle("NAV")
.searchable(
text: $searchQueryString,
text: $addressSearcher.searchQuery,
placement: .navigationBarDrawer,
prompt: "검색"
)
.onChange(of: searchQueryString) { newValue in
.onChange(of: addressSearcher.searchQuery) { newValue in
isEditing = (newValue != "" ? true : false)
}
}
}
}

struct MapView_Previews: PreviewProvider {
static var previews: some View {
MapView()
Expand Down

0 comments on commit c3b868a

Please sign in to comment.