This commit is contained in:
Felipe
2023-10-28 16:04:44 -05:00
parent b2c8f15dae
commit efa8c37a88
5 changed files with 104 additions and 1 deletions
+9
View File
@@ -67,4 +67,13 @@ class SettingModel {
return SettingModel(false, false, '', '', '', '', '', '', '', '', '');
}
}
@override
String toString() {
return 'SettingModel { domicilios: $domicilios, tarifas: $tarifas, '
'titulo: $titulo, parrafo: $parrafo, numero: $numero, '
'email: $email, dias: $dias, horas: $horas, '
'version: $version, politicasPrivacidad: $proliticasPrivacidad, '
'terminosCondiciones: $terminosCondiciones }';
}
}
+75
View File
@@ -13,6 +13,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/drawer_menu.dart';
import 'package:prosappco/src/models/event_model.dart';
import 'package:prosappco/src/models/setting_model.dart';
import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/professional.dart';
import 'package:intl/intl.dart';
@@ -23,6 +24,8 @@ import 'package:prosappco/src/screens/service_type.dart';
import 'package:prosappco/src/screens/ubicacion.dart';
import 'package:http/http.dart' as http;
import 'package:prosappco/src/components/network_utility.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
class ServiceScreen extends StatefulWidget {
const ServiceScreen({super.key});
@@ -32,6 +35,10 @@ class ServiceScreen extends StatefulWidget {
}
class _ServiceScreenState extends State<ServiceScreen> {
late String appVersion;
final Uri _url = Uri.parse(
'https://play.google.com/store/apps/details?id=com.prosapp.prosapp');
void _saveToken() async {
FirebaseMessaging messaging = FirebaseMessaging.instance;
@@ -239,10 +246,78 @@ class _ServiceScreenState extends State<ServiceScreen> {
});
}
Future<void> _getAppVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version;
setState(() {
appVersion = version;
print('Version de app $appVersion - version de firebase $settings');
});
if (settings != null) {
_checkForUpdate(settings);
}
}
void _checkForUpdate(String? settings) {
if (appVersion != settings) {
showDialog(
context: context,
builder: (context) {
return WillPopScope(
onWillPop: () async {
return false;
},
child: Center(
child: AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
title: const Text(
"Debes Actualizar la Aplicación",
style: TextStyle(fontWeight: FontWeight.bold),
),
content: const Text(
"Tienes una versión desactualizada de nuestra aplicación. Te recomendamos actualizarla para disfrutar de las últimas características y mejoras.",
),
actions: [
TextButton(
child: const Text(
"Actualizar",
style:
TextStyle(fontWeight: FontWeight.w600, fontSize: 20),
),
onPressed: () {
launchUrl(_url);
},
),
],
),
),
);
},
);
}
}
String? settings;
@override
void initState() {
super.initState();
_getAppVersion();
if (settings == null) {
SettingModel.getSettings().then(
(SettingModel value) => setState(() {
settings = value.version;
_getAppVersion(); // Llama a _getAppVersion una vez que settings se haya cargado
}),
);
}
if (_ciudad == '...') {
AuthenticationRepository.instance
.getCity(uid.toString())