mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 08:15:09 +00:00
design: Add snackbar with link to changelog on new version
This commit is contained in:
parent
21e7c3f8cb
commit
e5bbb755d9
6 changed files with 69 additions and 6 deletions
|
@ -2746,5 +2746,13 @@
|
|||
"changeTheCanonicalRoomAlias": "Change the main public chat address",
|
||||
"sendRoomNotifications": "Send a @room notifications",
|
||||
"changeTheDescriptionOfTheGroup": "Change the description of the chat",
|
||||
"chatPermissionsDescription": "Define which power level is necessary for certain actions in this chat. The power levels 0, 50 and 100 are usually representing users, moderators and admins, but any gradation is possible."
|
||||
"chatPermissionsDescription": "Define which power level is necessary for certain actions in this chat. The power levels 0, 50 and 100 are usually representing users, moderators and admins, but any gradation is possible.",
|
||||
"updateInstalled": "🎉 Update {version} installed!",
|
||||
"@updateInstalled": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"version": {}
|
||||
}
|
||||
},
|
||||
"changelog": "Changelog"
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
52
lib/utils/show_update_snackbar.dart
Normal file
52
lib/utils/show_update_snackbar.dart
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue