SwiftUIKit
SwiftUIKit copied to clipboard
ContactPicker: closes parent sheet when ContactPicker is closed
removing line 58 fixes it,
viewModel.dummy.dismiss(animated: true)
but I believe it was there for some reason. I'm new to Swift so I need some help in making a PR for that.
I also see this issue... However, once I added in logic to validate Permissions (and stop crashing when they are denied), I no longer get the ContactPicker presented...
HStack {
Button(action: {
saveRecipient()
self.presentationMode.wrappedValue.dismiss()
}, label: {
Image(systemName: "square.and.arrow.down")
.font(.largeTitle)
.foregroundColor(.green)
})
Button(action: {
let contactsPermsissions = checkContactsPermissions()
if contactsPermsissions == true {
self.showPicker.toggle()
}
}, label: {
Image(systemName: "magnifyingglass")
.font(.largeTitle)
.foregroundColor(.green)
})
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Image(systemName: "chevron.down.circle.fill")
.font(.largeTitle)
.foregroundColor(.green)
})
}
)
ContactPicker(showPicker: $showPicker, onSelectContact: {contact in
firstName = contact.givenName
lastName = contact.familyName
if contact.postalAddresses.count > 0 {
if let addressString = (((contact.postalAddresses[0] as AnyObject).value(forKey: "labelValuePair") as AnyObject).value(forKey: "value")) as? CNPostalAddress {
let mailAddress = CNPostalAddressFormatter.string(from:addressString, style: .mailingAddress)
addressLine1 = "\(addressString.street)"
addressLine2 = ""
city = "\(addressString.city)"
state = "\(addressString.state)"
zip = "\(addressString.postalCode)"
country = "\(addressString.country)"
print(mailAddress)
}
saveRecipient()
}
}, onCancel: nil)```
Anything obvious....