diff --git a/lib/src/screens/professional_profile.dart b/lib/src/screens/professional_profile.dart index 6dd4b53..0799664 100644 --- a/lib/src/screens/professional_profile.dart +++ b/lib/src/screens/professional_profile.dart @@ -561,10 +561,11 @@ class ProfessionalProfileScreenState extends State { return SafeArea( child: Scaffold( appBar: PopAppbar( - onPressed: () { - Navigator.pop(context); - }, - label: 'Perfil profesional'), + onPressed: () { + Navigator.pop(context); + }, + label: 'Perfil profesional', + ), body: SingleChildScrollView( reverse: true, child: Center( diff --git a/lib/src/screens/profile_pro.dart b/lib/src/screens/profile_pro.dart index ced044f..15ad158 100644 --- a/lib/src/screens/profile_pro.dart +++ b/lib/src/screens/profile_pro.dart @@ -33,9 +33,11 @@ class _ProfileProScreenState extends State { File? image_portada; File? imagen_to_upload; - bool domicilioValue = false; bool tarifaValue = false; + + bool domicilioValue = true; bool sitioValue = false; + var photoTemp = ''; var _photo = '...'; @@ -385,6 +387,24 @@ class _ProfileProScreenState extends State { ); } + void toggleDomicilio(bool newValue) { + setState(() { + domicilioValue = newValue; + if (newValue == false && sitioValue == false) { + sitioValue = true; + } + }); + } + + void toggleSitio(bool newValue) { + setState(() { + sitioValue = newValue; + if (newValue == false && domicilioValue == false) { + domicilioValue = true; + } + }); + } + @override Widget build(BuildContext context) { String address = _direccion.toString(); @@ -455,20 +475,9 @@ class _ProfileProScreenState extends State { ), if (settings?.domicilios == true) customSwitch( - 'Servicio a domicilio', - domicilioValue, - (value) { - domicilioValue = value; - }, - ), + 'Servicio a domicilio', domicilioValue, toggleDomicilio), const Divider(), - customSwitch( - 'Servicio en sitio', - sitioValue, - (value) { - sitioValue = value; - }, - ), + customSwitch('Servicio en sitio', sitioValue, toggleSitio), sitioValue ? Padding( padding: @@ -540,7 +549,7 @@ class _ProfileProScreenState extends State { TableCell( child: Container( padding: const EdgeInsets.all(8.0), - child: Text('Lunes'), + child: const Text('Lunes'), ), ), TableCell( @@ -672,7 +681,8 @@ class _ProfileProScreenState extends State { ); } - customSwitch(String text, bool switchValue, ValueChanged onChanged) { + Widget customSwitch( + String text, bool switchValue, ValueChanged onChanged) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: SizedBox( @@ -680,22 +690,19 @@ class _ProfileProScreenState extends State { child: Row( children: [ Expanded( - child: Text( - text, - style: const TextStyle( - fontSize: 15, - color: Colors.black, + child: Text( + text, + style: const TextStyle( + fontSize: 15, + color: Colors.black, + ), ), - )), + ), Transform.scale( scale: 1.2, child: Switch( value: switchValue, - onChanged: (bool newValue) { - setState(() { - onChanged(newValue); - }); - }, + onChanged: onChanged, ), ), ], diff --git a/lib/src/screens/profile_pro_web.dart b/lib/src/screens/profile_pro_web.dart index cd7cfdc..9f2356d 100644 --- a/lib/src/screens/profile_pro_web.dart +++ b/lib/src/screens/profile_pro_web.dart @@ -33,7 +33,7 @@ class _ProfileProWebScreenState extends State { double latUser = 0.0; double lngUser = 0.0; - bool domicilioValue = false; + bool domicilioValue = true; bool tarifaValue = false; bool sitioValue = false; var photoTemp = ''; @@ -314,6 +314,24 @@ class _ProfileProWebScreenState extends State { } } + void toggleDomicilio(bool newValue) { + setState(() { + domicilioValue = newValue; + if (newValue == false && sitioValue == false) { + sitioValue = true; + } + }); + } + + void toggleSitio(bool newValue) { + setState(() { + sitioValue = newValue; + if (newValue == false && domicilioValue == false) { + domicilioValue = true; + } + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -368,20 +386,9 @@ class _ProfileProWebScreenState extends State { ), if (settings?.domicilios == true) customSwitch( - 'Servicio a domicilio', - domicilioValue, - (value) { - domicilioValue = value; - }, - ), + 'Servicio a domicilio', domicilioValue, toggleDomicilio), const Divider(), - customSwitch( - 'Servicio en sitio', - sitioValue, - (value) { - sitioValue = value; - }, - ), + customSwitch('Servicio en sitio', sitioValue, toggleSitio), sitioValue ? Padding( padding: @@ -589,7 +596,8 @@ class _ProfileProWebScreenState extends State { ); } - customSwitch(String text, bool switchValue, ValueChanged onChanged) { + Widget customSwitch( + String text, bool switchValue, ValueChanged onChanged) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: SizedBox( @@ -597,22 +605,19 @@ class _ProfileProWebScreenState extends State { child: Row( children: [ Expanded( - child: Text( - text, - style: const TextStyle( - fontSize: 15, - color: Colors.black, + child: Text( + text, + style: const TextStyle( + fontSize: 15, + color: Colors.black, + ), ), - )), + ), Transform.scale( scale: 1.2, child: Switch( value: switchValue, - onChanged: (bool newValue) { - setState(() { - onChanged(newValue); - }); - }, + onChanged: onChanged, ), ), ], diff --git a/lib/src/screens/service.dart b/lib/src/screens/service.dart index 95cf0eb..52792c5 100644 --- a/lib/src/screens/service.dart +++ b/lib/src/screens/service.dart @@ -261,7 +261,7 @@ class _ServiceScreenState extends State { } void _checkForUpdate(String? settings) { - if (appVersion == settings) { + if (appVersion != settings) { showDialog( context: context, builder: (context) { diff --git a/lib/src/screens/web_view.dart b/lib/src/screens/web_view.dart index 066ffcc..dabae38 100644 --- a/lib/src/screens/web_view.dart +++ b/lib/src/screens/web_view.dart @@ -12,16 +12,30 @@ class WebViewScreen extends StatefulWidget { } class _WebViewScreenState extends State { + bool isLoading = true; + + late WebViewController controller; + @override - Widget build(BuildContext context) { - final controller = WebViewController() + void initState() { + super.initState(); + + controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setBackgroundColor(const Color(0x00000000)) ..setNavigationDelegate( NavigationDelegate( onProgress: (int progress) {}, - onPageStarted: (String url) {}, - onPageFinished: (String url) {}, + onPageStarted: (String url) { + setState(() { + isLoading = true; + }); + }, + onPageFinished: (String url) { + setState(() { + isLoading = false; + }); + }, onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) { if (request.url.startsWith('https://www.youtube.com/')) { @@ -32,6 +46,10 @@ class _WebViewScreenState extends State { ), ) ..loadRequest(Uri.parse(widget.link)); + } + + @override + Widget build(BuildContext context) { return Scaffold( appBar: PopAppbar( onPressed: () { @@ -41,7 +59,10 @@ class _WebViewScreenState extends State { ), body: Stack( children: [ - const Center(child: CircularProgressIndicator()), + if (isLoading) + const Center(child: CircularProgressIndicator()) + else + const SizedBox(), WebViewWidget(controller: controller), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index d0d2e04..174bcb3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: url_launcher: ^6.1.10 community_material_icon: ^5.9.55 flutter_email_sender: ^5.2.0 - webview_flutter: ^4.2.0 + webview_flutter: ^4.4.1 firebase_storage: ^11.2.2 responsive_builder: ^0.7.0 flutter_local_notifications: ^14.1.1