1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-22 22:43:22 +00:00

Show deprecation warning

This commit is contained in:
Pierre HUBERT 2021-02-20 09:24:51 +01:00
parent 1b0a3fd24b
commit 0cd9371460
7 changed files with 54 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import 'package:comunic/models/api_request.dart';
import 'package:comunic/models/server_config.dart';
import 'package:version/version.dart';
/// Server configuration helper
///
@ -20,6 +21,8 @@ class ServerConfigurationHelper {
final dataConservationPolicy = response["data_conservation_policy"];
_config = ServerConfig(
minSupportedMobileVersion:
Version.parse(response["min_supported_mobile_version"]),
passwordPolicy: PasswordPolicy(
allowMailInPassword: passwordPolicy["allow_email_in_password"],
allowNameInPassword: passwordPolicy["allow_name_in_password"],

View File

@ -1,4 +1,5 @@
import 'package:package_info/package_info.dart';
import 'package:version/version.dart';
/// Application version helper
///
@ -13,4 +14,7 @@ class VersionHelper {
/// Get current version information
static PackageInfo get info => _info;
/// Get current application version, in parsed format
static Version get version => Version.parse(info.version);
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:version/version.dart';
/// Server static configuration
///
@ -57,12 +58,15 @@ class ServerDataConservationPolicy {
}
class ServerConfig {
final Version minSupportedMobileVersion;
final PasswordPolicy passwordPolicy;
final ServerDataConservationPolicy dataConservationPolicy;
const ServerConfig({
@required this.minSupportedMobileVersion,
@required this.passwordPolicy,
@required this.dataConservationPolicy,
}) : assert(passwordPolicy != null),
}) : assert(minSupportedMobileVersion != null),
assert(passwordPolicy != null),
assert(dataConservationPolicy != null);
}

View File

@ -0,0 +1,28 @@
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart';
/// Deprecation dialog
///
/// @author Pierre Hubert
/// Show a dialog to warn the user this version of the application is deprecated
Future<void> showDeprecationDialog(BuildContext context) async {
await showDialog(context: context, builder: (c) => _DeprecationDialog());
}
class _DeprecationDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(tr("Deprecated application version")),
content: Text(tr(
"This version of the mobile application is deprecated. You might still be able to use it, but some features will not work. We recommend you to update to the latest version of the application.")),
actions: [
MaterialButton(
onPressed: () => Navigator.pop(context),
child: Text(tr("OK")),
)
],
);
}
}

View File

@ -3,6 +3,7 @@ import 'package:comunic/helpers/events_helper.dart';
import 'package:comunic/helpers/server_config_helper.dart';
import 'package:comunic/helpers/version_helper.dart';
import 'package:comunic/helpers/websocket_helper.dart';
import 'package:comunic/ui/dialogs/deprecation_dialog.dart';
import 'package:comunic/ui/routes/login_route.dart';
import 'package:comunic/ui/routes/main_route/main_route.dart';
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
@ -62,6 +63,9 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
try {
await ServerConfigurationHelper.ensureLoaded();
if (ServerConfigurationHelper.config.minSupportedMobileVersion > VersionHelper.version)
await showDeprecationDialog(context);
if (!AccountHelper.isUserIDLoaded) {
_popToMainRoute();
_openLoginPage();

View File

@ -630,6 +630,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version:
dependency: "direct main"
description:
name: version
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
wakelock:
dependency: "direct main"
description:

View File

@ -88,6 +88,9 @@ dependencies:
# Get information about current version
package_info: ^0.4.3+4
# Version manager
version: ^1.2.0
dev_dependencies:
flutter_test:
sdk: flutter