2020-09-26 20:27:15 +02:00
|
|
|
import 'dart:io';
|
|
|
|
|
2021-05-22 08:53:52 +02:00
|
|
|
import 'package:fluffychat/widgets/sentry_switch_list_tile.dart';
|
2020-09-26 20:27:15 +02:00
|
|
|
import 'package:flutter/foundation.dart';
|
2021-01-17 15:43:38 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-06-20 00:24:39 +02:00
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
2021-01-17 15:43:38 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2021-06-26 10:43:07 +02:00
|
|
|
import 'package:vrouter/vrouter.dart';
|
2021-01-17 15:43:38 +01:00
|
|
|
|
2021-04-09 16:29:48 +02:00
|
|
|
import '../config/app_config.dart';
|
2020-09-26 20:27:15 +02:00
|
|
|
|
|
|
|
abstract class PlatformInfos {
|
|
|
|
static bool get isWeb => kIsWeb;
|
2021-02-07 17:18:38 +01:00
|
|
|
static bool get isLinux => !kIsWeb && Platform.isLinux;
|
|
|
|
static bool get isWindows => !kIsWeb && Platform.isWindows;
|
|
|
|
static bool get isMacOS => !kIsWeb && Platform.isMacOS;
|
|
|
|
static bool get isIOS => !kIsWeb && Platform.isIOS;
|
|
|
|
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
2020-10-04 16:11:18 +02:00
|
|
|
|
2021-02-07 17:18:38 +01:00
|
|
|
static bool get isCupertinoStyle => isIOS || isMacOS;
|
2020-11-22 22:48:10 +01:00
|
|
|
|
2021-02-07 17:18:38 +01:00
|
|
|
static bool get isMobile => isAndroid || isIOS;
|
2020-10-04 16:11:18 +02:00
|
|
|
|
|
|
|
/// For desktops which don't support ChachedNetworkImage yet
|
2021-02-07 17:18:38 +01:00
|
|
|
static bool get isBetaDesktop => isWindows || isLinux;
|
2020-10-04 16:11:18 +02:00
|
|
|
|
2021-02-07 17:18:38 +01:00
|
|
|
static bool get isDesktop => isLinux || isWindows || isMacOS;
|
2020-10-28 08:05:10 +01:00
|
|
|
|
2020-09-26 20:27:15 +02:00
|
|
|
static bool get usesTouchscreen => !isMobile;
|
2021-01-17 15:43:38 +01:00
|
|
|
|
2021-02-07 17:18:38 +01:00
|
|
|
static String get clientName =>
|
2021-06-20 12:44:09 +02:00
|
|
|
'${AppConfig.applicationName} ${isWeb ? 'web' : Platform.operatingSystem}${kReleaseMode ? '' : 'Debug'}';
|
2021-02-07 17:18:38 +01:00
|
|
|
|
2021-01-17 15:43:38 +01:00
|
|
|
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 {
|
2021-04-14 10:37:15 +02:00
|
|
|
final version = await PlatformInfos.getVersion();
|
2021-01-17 15:43:38 +01:00
|
|
|
showAboutDialog(
|
|
|
|
context: context,
|
2021-05-23 15:02:36 +02:00
|
|
|
useRootNavigator: false,
|
2021-01-17 15:43:38 +01:00
|
|
|
children: [
|
|
|
|
Text('Version: $version'),
|
2021-03-04 12:28:06 +01:00
|
|
|
OutlinedButton(
|
2021-01-17 15:43:38 +01:00
|
|
|
onPressed: () => launch(AppConfig.sourceCodeUrl),
|
2021-03-04 12:28:06 +01:00
|
|
|
child: Text(L10n.of(context).sourceCode),
|
2021-01-17 15:43:38 +01:00
|
|
|
),
|
2021-03-04 12:28:06 +01:00
|
|
|
OutlinedButton(
|
2021-01-20 19:53:19 +01:00
|
|
|
onPressed: () => launch(AppConfig.emojiFontUrl),
|
2021-03-04 12:28:06 +01:00
|
|
|
child: Text(AppConfig.emojiFontName),
|
2021-01-17 15:43:38 +01:00
|
|
|
),
|
2021-06-26 10:43:07 +02:00
|
|
|
OutlinedButton(
|
2021-07-08 17:10:20 +02:00
|
|
|
onPressed: () => VRouter.of(context).to('logs'),
|
2021-06-26 10:43:07 +02:00
|
|
|
child: Text('Logs'),
|
|
|
|
),
|
2021-01-22 21:39:37 +01:00
|
|
|
SentrySwitchListTile(label: L10n.of(context).sendBugReports),
|
2021-01-17 15:43:38 +01:00
|
|
|
],
|
2021-01-22 21:39:37 +01:00
|
|
|
applicationIcon: Image.asset('assets/logo.png', width: 64, height: 64),
|
2021-01-17 15:43:38 +01:00
|
|
|
applicationName: AppConfig.applicationName,
|
|
|
|
);
|
|
|
|
}
|
2020-09-26 20:27:15 +02:00
|
|
|
}
|