feat: Search for public spaces
This commit is contained in:
parent
ef249c6f6e
commit
715e615e3a
5 changed files with 110 additions and 59 deletions
|
|
@ -6,6 +6,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
|
@ -41,9 +42,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
: await client.joinRoom(roomAlias ?? chunk!.roomId);
|
||||
|
||||
if (client.getRoomById(roomId) == null) {
|
||||
await client.onSync.stream.firstWhere(
|
||||
(sync) => sync.rooms?.join?.containsKey(roomId) ?? false,
|
||||
);
|
||||
await client.waitForRoomInSync(roomId);
|
||||
}
|
||||
return roomId;
|
||||
},
|
||||
|
|
@ -51,7 +50,8 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
if (result.error == null) {
|
||||
Navigator.of(context).pop();
|
||||
// don't open the room if the joined room is a space
|
||||
if (!client.getRoomById(result.result!)!.isSpace) {
|
||||
if (chunk?.roomType != 'm.space' &&
|
||||
!client.getRoomById(result.result!)!.isSpace) {
|
||||
outerContext.go('/rooms/${result.result!}');
|
||||
}
|
||||
return;
|
||||
|
|
@ -77,12 +77,12 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final roomAlias = this.roomAlias;
|
||||
final roomAlias = this.roomAlias ?? chunk?.canonicalAlias;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
roomAlias ?? chunk!.name ?? chunk!.roomId,
|
||||
chunk!.name ?? roomAlias ?? chunk!.roomId,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
leading: IconButton(
|
||||
|
|
@ -92,11 +92,13 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => _joinRoom(context),
|
||||
label: Text(L10n.of(context)!.joinRoom),
|
||||
icon: const Icon(Icons.login_outlined),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.adaptive.share_outlined),
|
||||
onPressed: () => FluffyShare.share(
|
||||
'https://matrix.to/#/${roomAlias ?? chunk?.roomId}',
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -131,29 +133,50 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () => _joinRoom(context),
|
||||
label: Text(
|
||||
chunk?.roomType == 'm.space'
|
||||
? L10n.of(context)!.joinSpace
|
||||
: L10n.of(context)!.joinRoom,
|
||||
),
|
||||
icon: const Icon(Icons.login_outlined),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ListTile(
|
||||
title: Text(
|
||||
profile?.name ??
|
||||
roomAlias?.localpart ??
|
||||
chunk!.roomId.localpart ??
|
||||
'',
|
||||
profile?.name ?? chunk!.roomId.localpart ?? '',
|
||||
),
|
||||
subtitle: Text(
|
||||
'${L10n.of(context)!.participant}: ${profile?.numJoinedMembers ?? 0}',
|
||||
),
|
||||
trailing: const Icon(Icons.account_box_outlined),
|
||||
),
|
||||
if (profile?.topic?.isNotEmpty ?? false)
|
||||
if (roomAlias != null)
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.chatDescription,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
title: Text(L10n.of(context)!.publicLink),
|
||||
subtitle: SelectableText(roomAlias),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.copy_outlined),
|
||||
onPressed: () => FluffyShare.share(
|
||||
roomAlias,
|
||||
context,
|
||||
),
|
||||
),
|
||||
subtitle: Linkify(
|
||||
),
|
||||
if (profile?.topic?.isNotEmpty ?? false)
|
||||
ListTile(
|
||||
subtitle: SelectableLinkify(
|
||||
text: profile!.topic!,
|
||||
linkStyle: const TextStyle(color: Colors.blueAccent),
|
||||
linkStyle: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
decorationColor: Colors.blueAccent,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).textTheme.bodyMedium!.color,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue