configuracion - sugerencias - soporte

This commit is contained in:
Felipe
2024-03-13 23:55:48 -05:00
parent cde7e72f1a
commit 66125235dd
23 changed files with 547 additions and 100 deletions
+2 -2
View File
@@ -138,7 +138,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
}
}
} catch (e) {
emit(const AuthStateFailure(message: "Error inesperado. PUTA 🥸"));
emit(const AuthStateFailure(message: "Error inesperado. 🥸"));
}
}
@@ -184,7 +184,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
// await _userRepository
} catch (e) {
emit(const AuthStateFailure(message: "Error inesperado. PUTA 🥸"));
emit(const AuthStateFailure(message: "Error inesperado. 🥸"));
}
}
+37 -1
View File
@@ -1,12 +1,28 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:prosappco/components/general_drawer_header.dart';
import 'package:prosappco/components/general_drawer_item.dart';
import 'package:prosappco/screens/configuration/configuration_screen.dart';
import 'package:prosappco/screens/configuration/configuration_support_screen.dart';
import 'package:prosappco/screens/web/web_view_screen.dart';
import 'package:url_launcher/url_launcher.dart';
class GeneralDrawer extends StatelessWidget {
const GeneralDrawer({super.key});
Future<void> _irSugerencias() async {
const url = 'https://admin.prosapp.co/sugerencias';
final Uri _url = Uri.parse(url);
if (await canLaunchUrl(_url)) {
await launchUrl(_url);
} else {
throw 'No se pudo abrir la URL $url';
}
}
@override
Widget build(BuildContext context) {
return Drawer(
@@ -49,13 +65,33 @@ class GeneralDrawer extends StatelessWidget {
label: 'Soporte',
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) =>
const ConfigurationSupportScreen(),
),
);
},
),
GeneralDrawerItem(
leading: Icons.campaign_outlined,
label: 'Sugerencias',
onTap: () {
Navigator.pop(context);
if (kIsWeb) {
_irSugerencias();
} else {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return WebViewScreen(
label: 'Sugerencias',
link: 'https://admin.prosapp.co/sugerencias');
},
),
);
}
},
),
],
+9 -3
View File
@@ -2,24 +2,26 @@ import 'package:flutter/material.dart';
class GeneralDrawerItem extends StatelessWidget {
final String label;
final String? subtitle;
final IconData? leading;
final bool trailing;
final Color? color;
final VoidCallback onTap;
final VoidCallback? onTap;
const GeneralDrawerItem({
super.key,
required this.label,
this.subtitle,
this.leading,
this.trailing = false,
this.color,
required this.onTap,
this.onTap,
});
@override
Widget build(BuildContext context) {
return ListTile(
onTap: onTap,
onTap: onTap == null ? null : () => onTap!(),
leading: leading == null
? null
: Icon(
@@ -36,6 +38,10 @@ class GeneralDrawerItem extends StatelessWidget {
label,
style: TextStyle(fontSize: 15, color: color),
),
subtitle: subtitle == null
? null
: Text(subtitle ?? "", style: const TextStyle(color: Colors.black54)),
// dense: true,
);
}
}
+4
View File
@@ -9,6 +9,7 @@ import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
import 'package:user_repository/user_repository.dart';
import 'package:city_repository/city_repository.dart';
import 'package:setting_repository/setting_repository.dart';
class AppDI {
void register() {
@@ -19,6 +20,9 @@ class AppDI {
injector.registerSingleton<CityRepository>(() => FirebaseCityRepository());
injector.registerSingleton<SettingRepository>(
() => FirebaseSettingRepository());
injector.registerSingleton<AuthenticationBloc>((() =>
AuthenticationBloc(myUserRepository: injector.get<UserRepository>())));
-10
View File
@@ -1,10 +0,0 @@
import 'package:flutter/material.dart';
class AboutScreen extends StatelessWidget {
const AboutScreen({super.key});
@override
Widget build(BuildContext context) {
return Placeholder();
}
}
@@ -0,0 +1,103 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:injector/injector.dart';
import 'package:prosappco/components/general_drawer_item.dart';
import 'package:prosappco/screens/web/web_view_screen.dart';
import 'package:setting_repository/setting_repository.dart';
import 'package:url_launcher/url_launcher.dart';
class ConfigurationAboutScreen extends StatefulWidget {
const ConfigurationAboutScreen({super.key});
@override
State<ConfigurationAboutScreen> createState() =>
_ConfigurationAboutScreenState();
}
class _ConfigurationAboutScreenState extends State<ConfigurationAboutScreen> {
final settingRepository = Injector.appInstance.get<SettingRepository>();
SettingEntity? settings;
@override
void initState() {
super.initState();
_loadSettings();
}
void _loadSettings() {
settingRepository.getSettings().then(
(value) => setState(() {
settings = value;
}),
);
}
void _launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url, forceSafariVC: false, forceWebView: false);
} else {
throw 'No se pudo abrir el enlace $url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Acerca de la aplicación'),
),
body: ListView(
children: [
GeneralDrawerItem(
label: 'Políticas de privacidad',
onTap: () {
if (kIsWeb) {
_launchURL(settings?.politicasPrivacidad ?? '');
} else {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return WebViewScreen(
label: 'Políticas de privacidad',
link: settings?.politicasPrivacidad ?? '',
);
},
),
);
}
},
trailing: true,
),
GeneralDrawerItem(
label: 'Términos y condiciones',
onTap: () {
if (kIsWeb) {
_launchURL(settings?.terminosCondiciones ?? '');
} else {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return WebViewScreen(
label: 'Términos y condiciones',
link: settings?.terminosCondiciones ?? '',
);
},
),
);
}
},
trailing: true,
),
GeneralDrawerItem(
label: 'Versión de la aplicación',
subtitle: settings?.version,
),
],
),
);
}
}
@@ -127,11 +127,13 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injector/injector.dart';
import 'package:prosappco/blocs/setting_bloc/setting_bloc.dart';
import 'package:prosappco/components/general_drawer_item.dart';
import 'package:prosappco/screens/configuration/configuration_about_screen.dart';
class ConfigurationScreen extends StatelessWidget {
const ConfigurationScreen({super.key});
@@ -156,7 +158,16 @@ class ConfigurationScreen extends StatelessWidget {
children: [
GeneralDrawerItem(
label: 'Acerca de la aplicación',
onTap: () {},
onTap: () {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ConfigurationAboutScreen();
},
),
);
},
trailing: true,
),
GeneralDrawerItem(
@@ -0,0 +1,212 @@
import 'package:community_material_icon/community_material_icon.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:injector/injector.dart';
import 'package:setting_repository/setting_repository.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
class ConfigurationSupportScreen extends StatefulWidget {
const ConfigurationSupportScreen({super.key});
@override
State<ConfigurationSupportScreen> createState() =>
_ConfigurationSupportScreenState();
}
class _ConfigurationSupportScreenState
extends State<ConfigurationSupportScreen> {
final settingRepository = Injector.appInstance.get<SettingRepository>();
SettingEntity? settings;
final String subject = 'Soporte Prosapp';
final String body = '';
@override
void initState() {
super.initState();
_loadSettings();
}
void _loadSettings() {
settingRepository.getSettings().then(
(value) => setState(() {
settings = value;
}),
);
}
Future<void> _sendWhatsapp(String? number) async {
final _whatsappUrl =
'https://api.whatsapp.com/send?phone=$number&text=Hola%21+soy+usuario+de+Prosapp+y+quisiera+conocer+mas+sobre+esta+app+%F0%9F%98%81';
if (!await launch(_whatsappUrl)) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Error al enviar el mensaje de WhatsApp'),
));
}
}
Future<void> _sendEmail(String recipients) async {
final Email email = Email(
body: body,
subject: subject,
recipients: [recipients],
isHTML: false,
);
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 {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Error al enviar el correo'),
));
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Soporte'),
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 30, left: 35, right: 35),
child: Text(
'${settings?.tituloSoporte}',
style: const TextStyle(fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 35),
child: Text(settings?.parrafoSoporte ?? 'Cargando...'),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Material(
color: Colors.blue, // Color de fondo azul
shape: const CircleBorder(), // Forma circular
child: InkWell(
borderRadius: BorderRadius.circular(
30), // Radio del área de interacción
onTap: () {
_sendWhatsapp(settings?.numeroSoporte);
},
child: const Padding(
padding: EdgeInsets.all(15),
child: Icon(
CommunityMaterialIcons.whatsapp,
color: Colors.white,
size: 30,
),
),
),
),
const SizedBox(width: 20),
Material(
color: Colors.blue,
shape: const CircleBorder(),
child: InkWell(
borderRadius: BorderRadius.circular(30),
onTap: () {
if (kIsWeb) {
_sendEmailWeb(settings?.emailSoporte ?? '');
} else {
_sendEmail(settings?.emailSoporte ?? '');
}
},
child: const Padding(
padding: EdgeInsets.all(15),
child: Icon(
Icons.email_outlined,
color: Colors.white,
size: 30,
),
),
),
),
// ElevatedButton(
// onPressed: () {
// // _sendWhatsapp(settings?.numeroSoporte);
// },
// style: ElevatedButton.styleFrom(
// foregroundColor: Colors.white,
// backgroundColor: const Color(0xFF2BA4EC),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(50),
// side: const BorderSide(
// color: Color(0xFF2BA4EC),
// width: 2,
// ),
// ),
// ),
// child: const Padding(
// padding: EdgeInsets.symmetric(vertical: 18, horizontal: 0),
// child: Icon(
// CommunityMaterialIcons.whatsapp,
// size: 30,
// color: Colors.white,
// ),
// ),
// ),
// const SizedBox(width: 20),
// ElevatedButton(
// onPressed: () {
// if (kIsWeb) {
// // _sendEmailWeb(settings?.emailSoporte ?? '');
// } else {
// // _sendEmail(settings?.emailSoporte ?? '');
// }
// },
// style: ElevatedButton.styleFrom(
// foregroundColor: Colors.white,
// backgroundColor: const Color(0xFF2BA4EC),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(50),
// side: const BorderSide(
// color: Color(0xFF2BA4EC),
// width: 2,
// ),
// ),
// ),
// child: const Padding(
// padding: EdgeInsets.symmetric(vertical: 18, horizontal: 0),
// child: Icon(
// Icons.email_outlined,
// size: 30,
// color: Colors.white,
// ),
// ),
// ),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 50),
child: Column(
children: [
const Text(
'Horario de atención:',
style: TextStyle(fontWeight: FontWeight.w600),
),
const SizedBox(height: 20),
Text('${settings?.diasSoporte}'),
const SizedBox(height: 5),
Text('${settings?.horasSoporte}'),
],
),
),
],
),
);
}
}
@@ -48,6 +48,11 @@ class _WebViewScreenState extends State<WebViewScreen> {
..loadRequest(Uri.parse(widget.link));
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:prosappco/screens/web/web_view_screen.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/photo_view.dart';
import 'package:prosappco/src/models/user_model.dart';