design: New chat access settings
This commit is contained in:
parent
cbdea13772
commit
c300220773
11 changed files with 499 additions and 355 deletions
|
|
@ -2,7 +2,6 @@ import 'dart:developer';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
|
@ -71,44 +70,6 @@ class ChatPermissionsSettingsController extends State<ChatPermissionsSettings> {
|
|||
false),
|
||||
);
|
||||
|
||||
void updateRoomAction(Capabilities capabilities) async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final roomVersion = room
|
||||
.getState(EventTypes.RoomCreate)!
|
||||
.content['room_version'] as String? ??
|
||||
'1';
|
||||
final newVersion = await showConfirmationDialog<String>(
|
||||
context: context,
|
||||
title: L10n.of(context)!.replaceRoomWithNewerVersion,
|
||||
actions: capabilities.mRoomVersions!.available.entries
|
||||
.where((r) => r.key != roomVersion)
|
||||
.map(
|
||||
(version) => AlertDialogAction(
|
||||
key: version.key,
|
||||
label:
|
||||
'${version.key} (${version.value.toString().split('.').last})',
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
if (newVersion == null ||
|
||||
OkCancelResult.cancel ==
|
||||
await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
okLabel: L10n.of(context)!.yes,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
message: L10n.of(context)!.roomUpgradeDescription,
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client.upgradeRoom(roomId!, newVersion),
|
||||
).then((_) => context.pop());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ChatPermissionsSettingsView(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
entry.value,
|
||||
),
|
||||
),
|
||||
const Divider(thickness: 1),
|
||||
Divider(color: Theme.of(context).dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.notifications,
|
||||
|
|
@ -87,7 +87,7 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
const Divider(thickness: 1),
|
||||
Divider(color: Theme.of(context).dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.configureChat,
|
||||
|
|
@ -109,33 +109,6 @@ class ChatPermissionsSettingsView extends StatelessWidget {
|
|||
category: 'events',
|
||||
),
|
||||
),
|
||||
if (room.canSendEvent(EventTypes.RoomTombstone)) ...{
|
||||
const Divider(thickness: 1),
|
||||
FutureBuilder<Capabilities>(
|
||||
future: room.client.getCapabilities(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
);
|
||||
}
|
||||
final roomVersion = room
|
||||
.getState(EventTypes.RoomCreate)!
|
||||
.content['room_version'] as String? ??
|
||||
'1';
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
'${L10n.of(context)!.roomVersion}: $roomVersion',
|
||||
),
|
||||
onTap: () =>
|
||||
controller.updateRoomAction(snapshot.data!),
|
||||
);
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue