mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 14:32:37 +01:00
feat: Display version number in app
This commit is contained in:
parent
3c713518fb
commit
e1e60c4d71
@ -1,6 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../app_config.dart';
|
||||
|
||||
abstract class PlatformInfos {
|
||||
static bool get isWeb => kIsWeb;
|
||||
@ -18,4 +24,32 @@ abstract class PlatformInfos {
|
||||
!kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS);
|
||||
|
||||
static bool get usesTouchscreen => !isMobile;
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
var version = kIsWeb ? 'Web' : 'Unknown';
|
||||
try {
|
||||
version = (await PackageInfo.fromPlatform()).version;
|
||||
} catch (_) {}
|
||||
return version;
|
||||
}
|
||||
|
||||
static void showDialog(BuildContext context) async {
|
||||
var version = await PlatformInfos.getVersion();
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
children: [
|
||||
Text('Version: $version'),
|
||||
RaisedButton(
|
||||
child: Text(L10n.of(context).sourceCode),
|
||||
onPressed: () => launch(AppConfig.sourceCodeUrl),
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text(L10n.of(context).help),
|
||||
onPressed: () => launch(AppConfig.supportUrl),
|
||||
),
|
||||
],
|
||||
applicationIcon: Image.asset('assets/logo.png', width: 100, height: 100),
|
||||
applicationName: AppConfig.applicationName,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:fluffychat/components/sentry_switch_list_tile.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flushbar/flushbar_helper.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -136,22 +137,7 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
onPressed: () => showAboutDialog(
|
||||
context: context,
|
||||
children: [
|
||||
RaisedButton(
|
||||
child: Text(L10n.of(context).sourceCode),
|
||||
onPressed: () => launch(AppConfig.sourceCodeUrl),
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text(L10n.of(context).help),
|
||||
onPressed: () => launch(AppConfig.supportUrl),
|
||||
),
|
||||
],
|
||||
applicationIcon: Image.asset('assets/logo.png',
|
||||
width: 100, height: 100),
|
||||
applicationName: AppConfig.applicationName,
|
||||
),
|
||||
onPressed: () => PlatformInfos.showDialog(context),
|
||||
),
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
@ -578,21 +578,16 @@ class _SettingsState extends State<Settings> {
|
||||
title: Text(L10n.of(context).privacy),
|
||||
onTap: () => launch(AppConfig.privacyUrl),
|
||||
),
|
||||
ListTile(
|
||||
trailing: Icon(Icons.link_outlined),
|
||||
title: Text(L10n.of(context).license),
|
||||
onTap: () => showLicensePage(
|
||||
context: context,
|
||||
applicationIcon:
|
||||
Image.asset('assets/logo.png', width: 100, height: 100),
|
||||
applicationName: AppConfig.applicationName,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
trailing: Icon(Icons.code_outlined),
|
||||
title: Text(L10n.of(context).sourceCode),
|
||||
onTap: () => launch(AppConfig.sourceCodeUrl),
|
||||
),
|
||||
ListTile(
|
||||
trailing: Icon(Icons.link_outlined),
|
||||
title: Text(L10n.of(context).about),
|
||||
onTap: () => PlatformInfos.showDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -705,12 +705,12 @@ packages:
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
package_info:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
version: "0.4.3+2"
|
||||
password_hash:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -68,6 +68,7 @@ dependencies:
|
||||
open_noti_settings: ^0.0.4
|
||||
emoji_picker: ^0.1.0
|
||||
future_loading_dialog: ^0.1.2
|
||||
package_info: ^0.4.3+2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user