116 lines
3.3 KiB
Dart
116 lines
3.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:injector/injector.dart';
|
|
import 'package:package_info_plus/package_info_plus.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';
|
|
import 'dart:io' show Platform;
|
|
|
|
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,
|
|
),
|
|
Platform.isIOS
|
|
? GeneralDrawerItem(
|
|
label: 'Versión de la aplicación',
|
|
subtitle: settings?.versionIos,
|
|
)
|
|
: Container(),
|
|
Platform.isAndroid
|
|
? GeneralDrawerItem(
|
|
label: 'Versión de la aplicación',
|
|
subtitle: settings?.versionAndroid,
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|