chore: Add missing safearea to spaceview

pull/748/head rc1.16.1-1
krille-chan 2 years ago
parent 4214785b00
commit 5bf87eae24
No known key found for this signature in database

@ -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, title: Text(
maxLines: 1, displayname,
overflow: TextOverflow.ellipsis, maxLines: 1,
), overflow: TextOverflow.ellipsis,
subtitle: Text( ),
L10n.of(context)! subtitle: Text(
.numChats(rootSpace.spaceChildren.length.toString()), 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),
), ),
onTap: () => widget.controller.setActiveSpace(rootSpace.id), );
onLongPress: () => },
_onSpaceChildContextMenu(null, rootSpace), childCount: rootSpaces.length,
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),
activeChat: widget.controller.activeChat == room.id,
);
}
final isSpace = spaceChild.roomType == 'm.space';
final topic = spaceChild.topic?.isEmpty ?? true
? null
: spaceChild.topic;
if (spaceChild.roomId == activeSpaceId) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SearchTitle(
title: spaceChild.name ??
spaceChild.canonicalAlias ??
'Space',
icon: Padding(
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 (activeSpace?.canChangeStateEvent(
EventTypes.spaceChild,
) ==
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,
),
),
],
);
}
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( ],
),
);
}
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);
},
),
);
}
final spaceChild = spaceChildren[i];
final room = client.getRoomById(spaceChild.roomId);
if (room != null && !room.isSpace) {
return ChatListItem(
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;
if (spaceChild.roomId == activeSpaceId) {
return Column(
mainAxisSize: MainAxisSize.min,
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), 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: [
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,
), ),
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…
Cancel
Save