Untitled
unknown
plain_text
14 days ago
2.1 kB
7
Indexable
Never
import SwiftUI struct ComposeView: View { @Environment(\.presentationMode) var presentationMode @State private var recipient: String = "" @State private var subject: String = "" @State private var emailBody: String = "" @State private var priority: Int = 1 @State private var requestReadReceipt: Bool = false var body: some View { NavigationView { Form { Section(header: Text("Recipient")) { TextField("To:", text: $recipient) } Section(header: Text("Subject")) { TextField("Subject:", text: $subject) } Section(header: Text("Email Body")) { TextEditor(text: $emailBody) .frame(height: 200) } Section(header: Text("Options")) { Picker("Priority", selection: $priority) { Text("High").tag(1) Text("Normal").tag(2) Text("Low").tag(3) } .pickerStyle(SegmentedPickerStyle()) Toggle("Request Read Receipt", isOn: $requestReadReceipt) } } .navigationBarTitle("Compose Email", displayMode: .inline) .navigationBarItems( leading: Button("Cancel") { presentationMode.wrappedValue.dismiss() }, trailing: Button("Send") { sendEmail() presentationMode.wrappedValue.dismiss() } .disabled(recipient.isEmpty || subject.isEmpty || emailBody.isEmpty) ) } } private func sendEmail() { // Function to handle email sending logic print("Email sent to: \(recipient) with subject: \(subject)") } } struct ComposeView_Previews: PreviewProvider { static var previews: some View { ComposeView() } }
Leave a Comment