SwiftUIKit icon indicating copy to clipboard operation
SwiftUIKit copied to clipboard

ContactPicker: closes parent sheet when ContactPicker is closed

Open dderg opened this issue 4 years ago • 1 comments

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.

dderg avatar Jan 28 '21 15:01 dderg

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....

michaelrowe01 avatar Jan 30 '21 19:01 michaelrowe01