0

I have a List() of contact emails, each one displayed on a row with some Buttons().

One of the buttons is expected to launch a new mail message.

I should use Link() with “mailto:” scheme but it does not work when different buttons share same row, so I guess I can only use .onTapGesture closure to call a function.

How could I activate a Link() from a self.launchNewMessage() func?

Is there any CallBack from Link() I could use to confirm a success launch?

var body: some View {
    List(emails) { email in
        HStack() {
            VStack() {
                Image(systemName: "square.and.pencil")
                Text("new message")
            }.onTapGesture {
                self.launchNewMessage(email.address)
            }
            //Other Buttons in same row...
    }
}

func launchNewMessage(_ emailAddress:String) {
}
Matias Masso
  • 1,670
  • 3
  • 18
  • 28
  • 1
    openURL? Does this answer your question https://stackoverflow.com/a/65245999/12299030? – Asperi Jan 29 '21 at 17:02
  • Yes it does, thanks! in case anyone else is interested it is documented on https://developer.apple.com/documentation/swiftui/openurlaction – Matias Masso Jan 30 '21 at 08:13
  • Does this answer your question? [Merely declaring the environment variable openURL cause popover behavior to go wonky](https://stackoverflow.com/questions/65241939/merely-declaring-the-environment-variable-openurl-cause-popover-behavior-to-go-w) – Jonas Deichelmann Jan 30 '21 at 12:19
  • Yes Jonas, your link goes to same page already suggested by @Asperi – Matias Masso Jan 30 '21 at 17:31

0 Answers0