StartView -> TestView


struct StartView: View {
@StateObject var vm: APIViewModel = APIViewModel()
@State private var isSearchButtonTapped = false
var body: some View {
NavigationStack{
VStack{
Button {
isSearchButtonTapped = true
vm.search(query: "", srchPolyBizSecd: "")
} label: {
Text("정책검색")
.font(.title3)
.padding()
.background(.buttonGreen)
.foregroundColor(.white)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
.frame(width: 140, height: 50)
.navigationDestination(isPresented: $isSearchButtonTapped) {
TestView().environmentObject(vm)
}
}
}
}
}
struct TestView: View {
@EnvironmentObject var vm: APIViewModel
var body: some View {
ScrollView {
ForEach(vm.result?.youthPolicies ?? []) { youthPolicy in
HStack {
Text(youthPolicy.polyBizSjnm)
.font(.system(size: 15))
.padding()
Spacer()
}
}
}
}
}