Skip to content

NigelGee/AFMessageUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AFMessageUI

A package to wrap UIKit Email and Message in a ViewModifier for SwiftUI. isPresented and toRecipients are required, however for Email, you can have subject and the main body of email as well as CC and BCC recipients and Messages body is optional. Also added the option to have onDismiss method/closure. It will handle if a devices can send email and give error sheet if so.

  • Important: This will not send an email/messages. It will present the email/message composer and user has the option to send the email/message or cancel it.
  • Note: onDismiss closure will run even if email is not sent/canceled or device does not handle emails/messages.
  1. Add to Swift Package Manager
  2. Import AFMessageUI
  3. Add Modifier .mailSheet(isPresented: toRecipients) and or .messageSheet(isPresented: toRecipients)
import AFMessageUI
import SwiftUI

struct ContentView: View {
    @State private var showMailComposer = false
    @State private var showMessageComposer = false
    
    var body: some View {
        Button("Compose Mail") {
            showMailComposer.toggle()
        }
        .buttonStyle(.bordered)
        .mailSheet(
            isPresented: $showMailComposer,
            toRecipients: "[email protected]",
            subject: "My Important Email",
            body: "This is very important information."
        )
        
        Button("Compose Message") {
            showMessageComposer.toggle()
        }
        .buttonStyle(.bordered)
        .messageSheet(
            isPresented: $showMessageComposer,
            toRecipients: "07795111222",
            body: "This is very important message."
        )
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages