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",
"recordAVideo": "Record a video",
"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';
static const String noEncryptionWarningShown =
'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> {

@ -1050,35 +1050,23 @@ class ChatController extends State<ChatPageWithRoom>
}
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(
context: context,
future: () async {
final roomId = room.client.joinRoom(
room
.getState(EventTypes.RoomTombstone)!
.parsedTombstoneContent
.replacementRoom,
);
await room.leave();
return roomId;
},
future: () => room.client.joinRoom(
room
.getState(EventTypes.RoomTombstone)!
.parsedTombstoneContent
.replacementRoom,
),
);
if (result.error != null) return;
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) {

@ -169,11 +169,6 @@ class ChatView extends StatelessWidget {
if (scrollUpBannerEventId != null) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight;
}
final tombstoneEvent =
controller.room.getState(EventTypes.RoomTombstone);
if (tombstoneEvent != null) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight;
}
return Scaffold(
appBar: AppBar(
actionsIconTheme: IconThemeData(
@ -212,18 +207,6 @@ class ChatView extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
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)
ChatAppBarListTile(
leading: IconButton(
@ -300,7 +283,21 @@ class ChatView extends StatelessWidget {
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)
Container(
margin: EdgeInsets.only(

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

Loading…
Cancel
Save