add room directory support
This commit is contained in:
parent
033c7f9c05
commit
e382499a2a
3 changed files with 868 additions and 245 deletions
|
|
@ -4,6 +4,12 @@ extension GetLocalpart on String {
|
|||
/// Whether this looks like a valid Matrix user ID, e.g. `@user:example.com`.
|
||||
bool get isValidUserId => RegExp(r"^@[^:\s]+:[^\s]+$").hasMatch(this);
|
||||
|
||||
/// Whether this is a valid Matrix server name, e.g. `example.com:8448`.
|
||||
bool get isValidServerName => RegExp(
|
||||
r"^(\[[0-9a-f:.]+\]|[a-z0-9.-]{1,255})(:\d{1,5})?$",
|
||||
caseSensitive: false,
|
||||
).hasMatch(this);
|
||||
|
||||
String? get serverName {
|
||||
final index = indexOf(":");
|
||||
return index == -1 ? null : substring(index + 1);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ extension JoinRoom on BuildContext {
|
|||
}) async {
|
||||
final container = ProviderScope.containerOf(this);
|
||||
final messenger = ScaffoldMessenger.of(this);
|
||||
final navigator = Navigator.of(this);
|
||||
|
||||
final roomId = await withProgressSnackbar(
|
||||
"Joining $name...",
|
||||
|
|
@ -31,6 +32,7 @@ extension JoinRoom on BuildContext {
|
|||
action: .new(
|
||||
label: "Open",
|
||||
onPressed: () async {
|
||||
navigator.popUntil((route) => route.isFirst);
|
||||
await container.focusRoom(roomId);
|
||||
container.read(SidebarPageController.provider.notifier).set(.rooms);
|
||||
},
|
||||
|
|
|
|||
18
lib/helpers/extensions/room_summary_display.dart
Normal file
18
lib/helpers/extensions/room_summary_display.dart
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/models/content/create.dart";
|
||||
import "package:nexus/models/room_summary.dart";
|
||||
|
||||
extension RoomSummaryDisplay on RoomSummary {
|
||||
bool get isSpace => roomType == RoomType.space;
|
||||
|
||||
IconData get icon => isSpace ? Icons.workspaces : Icons.numbers;
|
||||
|
||||
String get displayName =>
|
||||
name ?? canonicalAlias ?? (isSpace ? "Unnamed Space" : "Unnamed Room");
|
||||
|
||||
/// E.g. "Space · 12 members"
|
||||
String get details => [
|
||||
if (isSpace) "Space",
|
||||
if (joinedMembers case final members?) "$members members",
|
||||
].join(" · ");
|
||||
}
|
||||
Loading…
Reference in a new issue