mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Start to add support for Flutter Web
This commit is contained in:
parent
1aa39ea64f
commit
4a905174bf
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
// ignore_for_file: lines_longer_than_80_chars
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
|
|
||||||
// ignore: implementation_imports
|
|
||||||
import 'package:file_picker/src/file_picker_web.dart';
|
import 'package:file_picker/src/file_picker_web.dart';
|
||||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||||
import 'package:shared_preferences_web/shared_preferences_web.dart';
|
import 'package:shared_preferences_web/shared_preferences_web.dart';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:comunic/utils/flutter_utils.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
import 'package:version/version.dart';
|
import 'package:version/version.dart';
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ class VersionHelper {
|
|||||||
static PackageInfo _info;
|
static PackageInfo _info;
|
||||||
|
|
||||||
static Future<void> ensureLoaded() async {
|
static Future<void> ensureLoaded() async {
|
||||||
_info = await PackageInfo.fromPlatform();
|
if (!isWeb) _info = await PackageInfo.fromPlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get current version information
|
/// Get current version information
|
||||||
|
@ -3,6 +3,7 @@ import 'package:comunic/helpers/database/database_helper.dart';
|
|||||||
import 'package:comunic/helpers/preferences_helper.dart';
|
import 'package:comunic/helpers/preferences_helper.dart';
|
||||||
import 'package:comunic/helpers/version_helper.dart';
|
import 'package:comunic/helpers/version_helper.dart';
|
||||||
import 'package:comunic/ui/widgets/init_widget.dart';
|
import 'package:comunic/ui/widgets/init_widget.dart';
|
||||||
|
import 'package:comunic/utils/flutter_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -17,8 +18,10 @@ void subMain() async {
|
|||||||
await VersionHelper.ensureLoaded();
|
await VersionHelper.ensureLoaded();
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
await DatabaseHelper.open();
|
if(!isWeb) {
|
||||||
await DatabaseHelper.cleanUpDatabase();
|
await DatabaseHelper.open();
|
||||||
|
await DatabaseHelper.cleanUpDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
// Get current system language
|
// Get current system language
|
||||||
await initTranslations();
|
await initTranslations();
|
||||||
|
@ -9,6 +9,7 @@ import 'package:comunic/ui/routes/main_route/main_route.dart';
|
|||||||
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
|
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/tablet_route.dart';
|
import 'package:comunic/ui/routes/main_route/tablet_route.dart';
|
||||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
|
import 'package:comunic/utils/flutter_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -63,8 +64,9 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
try {
|
try {
|
||||||
await ServerConfigurationHelper.ensureLoaded();
|
await ServerConfigurationHelper.ensureLoaded();
|
||||||
|
|
||||||
if (ServerConfigurationHelper.config.minSupportedMobileVersion > VersionHelper.version)
|
if (!isWeb &&
|
||||||
await showDeprecationDialog(context);
|
ServerConfigurationHelper.config.minSupportedMobileVersion >
|
||||||
|
VersionHelper.version) await showDeprecationDialog(context);
|
||||||
|
|
||||||
if (!AccountHelper.isUserIDLoaded) {
|
if (!AccountHelper.isUserIDLoaded) {
|
||||||
_popToMainRoute();
|
_popToMainRoute();
|
||||||
@ -128,10 +130,12 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
Spacer(
|
Spacer(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
),
|
),
|
||||||
Text(tr("Version %version% - Build %build%", args: {
|
!isWeb
|
||||||
"version": VersionHelper.info.version.toString(),
|
? Text(tr("Version %version% - Build %build%", args: {
|
||||||
"build": VersionHelper.info.buildNumber.toString()
|
"version": VersionHelper.info.version.toString(),
|
||||||
})),
|
"build": VersionHelper.info.buildNumber.toString()
|
||||||
|
}))
|
||||||
|
: Container(),
|
||||||
Spacer(flex: 1),
|
Spacer(flex: 1),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
6
lib/utils/flutter_utils.dart
Normal file
6
lib/utils/flutter_utils.dart
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/// Flutter utilities
|
||||||
|
///
|
||||||
|
/// @author Pierre Hubert
|
||||||
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
|
bool get isWeb => kIsWeb;
|
Loading…
Reference in New Issue
Block a user