build method
dynamic
build( - dynamic context,
- dynamic ref
)
Implementation
@override
Widget build(BuildContext context, WidgetRef ref) {
final spaceName =
ref.watch(roomDisplayNameProvider(spaceIdOrAlias)).valueOrNull ??
spaceIdOrAlias;
final chatListAsync =
ref.watch(spaceRelationsOverviewProvider(spaceIdOrAlias));
final chatList = chatListAsync.valueOrNull?.knownChats ?? [];
final remoteChatsAsync =
ref.watch(remoteChatRelationsProvider(spaceIdOrAlias));
final remoteChats = remoteChatsAsync.valueOrNull ?? [];
final isLoading = chatListAsync.isLoading || remoteChatsAsync.isLoading;
final isEmpty = (chatListAsync.hasValue ? chatList.isEmpty : false) &&
(remoteChatsAsync.hasValue ? remoteChats.isEmpty : false);
final membership = ref.watch(roomMembershipProvider(spaceIdOrAlias));
bool canCreateSpace =
membership.valueOrNull?.canString('CanLinkSpaces') == true;
return Scaffold(
appBar: AppBar(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(L10n.of(context).chat),
Text(
'($spaceName)',
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelLarge,
),
],
),
actions: [
IconButton(
icon: const Icon(Atlas.arrows_rotating_right_thin),
iconSize: 28,
color: Theme.of(context).colorScheme.surface,
onPressed: () async {
ref.invalidate(spaceRelationsProvider);
},
),
if (canCreateSpace)
PopupMenuButton(
key: actionsMenuKey,
icon: const Icon(Atlas.plus_circle),
iconSize: 28,
color: Theme.of(context).colorScheme.surface,
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
key: createChatKey,
onTap: () => context.pushNamed(
Routes.createChat.name,
queryParameters: {'spaceId': spaceIdOrAlias},
extra: 1,
),
child: Row(
children: <Widget>[
Text(L10n.of(context).createChat),
const Spacer(),
const Icon(Atlas.chats),
],
),
),
PopupMenuItem(
onTap: () => context.pushNamed(
Routes.linkChat.name,
pathParameters: {'spaceId': spaceIdOrAlias},
),
child: Row(
children: <Widget>[
Text(L10n.of(context).linkExistingChat),
const Spacer(),
const Icon(Atlas.chats),
],
),
),
],
),
],
),
body: SingleChildScrollView(
child: Column(
children: [
if (chatList.isNotEmpty)
chatsListUI(
ref,
spaceIdOrAlias,
chatList,
chatList.length,
showOptions: true,
),
if (isLoading) _renderLoading(context),
if (remoteChats.isNotEmpty)
renderFurther(context, ref, spaceIdOrAlias, null),
if (isEmpty) _renderEmpty(context, ref),
],
),
),
);
}