chore: Follow up spaces ui

pull/1223/head
Krille 1 year ago
parent 3bd7257249
commit 650f87b1d2
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -2710,5 +2710,6 @@
"@goToSpace": { "@goToSpace": {
"type": "text", "type": "text",
"space": {} "space": {}
} },
"markAsUnread": "Mark as unread"
} }

@ -619,7 +619,7 @@ class ChatListController extends State<ChatList>
if (space != null) if (space != null)
SheetAction( SheetAction(
key: ChatContextAction.goToSpace, key: ChatContextAction.goToSpace,
icon: Icons.workspaces_outlined, icon: Icons.chevron_right_outlined,
label: L10n.of(context)!.goToSpace(space.getLocalizedDisplayname()), label: L10n.of(context)!.goToSpace(space.getLocalizedDisplayname()),
), ),
SheetAction( SheetAction(
@ -627,11 +627,13 @@ class ChatListController extends State<ChatList>
icon: room.markedUnread icon: room.markedUnread
? Icons.mark_as_unread ? Icons.mark_as_unread
: Icons.mark_as_unread_outlined, : Icons.mark_as_unread_outlined,
label: L10n.of(context)!.toggleUnread, label: room.markedUnread
? L10n.of(context)!.markAsRead
: L10n.of(context)!.markAsUnread,
), ),
SheetAction( SheetAction(
key: ChatContextAction.favorite, key: ChatContextAction.favorite,
icon: room.isFavourite ? Icons.pin : Icons.pin_outlined, icon: room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined,
label: room.isFavourite label: room.isFavourite
? L10n.of(context)!.unpin ? L10n.of(context)!.unpin
: L10n.of(context)!.pin, : L10n.of(context)!.pin,
@ -640,7 +642,7 @@ class ChatListController extends State<ChatList>
key: ChatContextAction.mute, key: ChatContextAction.mute,
icon: room.pushRuleState == PushRuleState.notify icon: room.pushRuleState == PushRuleState.notify
? Icons.notifications_off_outlined ? Icons.notifications_off_outlined
: Icons.notifications, : Icons.notifications_outlined,
label: room.pushRuleState == PushRuleState.notify label: room.pushRuleState == PushRuleState.notify
? L10n.of(context)!.muteChat ? L10n.of(context)!.muteChat
: L10n.of(context)!.unmuteChat, : L10n.of(context)!.unmuteChat,
@ -657,6 +659,19 @@ class ChatListController extends State<ChatList>
if (action == null) return; if (action == null) return;
if (!mounted) return; if (!mounted) return;
if (action == ChatContextAction.leave) {
final confirmed = await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.archiveRoomDescription,
);
if (confirmed == OkCancelResult.cancel) return;
}
if (!mounted) return;
await showFutureLoadingDialog( await showFutureLoadingDialog(
context: context, context: context,
future: () async { future: () async {

@ -22,14 +22,9 @@ class ChatListView extends StatelessWidget {
final selectMode = controller.selectMode; final selectMode = controller.selectMode;
return PopScope( return PopScope(
canPop: controller.selectMode == SelectMode.normal && canPop: controller.selectMode == SelectMode.normal &&
!controller.isSearchMode && !controller.isSearchMode,
controller.activeFilter == ActiveFilter.allChats, onPopInvoked: (pop) {
onPopInvoked: (pop) async {
if (pop) return; if (pop) return;
if (controller.activeSpaceId != null) {
controller.clearActiveSpace();
return;
}
final selMode = controller.selectMode; final selMode = controller.selectMode;
if (controller.isSearchMode) { if (controller.isSearchMode) {
controller.cancelSearch(); controller.cancelSearch();

@ -165,7 +165,10 @@ class _SpaceViewState extends State<SpaceView> {
final room = Matrix.of(context).client.getRoomById(widget.spaceId); final room = Matrix.of(context).client.getRoomById(widget.spaceId);
final displayname = final displayname =
room?.getLocalizedDisplayname() ?? L10n.of(context)!.nothingFound; room?.getLocalizedDisplayname() ?? L10n.of(context)!.nothingFound;
return Scaffold( return PopScope(
canPop: false,
onPopInvoked: (_) => widget.onBack(),
child: Scaffold(
appBar: AppBar( appBar: AppBar(
leading: Center( leading: Center(
child: CloseButton( child: CloseButton(
@ -249,25 +252,14 @@ class _SpaceViewState extends State<SpaceView> {
.where((s) => s.hasRoomUpdate) .where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)), .rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) { builder: (context, snapshot) {
final joinedRooms = room.spaceChildren final childrenIds = room.spaceChildren
.map((child) { .map((c) => c.roomId)
final roomId = child.roomId; .whereType<String>()
if (roomId == null) return null; .toSet();
return room.client.getRoomById(roomId);
})
.whereType<Room>()
.where((room) => room.membership != Membership.leave)
.toList();
// Sort rooms by last activity final joinedRooms = room.client.rooms
joinedRooms.sort( .where((room) => childrenIds.remove(room.id))
(b, a) => (a.lastEvent?.originServerTs ?? .toList();
DateTime.fromMillisecondsSinceEpoch(0))
.compareTo(
b.lastEvent?.originServerTs ??
DateTime.fromMillisecondsSinceEpoch(0),
),
);
final joinedParents = room.spaceParents final joinedParents = room.spaceParents
.map((parent) { .map((parent) {
@ -291,8 +283,9 @@ class _SpaceViewState extends State<SpaceView> {
onChanged: (_) => setState(() {}), onChanged: (_) => setState(() {}),
textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
decoration: InputDecoration( decoration: InputDecoration(
fillColor: fillColor: Theme.of(context)
Theme.of(context).colorScheme.secondaryContainer, .colorScheme
.secondaryContainer,
border: OutlineInputBorder( border: OutlineInputBorder(
borderSide: BorderSide.none, borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(99), borderRadius: BorderRadius.circular(99),
@ -455,7 +448,9 @@ class _SpaceViewState extends State<SpaceView> {
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
const Icon(Icons.add_circle_outline_outlined), const Icon(
Icons.add_circle_outline_outlined,
),
], ],
), ),
subtitle: Text( subtitle: Text(
@ -475,6 +470,7 @@ class _SpaceViewState extends State<SpaceView> {
); );
}, },
), ),
),
); );
} }
} }

Loading…
Cancel
Save