update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:community_material_icon/community_material_icon.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||
@@ -14,6 +15,8 @@ class SupportScreen extends StatefulWidget {
|
||||
|
||||
class SsupportStateScreen extends State<SupportScreen> {
|
||||
SettingModel? settings;
|
||||
final String subject = 'Soporte Prosapp';
|
||||
final String body = '';
|
||||
|
||||
Future<void> _sendWhatsapp(String? number) async {
|
||||
final _whatsappUrl =
|
||||
@@ -26,8 +29,8 @@ class SsupportStateScreen extends State<SupportScreen> {
|
||||
|
||||
Future<void> _sendEmail(String recipients) async {
|
||||
final Email email = Email(
|
||||
body: '',
|
||||
subject: 'Soporte Prosapp',
|
||||
body: body,
|
||||
subject: subject,
|
||||
recipients: [recipients],
|
||||
isHTML: false,
|
||||
);
|
||||
@@ -35,6 +38,17 @@ class SsupportStateScreen extends State<SupportScreen> {
|
||||
await FlutterEmailSender.send(email);
|
||||
}
|
||||
|
||||
void _sendEmailWeb(String recipients) async {
|
||||
final email =
|
||||
'mailto:$recipients?subject=${Uri.encodeComponent(recipients)}&body=${Uri.encodeComponent(body)}';
|
||||
if (await canLaunch(email)) {
|
||||
await launch(email);
|
||||
} else {
|
||||
// No se pudo abrir el cliente de correo electrónico
|
||||
// Puedes mostrar un diálogo o realizar otra acción en este caso
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -98,7 +112,11 @@ class SsupportStateScreen extends State<SupportScreen> {
|
||||
const SizedBox(width: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
_sendEmail(settings?.email ?? '');
|
||||
if (kIsWeb) {
|
||||
_sendEmailWeb(settings?.email ?? '');
|
||||
} else {
|
||||
_sendEmail(settings?.email ?? '');
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
|
||||
Reference in New Issue
Block a user