mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
chore: Add missing safearea to spaceview
This commit is contained in:
parent
4214785b00
commit
5bf87eae24
1 changed files with 236 additions and 229 deletions
|
@ -285,44 +285,48 @@ class _SpaceViewState extends State<SpaceView> {
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return CustomScrollView(
|
return SafeArea(
|
||||||
controller: widget.scrollController,
|
child: CustomScrollView(
|
||||||
slivers: [
|
controller: widget.scrollController,
|
||||||
ChatListHeader(controller: widget.controller),
|
slivers: [
|
||||||
SliverList(
|
ChatListHeader(controller: widget.controller),
|
||||||
delegate: SliverChildBuilderDelegate(
|
SliverList(
|
||||||
(context, i) {
|
delegate: SliverChildBuilderDelegate(
|
||||||
final rootSpace = rootSpaces[i];
|
(context, i) {
|
||||||
final displayname = rootSpace.getLocalizedDisplayname(
|
final rootSpace = rootSpaces[i];
|
||||||
MatrixLocals(L10n.of(context)!),
|
final displayname = rootSpace.getLocalizedDisplayname(
|
||||||
);
|
MatrixLocals(L10n.of(context)!),
|
||||||
return Material(
|
);
|
||||||
color: Theme.of(context).colorScheme.background,
|
return Material(
|
||||||
child: ListTile(
|
color: Theme.of(context).colorScheme.background,
|
||||||
leading: Avatar(
|
child: ListTile(
|
||||||
mxContent: rootSpace.avatar,
|
leading: Avatar(
|
||||||
name: displayname,
|
mxContent: rootSpace.avatar,
|
||||||
|
name: displayname,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
displayname,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
L10n.of(context)!.numChats(
|
||||||
|
rootSpace.spaceChildren.length.toString(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () =>
|
||||||
|
widget.controller.setActiveSpace(rootSpace.id),
|
||||||
|
onLongPress: () =>
|
||||||
|
_onSpaceChildContextMenu(null, rootSpace),
|
||||||
|
trailing: const Icon(Icons.chevron_right_outlined),
|
||||||
),
|
),
|
||||||
title: Text(
|
);
|
||||||
displayname,
|
},
|
||||||
maxLines: 1,
|
childCount: rootSpaces.length,
|
||||||
overflow: TextOverflow.ellipsis,
|
),
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
L10n.of(context)!
|
|
||||||
.numChats(rootSpace.spaceChildren.length.toString()),
|
|
||||||
),
|
|
||||||
onTap: () => widget.controller.setActiveSpace(rootSpace.id),
|
|
||||||
onLongPress: () =>
|
|
||||||
_onSpaceChildContextMenu(null, rootSpace),
|
|
||||||
trailing: const Icon(Icons.chevron_right_outlined),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
childCount: rootSpaces.length,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,211 +342,214 @@ class _SpaceViewState extends State<SpaceView> {
|
||||||
widget.controller.setActiveSpace(parentSpace.id);
|
widget.controller.setActiveSpace(parentSpace.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: SafeArea(
|
||||||
controller: widget.scrollController,
|
child: CustomScrollView(
|
||||||
slivers: [
|
controller: widget.scrollController,
|
||||||
ChatListHeader(controller: widget.controller),
|
slivers: [
|
||||||
SliverAppBar(
|
ChatListHeader(controller: widget.controller),
|
||||||
automaticallyImplyLeading: false,
|
SliverAppBar(
|
||||||
primary: false,
|
automaticallyImplyLeading: false,
|
||||||
titleSpacing: 0,
|
primary: false,
|
||||||
title: ListTile(
|
titleSpacing: 0,
|
||||||
leading: BackButton(
|
title: ListTile(
|
||||||
onPressed: () =>
|
leading: BackButton(
|
||||||
widget.controller.setActiveSpace(parentSpace?.id),
|
onPressed: () =>
|
||||||
),
|
widget.controller.setActiveSpace(parentSpace?.id),
|
||||||
title: Text(
|
),
|
||||||
parentSpace == null
|
title: Text(
|
||||||
? L10n.of(context)!.allSpaces
|
parentSpace == null
|
||||||
: parentSpace.getLocalizedDisplayname(
|
? L10n.of(context)!.allSpaces
|
||||||
MatrixLocals(L10n.of(context)!),
|
: parentSpace.getLocalizedDisplayname(
|
||||||
),
|
MatrixLocals(L10n.of(context)!),
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
),
|
||||||
icon: loading
|
trailing: IconButton(
|
||||||
? const CircularProgressIndicator.adaptive(strokeWidth: 2)
|
icon: loading
|
||||||
: const Icon(Icons.refresh_outlined),
|
? const CircularProgressIndicator.adaptive(strokeWidth: 2)
|
||||||
onPressed: loading ? null : _refresh,
|
: const Icon(Icons.refresh_outlined),
|
||||||
|
onPressed: loading ? null : _refresh,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Builder(
|
||||||
Builder(
|
builder: (context) {
|
||||||
builder: (context) {
|
final response = _lastResponse[activeSpaceId];
|
||||||
final response = _lastResponse[activeSpaceId];
|
final error = this.error;
|
||||||
final error = this.error;
|
if (error != null) {
|
||||||
if (error != null) {
|
return SliverFillRemaining(
|
||||||
return SliverFillRemaining(
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.all(16.0),
|
||||||
padding: const EdgeInsets.all(16.0),
|
child: Text(error.toLocalizedString(context)),
|
||||||
child: Text(error.toLocalizedString(context)),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: _refresh,
|
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (response == null) {
|
|
||||||
return SliverFillRemaining(
|
|
||||||
child: Center(
|
|
||||||
child: Text(L10n.of(context)!.loadingPleaseWait),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final spaceChildren = response.rooms;
|
|
||||||
final canLoadMore = response.nextBatch != null;
|
|
||||||
return SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(context, i) {
|
|
||||||
if (canLoadMore && i == spaceChildren.length) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: OutlinedButton.icon(
|
|
||||||
label: loading
|
|
||||||
? const LinearProgressIndicator()
|
|
||||||
: Text(L10n.of(context)!.loadMore),
|
|
||||||
icon: const Icon(Icons.chevron_right_outlined),
|
|
||||||
onPressed: loading
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
loadHierarchy(response.nextBatch);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
IconButton(
|
||||||
}
|
onPressed: _refresh,
|
||||||
final spaceChild = spaceChildren[i];
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
final room = client.getRoomById(spaceChild.roomId);
|
),
|
||||||
if (room != null && !room.isSpace) {
|
],
|
||||||
return ChatListItem(
|
),
|
||||||
room,
|
);
|
||||||
onLongPress: () =>
|
}
|
||||||
_onSpaceChildContextMenu(spaceChild, room),
|
if (response == null) {
|
||||||
activeChat: widget.controller.activeChat == room.id,
|
return SliverFillRemaining(
|
||||||
);
|
child: Center(
|
||||||
}
|
child: Text(L10n.of(context)!.loadingPleaseWait),
|
||||||
final isSpace = spaceChild.roomType == 'm.space';
|
),
|
||||||
final topic = spaceChild.topic?.isEmpty ?? true
|
);
|
||||||
? null
|
}
|
||||||
: spaceChild.topic;
|
final spaceChildren = response.rooms;
|
||||||
if (spaceChild.roomId == activeSpaceId) {
|
final canLoadMore = response.nextBatch != null;
|
||||||
return Column(
|
return SliverList(
|
||||||
mainAxisSize: MainAxisSize.min,
|
delegate: SliverChildBuilderDelegate(
|
||||||
children: [
|
(context, i) {
|
||||||
SearchTitle(
|
if (canLoadMore && i == spaceChildren.length) {
|
||||||
title: spaceChild.name ??
|
return Padding(
|
||||||
spaceChild.canonicalAlias ??
|
padding: const EdgeInsets.all(16.0),
|
||||||
'Space',
|
child: OutlinedButton.icon(
|
||||||
icon: Padding(
|
label: loading
|
||||||
padding:
|
? const LinearProgressIndicator()
|
||||||
const EdgeInsets.symmetric(horizontal: 10.0),
|
: Text(L10n.of(context)!.loadMore),
|
||||||
child: Avatar(
|
icon: const Icon(Icons.chevron_right_outlined),
|
||||||
size: 24,
|
onPressed: loading
|
||||||
mxContent: spaceChild.avatarUrl,
|
? null
|
||||||
name: spaceChild.name,
|
: () {
|
||||||
fontSize: 9,
|
loadHierarchy(response.nextBatch);
|
||||||
),
|
},
|
||||||
),
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.secondaryContainer
|
|
||||||
.withAlpha(128),
|
|
||||||
trailing: const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Icon(Icons.edit_outlined),
|
|
||||||
),
|
|
||||||
onTap: () => _onJoinSpaceChild(spaceChild),
|
|
||||||
),
|
),
|
||||||
if (activeSpace?.canChangeStateEvent(
|
);
|
||||||
EventTypes.spaceChild,
|
}
|
||||||
) ==
|
final spaceChild = spaceChildren[i];
|
||||||
true)
|
final room = client.getRoomById(spaceChild.roomId);
|
||||||
Material(
|
if (room != null && !room.isSpace) {
|
||||||
child: ListTile(
|
return ChatListItem(
|
||||||
leading: const CircleAvatar(
|
room,
|
||||||
child: Icon(Icons.group_add_outlined),
|
onLongPress: () =>
|
||||||
),
|
_onSpaceChildContextMenu(spaceChild, room),
|
||||||
title:
|
activeChat: widget.controller.activeChat == room.id,
|
||||||
Text(L10n.of(context)!.addChatOrSubSpace),
|
);
|
||||||
trailing:
|
}
|
||||||
const Icon(Icons.chevron_right_outlined),
|
final isSpace = spaceChild.roomType == 'm.space';
|
||||||
onTap: _addChatOrSubSpace,
|
final topic = spaceChild.topic?.isEmpty ?? true
|
||||||
),
|
? null
|
||||||
),
|
: spaceChild.topic;
|
||||||
],
|
if (spaceChild.roomId == activeSpaceId) {
|
||||||
);
|
return Column(
|
||||||
}
|
mainAxisSize: MainAxisSize.min,
|
||||||
final name = spaceChild.name ??
|
|
||||||
spaceChild.canonicalAlias ??
|
|
||||||
L10n.of(context)!.chat;
|
|
||||||
if (widget.controller.isSearchMode &&
|
|
||||||
!name.toLowerCase().contains(
|
|
||||||
widget.controller.searchController.text,
|
|
||||||
)) {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
return Material(
|
|
||||||
child: ListTile(
|
|
||||||
leading: Avatar(
|
|
||||||
mxContent: spaceChild.avatarUrl,
|
|
||||||
name: spaceChild.name,
|
|
||||||
),
|
|
||||||
title: Row(
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
SearchTitle(
|
||||||
child: Text(
|
title: spaceChild.name ??
|
||||||
name,
|
spaceChild.canonicalAlias ??
|
||||||
maxLines: 1,
|
'Space',
|
||||||
style: const TextStyle(
|
icon: Padding(
|
||||||
fontWeight: FontWeight.bold,
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10.0,
|
||||||
|
),
|
||||||
|
child: Avatar(
|
||||||
|
size: 24,
|
||||||
|
mxContent: spaceChild.avatarUrl,
|
||||||
|
name: spaceChild.name,
|
||||||
|
fontSize: 9,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.secondaryContainer
|
||||||
|
.withAlpha(128),
|
||||||
|
trailing: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
child: Icon(Icons.edit_outlined),
|
||||||
|
),
|
||||||
|
onTap: () => _onJoinSpaceChild(spaceChild),
|
||||||
),
|
),
|
||||||
if (!isSpace) ...[
|
if (activeSpace?.canChangeStateEvent(
|
||||||
const Icon(
|
EventTypes.spaceChild,
|
||||||
Icons.people_outline,
|
) ==
|
||||||
size: 16,
|
true)
|
||||||
|
Material(
|
||||||
|
child: ListTile(
|
||||||
|
leading: const CircleAvatar(
|
||||||
|
child: Icon(Icons.group_add_outlined),
|
||||||
|
),
|
||||||
|
title:
|
||||||
|
Text(L10n.of(context)!.addChatOrSubSpace),
|
||||||
|
trailing:
|
||||||
|
const Icon(Icons.chevron_right_outlined),
|
||||||
|
onTap: _addChatOrSubSpace,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(
|
|
||||||
spaceChild.numJoinedMembers.toString(),
|
|
||||||
style: const TextStyle(fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
onTap: () => room?.isSpace == true
|
}
|
||||||
? widget.controller.setActiveSpace(room!.id)
|
final name = spaceChild.name ??
|
||||||
: _onSpaceChildContextMenu(spaceChild, room),
|
spaceChild.canonicalAlias ??
|
||||||
onLongPress: () =>
|
L10n.of(context)!.chat;
|
||||||
_onSpaceChildContextMenu(spaceChild, room),
|
if (widget.controller.isSearchMode &&
|
||||||
subtitle: Text(
|
!name.toLowerCase().contains(
|
||||||
topic ??
|
widget.controller.searchController.text,
|
||||||
(isSpace
|
)) {
|
||||||
? L10n.of(context)!.enterSpace
|
return const SizedBox.shrink();
|
||||||
: L10n.of(context)!.enterRoom),
|
}
|
||||||
maxLines: 1,
|
return Material(
|
||||||
style: TextStyle(
|
child: ListTile(
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
leading: Avatar(
|
||||||
|
mxContent: spaceChild.avatarUrl,
|
||||||
|
name: spaceChild.name,
|
||||||
),
|
),
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
maxLines: 1,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isSpace) ...[
|
||||||
|
const Icon(
|
||||||
|
Icons.people_outline,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
spaceChild.numJoinedMembers.toString(),
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () => room?.isSpace == true
|
||||||
|
? widget.controller.setActiveSpace(room!.id)
|
||||||
|
: _onSpaceChildContextMenu(spaceChild, room),
|
||||||
|
onLongPress: () =>
|
||||||
|
_onSpaceChildContextMenu(spaceChild, room),
|
||||||
|
subtitle: Text(
|
||||||
|
topic ??
|
||||||
|
(isSpace
|
||||||
|
? L10n.of(context)!.enterSpace
|
||||||
|
: L10n.of(context)!.enterRoom),
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
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 + (canLoadMore ? 1 : 0),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: spaceChildren.length + (canLoadMore ? 1 : 0),
|
),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue