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';
|
|
|
|
import 'package:package_info/package_info.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
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-04-09 16:54:00 +02:00
|
|
|
'${AppConfig.applicationName} ${isWeb ? 'web' : Platform.operatingSystem}';
|
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,
|
|
|
|
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-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
|
|
|
}
|