refactor: Improved UX for room upgrades

pull/1683/head
Krille 6 months ago
parent 730fb22be3
commit b645193f7b
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -3205,5 +3205,6 @@
"takeAPhoto": "Take a photo", "takeAPhoto": "Take a photo",
"recordAVideo": "Record a video", "recordAVideo": "Record a video",
"optionalMessage": "(Optional) message...", "optionalMessage": "(Optional) message...",
"notSupportedOnThisDevice": "Not supported on this device" "notSupportedOnThisDevice": "Not supported on this device",
"enterNewChat": "Enter new chat"
} }

@ -36,7 +36,7 @@ abstract class SettingKeys {
'chat.fluffy.display_chat_details_column'; 'chat.fluffy.display_chat_details_column';
static const String noEncryptionWarningShown = static const String noEncryptionWarningShown =
'chat.fluffy.no_encryption_warning_shown'; 'chat.fluffy.no_encryption_warning_shown';
static const String shareKeysWith = 'chat.fluffy.share_keys_with'; static const String shareKeysWith = 'chat.fluffy.share_keys_with_2';
} }
enum AppSettings<T> { enum AppSettings<T> {

@ -1050,35 +1050,23 @@ class ChatController extends State<ChatPageWithRoom>
} }
void goToNewRoomAction() async { void goToNewRoomAction() async {
if (OkCancelResult.ok !=
await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).goToTheNewRoom,
message: room
.getState(EventTypes.RoomTombstone)!
.parsedTombstoneContent
.body,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
)) {
return;
}
final result = await showFutureLoadingDialog( final result = await showFutureLoadingDialog(
context: context, context: context,
future: () async { future: () => room.client.joinRoom(
final roomId = room.client.joinRoom( room
room .getState(EventTypes.RoomTombstone)!
.getState(EventTypes.RoomTombstone)! .parsedTombstoneContent
.parsedTombstoneContent .replacementRoom,
.replacementRoom, ),
); );
await room.leave(); if (result.error != null) return;
return roomId; if (!mounted) return;
}, context.go('/rooms/${result.result!}');
await showFutureLoadingDialog(
context: context,
future: room.leave,
); );
if (result.error == null) {
context.go('/rooms/${result.result!}');
}
} }
void onSelectMessage(Event event) { void onSelectMessage(Event event) {

@ -169,11 +169,6 @@ class ChatView extends StatelessWidget {
if (scrollUpBannerEventId != null) { if (scrollUpBannerEventId != null) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight; appbarBottomHeight += ChatAppBarListTile.fixedHeight;
} }
final tombstoneEvent =
controller.room.getState(EventTypes.RoomTombstone);
if (tombstoneEvent != null) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight;
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
actionsIconTheme: IconThemeData( actionsIconTheme: IconThemeData(
@ -212,18 +207,6 @@ class ChatView extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
PinnedEvents(controller), PinnedEvents(controller),
if (tombstoneEvent != null)
ChatAppBarListTile(
title: tombstoneEvent.parsedTombstoneContent.body,
leading: const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.upgrade_outlined),
),
trailing: TextButton(
onPressed: controller.goToNewRoomAction,
child: Text(L10n.of(context).goToTheNewRoom),
),
),
if (scrollUpBannerEventId != null) if (scrollUpBannerEventId != null)
ChatAppBarListTile( ChatAppBarListTile(
leading: IconButton( leading: IconButton(
@ -300,7 +283,21 @@ class ChatView extends StatelessWidget {
child: ChatEventList(controller: controller), child: ChatEventList(controller: controller),
), ),
), ),
if (controller.room.canSendDefaultMessages && if (controller.room.isExtinct)
Container(
margin: EdgeInsets.only(
bottom: bottomSheetPadding,
left: bottomSheetPadding,
right: bottomSheetPadding,
),
width: double.infinity,
child: ElevatedButton.icon(
icon: const Icon(Icons.chevron_right),
label: Text(L10n.of(context).enterNewChat),
onPressed: controller.goToNewRoomAction,
),
)
else if (controller.room.canSendDefaultMessages &&
controller.room.membership == Membership.join) controller.room.membership == Membership.join)
Container( Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(

@ -1,6 +1,7 @@
import 'package:flutter/material.dart' hide Visibility; import 'package:flutter/material.dart' hide Visibility;
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/chat_access_settings/chat_access_settings_page.dart'; import 'package:fluffychat/pages/chat_access_settings/chat_access_settings_page.dart';
@ -179,10 +180,13 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
)) { )) {
return; return;
} }
await showFutureLoadingDialog( final result = await showFutureLoadingDialog(
context: context, context: context,
future: () => room.client.upgradeRoom(room.id, newVersion), future: () => room.client.upgradeRoom(room.id, newVersion),
); );
if (result.error != null) return;
if (!mounted) return;
context.go('/rooms/${room.id}');
} }
Future<void> addAlias() async { Future<void> addAlias() async {

Loading…
Cancel
Save