我有两个 DisclosureGroup,每个都有一个选择器。第一个选择器只是从一个静态的年份数组中读取,并且可以正常工作。第二个选择器填充用户名的选择器,但当您选择用户时,该值是 Firebase 文档 ID,而不是全名值。
// MARK: - DISCLOSER GROUP TRIP YEAR
DisclosureGroup("Trip Year: \(String(selectedYear))", isExpanded: $tripYearIsExpanded) {
Picker(selection: $selectedYear, label: Text("")) {
ForEach(years, id: \.self) {
Text(String($0))
} // END:FOREACH
} // END:PICKER
.onChange(of: selectedYear, perform: { value in
getTrips(passedYear: selectedYear)
})
} // END:DISCLOSUREGROUP
.padding(.horizontal)
// MARK: - DISCLOSURE GROUP DRIVER
DisclosureGroup("Driver: \(selectedDriver)", isExpanded: $driverIsExpanded) {
Picker(selection: $selectedDriver, label: Text("")) {
ForEach(userListVM.userVM, id: \.id) { user in
Text(user.fullname)
} // END:FOREACH
} // END:PICKER
.onChange(of: selectedDriver, perform: { value in
print("SELECTED DRIVER: \(selectedDriver)")
})
}
.padding(.horizontal)