|
|
|
@ -14,6 +14,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
|
import '../../utils/localized_exception_extension.dart';
|
|
|
|
|
import '../../widgets/matrix.dart';
|
|
|
|
|
import 'chat_list_header.dart';
|
|
|
|
|
|
|
|
|
|
class SpaceView extends StatefulWidget {
|
|
|
|
|
final ChatListController controller;
|
|
|
|
@ -154,10 +155,13 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
itemCount: rootSpaces.length,
|
|
|
|
|
return CustomScrollView(
|
|
|
|
|
controller: widget.scrollController,
|
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
|
slivers: [
|
|
|
|
|
ChatListHeader(controller: widget.controller),
|
|
|
|
|
SliverList(
|
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
|
(context, i) {
|
|
|
|
|
final rootSpace = rootSpaces[i];
|
|
|
|
|
final displayname = rootSpace.getLocalizedDisplayname(
|
|
|
|
|
MatrixLocals(L10n.of(context)!),
|
|
|
|
@ -179,11 +183,16 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
.numChats(rootSpace.spaceChildren.length.toString()),
|
|
|
|
|
),
|
|
|
|
|
onTap: () => widget.controller.setActiveSpace(rootSpace.id),
|
|
|
|
|
onLongPress: () => _onSpaceChildContextMenu(null, rootSpace),
|
|
|
|
|
onLongPress: () =>
|
|
|
|
|
_onSpaceChildContextMenu(null, rootSpace),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
childCount: rootSpaces.length,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return FutureBuilder<GetSpaceHierarchyResponse>(
|
|
|
|
@ -208,7 +217,16 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (response == null) {
|
|
|
|
|
return const Center(child: CircularProgressIndicator.adaptive());
|
|
|
|
|
return CustomScrollView(
|
|
|
|
|
slivers: [
|
|
|
|
|
ChatListHeader(controller: widget.controller),
|
|
|
|
|
const SliverFillRemaining(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: CircularProgressIndicator.adaptive(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final parentSpace = allSpaces.firstWhereOrNull(
|
|
|
|
|
(space) =>
|
|
|
|
@ -224,10 +242,13 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
itemCount: spaceChildren.length + 1 + (canLoadMore ? 1 : 0),
|
|
|
|
|
child: CustomScrollView(
|
|
|
|
|
controller: widget.scrollController,
|
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
|
slivers: [
|
|
|
|
|
ChatListHeader(controller: widget.controller),
|
|
|
|
|
SliverList(
|
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
|
(context, i) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
return ListTile(
|
|
|
|
|
leading: BackButton(
|
|
|
|
@ -245,7 +266,8 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
icon: snapshot.connectionState != ConnectionState.done
|
|
|
|
|
? const CircularProgressIndicator.adaptive()
|
|
|
|
|
: const Icon(Icons.refresh_outlined),
|
|
|
|
|
onPressed: snapshot.connectionState != ConnectionState.done
|
|
|
|
|
onPressed:
|
|
|
|
|
snapshot.connectionState != ConnectionState.done
|
|
|
|
|
? null
|
|
|
|
|
: _refresh,
|
|
|
|
|
),
|
|
|
|
@ -267,17 +289,20 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
if (room != null && !room.isSpace) {
|
|
|
|
|
return ChatListItem(
|
|
|
|
|
room,
|
|
|
|
|
onLongPress: () => _onSpaceChildContextMenu(spaceChild, room),
|
|
|
|
|
onLongPress: () =>
|
|
|
|
|
_onSpaceChildContextMenu(spaceChild, room),
|
|
|
|
|
activeChat: widget.controller.activeChat == room.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final isSpace = spaceChild.roomType == 'm.space';
|
|
|
|
|
final topic =
|
|
|
|
|
spaceChild.topic?.isEmpty ?? true ? null : spaceChild.topic;
|
|
|
|
|
final topic = spaceChild.topic?.isEmpty ?? true
|
|
|
|
|
? null
|
|
|
|
|
: spaceChild.topic;
|
|
|
|
|
if (spaceChild.roomId == activeSpaceId) {
|
|
|
|
|
return SearchTitle(
|
|
|
|
|
title:
|
|
|
|
|
spaceChild.name ?? spaceChild.canonicalAlias ?? 'Space',
|
|
|
|
|
title: spaceChild.name ??
|
|
|
|
|
spaceChild.canonicalAlias ??
|
|
|
|
|
'Space',
|
|
|
|
|
icon: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
|
child: Avatar(
|
|
|
|
@ -311,7 +336,8 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
spaceChild.canonicalAlias ??
|
|
|
|
|
L10n.of(context)!.chat,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
|
style:
|
|
|
|
|
const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (!isSpace) ...[
|
|
|
|
@ -328,7 +354,8 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
onTap: () => _onJoinSpaceChild(spaceChild),
|
|
|
|
|
onLongPress: () => _onSpaceChildContextMenu(spaceChild, room),
|
|
|
|
|
onLongPress: () =>
|
|
|
|
|
_onSpaceChildContextMenu(spaceChild, room),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
topic ??
|
|
|
|
|
(isSpace
|
|
|
|
@ -339,10 +366,15 @@ class _SpaceViewState extends State<SpaceView> {
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing:
|
|
|
|
|
isSpace ? const Icon(Icons.chevron_right_outlined) : null,
|
|
|
|
|
trailing: isSpace
|
|
|
|
|
? const Icon(Icons.chevron_right_outlined)
|
|
|
|
|
: null,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
childCount: spaceChildren.length + 1 + (canLoadMore ? 1 : 0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|