Mostra a versao (via getVersion/package_info_plus) ao lado de um badge alpha e um aviso de que o app ainda esta em desenvolvimento.
202 lines
8.3 KiB
Dart
202 lines
8.3 KiB
Dart
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
|
|
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_linkify/flutter_linkify.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:material_ui/material_ui.dart' as m show Dialog, showDialog;
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:tatchat/config/setting_keys.dart';
|
|
import 'package:tatchat/l10n/l10n.dart';
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
import '../config/app_config.dart';
|
|
|
|
abstract class PlatformInfos {
|
|
static bool get isWeb => kIsWeb;
|
|
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;
|
|
|
|
static bool get isCupertinoStyle => isIOS || isMacOS;
|
|
|
|
static bool get isMobile => isAndroid || isIOS;
|
|
|
|
/// For desktops which don't support ChachedNetworkImage yet
|
|
static bool get isBetaDesktop => isWindows || isLinux;
|
|
|
|
static bool get isDesktop => isLinux || isWindows || isMacOS;
|
|
|
|
static bool get usesTouchscreen => !isMobile;
|
|
|
|
static bool get supportsVideoPlayer =>
|
|
!PlatformInfos.isWindows && !PlatformInfos.isLinux;
|
|
|
|
static bool get supportsCustomImageResizer =>
|
|
PlatformInfos.isWeb || PlatformInfos.isMobile;
|
|
|
|
/// Web could also record in theory but currently creates broken opus
|
|
static bool get platformCanRecord => (isMobile || isMacOS);
|
|
|
|
static bool get supportsAppLock => (isMobile || isMacOS);
|
|
|
|
static String get appDisplayName =>
|
|
'${AppSettings.applicationName.value} ${isWeb ? 'web' : Platform.operatingSystem}${kReleaseMode ? '' : 'Debug'}';
|
|
|
|
static Future<String> getVersion() async {
|
|
var version = kIsWeb ? 'Web' : 'Unknown';
|
|
try {
|
|
version = (await PackageInfo.fromPlatform()).version;
|
|
} catch (_) {}
|
|
return version;
|
|
}
|
|
|
|
static const String aboutDescription =
|
|
'O TatuChat é um cliente de mensagens instantâneas focado em '
|
|
'privacidade, simplicidade e código aberto, desenvolvido como um fork do '
|
|
'aclamado projeto FluffyChat. Utilizando o protocolo descentralizado '
|
|
'Matrix, ele oferece criptografia de ponta a ponta (E2EE) para proteger '
|
|
'conversas, arquivos e mídias. Além do bate-papo tradicional, o projeto '
|
|
'se destaca por recursos como canais de transmissão, organização em '
|
|
'espaços, murais visuais em formato de grid e suporte a mini-apps '
|
|
'desenvolvidos pela comunidade. Acesse Aqui. '
|
|
'https://tatuchat.weltonmoura.com.br/home/';
|
|
|
|
static Future<void> showDialog(BuildContext context) async {
|
|
final l10n = L10n.of(context);
|
|
final theme = Theme.of(context);
|
|
final size = MediaQuery.sizeOf(context);
|
|
final version = await getVersion();
|
|
if (!context.mounted) return;
|
|
await m.showDialog<void>(
|
|
context: context,
|
|
builder: (context) => m.Dialog(
|
|
insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 40),
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: 720,
|
|
maxHeight: size.height * 0.88,
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: .min,
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: .min,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(32),
|
|
child: Image.asset(
|
|
'./assets/logo/mini/logo_mini.png',
|
|
width: 96,
|
|
height: 96,
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
AppSettings.applicationName.value,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.headlineMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
l10n.versionWithNumber(version),
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8,
|
|
vertical: 2,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: theme.colorScheme.tertiaryContainer,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Text(
|
|
'alpha',
|
|
style: theme.textTheme.labelMedium?.copyWith(
|
|
color: theme.colorScheme.onTertiaryContainer,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'Esta versão ainda está em fase alpha: o '
|
|
'aplicativo está em desenvolvimento e ainda pode '
|
|
'apresentar erros.',
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Linkify(
|
|
text: aboutDescription,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: theme.colorScheme.onSurface),
|
|
options: const LinkifyOptions(humanize: false),
|
|
linkStyle: TextStyle(
|
|
color: theme.colorScheme.primary,
|
|
decorationColor: theme.colorScheme.primary,
|
|
),
|
|
onOpen: (link) => launchUrlString(link.url),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
const Divider(),
|
|
const SizedBox(height: 8),
|
|
Wrap(
|
|
alignment: WrapAlignment.end,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
spacing: 8,
|
|
runSpacing: 4,
|
|
children: [
|
|
TextButton.icon(
|
|
onPressed: () => launchUrlString(AppConfig.sourceCodeUrl),
|
|
icon: const Icon(Icons.source_outlined),
|
|
label: Text(l10n.sourceCode),
|
|
),
|
|
TextButton.icon(
|
|
onPressed: () => launchUrlString(AppConfig.licenseUrl),
|
|
icon: const Icon(Icons.description_outlined),
|
|
label: Text(l10n.licence),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: Text(l10n.close),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|