design: Add snackbar with link to changelog on new version

This commit is contained in:
Krille 2024-07-31 15:23:25 +02:00
commit e5bbb755d9
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
6 changed files with 69 additions and 6 deletions

View file

@ -35,6 +35,8 @@ abstract class AppConfig {
'https://github.com/krille-chan/fluffychat';
static const String supportUrl =
'https://github.com/krille-chan/fluffychat/issues';
static const String changelogUrl =
'https://github.com/krille-chan/fluffychat/blob/main/CHANGELOG.md';
static final Uri newIssueUrl = Uri(
scheme: 'https',
host: 'github.com',

View file

@ -77,9 +77,6 @@ abstract class FluffyThemes {
? Typography.material2018().black.merge(fallbackTextTheme)
: Typography.material2018().white.merge(fallbackTextTheme)
: null,
snackBarTheme: const SnackBarThemeData(
behavior: SnackBarBehavior.floating,
),
dividerColor: brightness == Brightness.light
? Colors.blueGrey.shade50
: Colors.blueGrey.shade900,

View file

@ -21,6 +21,7 @@ import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/show_update_snackbar.dart';
import 'package:fluffychat/widgets/avatar.dart';
import '../../../utils/account_bundles.dart';
import '../../config/setting_keys.dart';
@ -511,6 +512,7 @@ class ChatListController extends State<ChatList>
searchServer =
Matrix.of(context).store.getString(_serverStoreNamespace);
Matrix.of(context).backgroundPush?.setupPush();
UpdateNotifier.showUpdateSnackBar(context);
}
// Workaround for system UI overlay style not applied on app start

View file

@ -68,7 +68,9 @@ class ClientChooserButton extends StatelessWidget {
],
),
),
PopupMenuItem(
// Currently disabled because of:
// https://github.com/matrix-org/matrix-react-sdk/pull/12286
/*PopupMenuItem(
value: SettingsAction.archive,
child: Row(
children: [
@ -77,7 +79,7 @@ class ClientChooserButton extends StatelessWidget {
Text(L10n.of(context)!.archive),
],
),
),
),*/
PopupMenuItem(
value: SettingsAction.settings,
child: Row(

View file

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart';
abstract class UpdateNotifier {
static const String versionStoreKey = 'last_known_version';
static void showUpdateSnackBar(BuildContext context) async {
final scaffoldMessenger = ScaffoldMessenger.of(context);
final currentVersion = await PlatformInfos.getVersion();
final store = await SharedPreferences.getInstance();
final storedVersion = store.getString(versionStoreKey);
if (currentVersion != storedVersion) {
if (storedVersion != null) {
ScaffoldFeatureController? controller;
controller = scaffoldMessenger.showSnackBar(
SnackBar(
duration: const Duration(seconds: 30),
content: Row(
children: [
IconButton(
icon: Icon(
Icons.close_outlined,
size: 20,
color: Theme.of(context).colorScheme.onPrimary,
),
onPressed: () => controller?.close(),
),
Expanded(
child: Text(
L10n.of(context)!.updateInstalled(currentVersion),
),
),
],
),
action: SnackBarAction(
label: L10n.of(context)!.changelog,
onPressed: () => launchUrlString(AppConfig.changelogUrl),
),
),
);
}
await store.setString(versionStoreKey, currentVersion);
}
}
}