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": {
"type": "text",
"space": {}
}
},
"markAsUnread": "Mark as unread"
}

@ -619,7 +619,7 @@ class ChatListController extends State<ChatList>
if (space != null)
SheetAction(
key: ChatContextAction.goToSpace,
icon: Icons.workspaces_outlined,
icon: Icons.chevron_right_outlined,
label: L10n.of(context)!.goToSpace(space.getLocalizedDisplayname()),
),
SheetAction(
@ -627,11 +627,13 @@ class ChatListController extends State<ChatList>
icon: room.markedUnread
? Icons.mark_as_unread
: Icons.mark_as_unread_outlined,
label: L10n.of(context)!.toggleUnread,
label: room.markedUnread
? L10n.of(context)!.markAsRead
: L10n.of(context)!.markAsUnread,
),
SheetAction(
key: ChatContextAction.favorite,
icon: room.isFavourite ? Icons.pin : Icons.pin_outlined,
icon: room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined,
label: room.isFavourite
? L10n.of(context)!.unpin
: L10n.of(context)!.pin,
@ -640,7 +642,7 @@ class ChatListController extends State<ChatList>
key: ChatContextAction.mute,
icon: room.pushRuleState == PushRuleState.notify
? Icons.notifications_off_outlined
: Icons.notifications,
: Icons.notifications_outlined,
label: room.pushRuleState == PushRuleState.notify
? L10n.of(context)!.muteChat
: L10n.of(context)!.unmuteChat,
@ -657,6 +659,19 @@ class ChatListController extends State<ChatList>
if (action == null) 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(
context: context,
future: () async {

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

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

Loading…
Cancel
Save