Compare commits
6 changed files with 101 additions and 129 deletions
|
|
@ -18,8 +18,9 @@ extension ShowLeaveRoomSheet on BuildContext {
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final client = ProviderScope.containerOf(context)
|
final client = ProviderScope.containerOf(
|
||||||
.read(ClientController.provider.notifier);
|
context,
|
||||||
|
).read(ClientController.provider.notifier);
|
||||||
context.withProgressSnackbar(
|
context.withProgressSnackbar(
|
||||||
"Leaving $name...",
|
"Leaving $name...",
|
||||||
() => client.leaveRoom(roomId),
|
() => client.leaveRoom(roomId),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import "package:nexus/models/content/create.dart";
|
||||||
import "package:nexus/models/content/membership.dart";
|
import "package:nexus/models/content/membership.dart";
|
||||||
import "package:nexus/models/join_rule.dart";
|
import "package:nexus/models/join_rule.dart";
|
||||||
import "package:nexus/models/membership_status.dart";
|
import "package:nexus/models/membership_status.dart";
|
||||||
import "package:nexus/models/room_metadata.dart";
|
|
||||||
|
|
||||||
part "room_summary.freezed.dart";
|
part "room_summary.freezed.dart";
|
||||||
part "room_summary.g.dart";
|
part "room_summary.g.dart";
|
||||||
|
|
@ -41,16 +40,6 @@ class const RoomSummary({
|
||||||
/// Whether this is an invite to a direct message.
|
/// Whether this is an invite to a direct message.
|
||||||
@JsonKey(includeFromJson: false) final bool isDirect = false,
|
@JsonKey(includeFromJson: false) final bool isDirect = false,
|
||||||
}) with _$RoomSummary {
|
}) with _$RoomSummary {
|
||||||
/// A summary of a room the user is in, from its synced metadata.
|
|
||||||
factory RoomSummary.fromMetadata(RoomMetadata metadata) => .new(
|
|
||||||
roomId: metadata.id,
|
|
||||||
joinedMembers: metadata.lazyLoadSummary?.joinedMemberCount,
|
|
||||||
avatarUrl: metadata.avatar,
|
|
||||||
canonicalAlias: metadata.canonicalAlias,
|
|
||||||
name: metadata.name,
|
|
||||||
topic: metadata.topic,
|
|
||||||
);
|
|
||||||
|
|
||||||
factory RoomSummary.fromJson(Map<String, Object?> json) =>
|
factory RoomSummary.fromJson(Map<String, Object?> json) =>
|
||||||
_$RoomSummaryFromJson(json);
|
_$RoomSummaryFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@ final class const Appbar({
|
||||||
final double? scrolledUnderElevation,
|
final double? scrolledUnderElevation,
|
||||||
final IList<Widget> actions = const .empty(),
|
final IList<Widget> actions = const .empty(),
|
||||||
final VoidCallback? onTap,
|
final VoidCallback? onTap,
|
||||||
|
|
||||||
/// Whether to show the minimize, maximize and close buttons on desktop.
|
|
||||||
final bool windowControls = true,
|
|
||||||
super.key,
|
super.key,
|
||||||
}) extends ConsumerWidget implements PreferredSizeWidget {
|
}) extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
@override
|
@override
|
||||||
|
|
@ -53,7 +50,7 @@ final class const Appbar({
|
||||||
flexibleSpace: GestureDetector(onDoubleTap: maximize),
|
flexibleSpace: GestureDetector(onDoubleTap: maximize),
|
||||||
actions: [
|
actions: [
|
||||||
...actions,
|
...actions,
|
||||||
if (windowControls && !(Platform.isAndroid || Platform.isIOS)) ...[
|
if (!(Platform.isAndroid || Platform.isIOS)) ...[
|
||||||
if (ref
|
if (ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.whenOrNull(
|
.whenOrNull(
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import "package:nexus/widgets/avatar_or_hash.dart";
|
||||||
import "package:nexus/widgets/count_badge.dart";
|
import "package:nexus/widgets/count_badge.dart";
|
||||||
import "package:nexus/widgets/room_menu_button.dart";
|
import "package:nexus/widgets/room_menu_button.dart";
|
||||||
import "package:nexus/widgets/room_summary_sheet.dart";
|
import "package:nexus/widgets/room_summary_sheet.dart";
|
||||||
import "package:nexus/widgets/room_title.dart";
|
|
||||||
import "package:nexus/widgets/sidebar.dart";
|
import "package:nexus/widgets/sidebar.dart";
|
||||||
|
|
||||||
final class const RoomAppbar({
|
final class const RoomAppbar({
|
||||||
|
|
@ -31,7 +30,17 @@ final class const RoomAppbar({
|
||||||
onTap: room?.metadata == null
|
onTap: room?.metadata == null
|
||||||
? null
|
? null
|
||||||
: () => context.showAdaptiveSheet(
|
: () => context.showAdaptiveSheet(
|
||||||
(context) => RoomSummarySheet(.fromMetadata(room!.metadata!)),
|
(context) => RoomSummarySheet(
|
||||||
|
.new(
|
||||||
|
roomId: room!.metadata!.id,
|
||||||
|
joinedMembers:
|
||||||
|
room.metadata!.lazyLoadSummary?.joinedMemberCount,
|
||||||
|
avatarUrl: room.metadata?.avatar,
|
||||||
|
canonicalAlias: room.metadata?.canonicalAlias,
|
||||||
|
name: room.metadata?.name,
|
||||||
|
topic: room.metadata?.topic,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
leading: isDesktop
|
leading: isDesktop
|
||||||
? room == null
|
? room == null
|
||||||
|
|
@ -53,9 +62,24 @@ final class const RoomAppbar({
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
title: room == null
|
title: room == null
|
||||||
? null
|
? null
|
||||||
: RoomTitle(
|
: Column(
|
||||||
room.metadata?.name ?? "Unnamed Room",
|
crossAxisAlignment: .start,
|
||||||
topic: room.metadata?.topic,
|
children: [
|
||||||
|
Text(
|
||||||
|
room.metadata?.name ?? "Unnamed Room",
|
||||||
|
overflow: .ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
if (room.metadata?.topic?.isNotEmpty == true)
|
||||||
|
Text(
|
||||||
|
room.metadata!.topic!,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: .ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
actions: .new(
|
actions: .new(
|
||||||
room == null
|
room == null
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ import "package:nexus/helpers/extensions/room_destinations.dart";
|
||||||
import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
|
import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
|
||||||
import "package:nexus/widgets/adaptive_menu_button.dart";
|
import "package:nexus/widgets/adaptive_menu_button.dart";
|
||||||
import "package:nexus/models/nav_page.dart";
|
import "package:nexus/models/nav_page.dart";
|
||||||
import "package:nexus/widgets/appbar.dart";
|
|
||||||
import "package:nexus/widgets/room_title.dart";
|
|
||||||
import "package:nexus/widgets/avatar_or_hash.dart";
|
import "package:nexus/widgets/avatar_or_hash.dart";
|
||||||
import "package:nexus/widgets/create_room_sheet.dart";
|
import "package:nexus/widgets/create_room_sheet.dart";
|
||||||
import "package:nexus/widgets/start_dm_sheet.dart";
|
import "package:nexus/widgets/start_dm_sheet.dart";
|
||||||
|
|
@ -18,7 +16,6 @@ import "package:nexus/widgets/divider_widget.dart";
|
||||||
import "package:nexus/widgets/error_dialog.dart";
|
import "package:nexus/widgets/error_dialog.dart";
|
||||||
import "package:nexus/widgets/pages/settings.dart";
|
import "package:nexus/widgets/pages/settings.dart";
|
||||||
import "package:nexus/widgets/join_sheet.dart";
|
import "package:nexus/widgets/join_sheet.dart";
|
||||||
import "package:nexus/widgets/room_summary_sheet.dart";
|
|
||||||
import "package:nexus/widgets/room_menu_button.dart";
|
import "package:nexus/widgets/room_menu_button.dart";
|
||||||
import "package:nexus/widgets/space_hierarchy_sheet.dart";
|
import "package:nexus/widgets/space_hierarchy_sheet.dart";
|
||||||
import "package:nexus/controllers/key.dart";
|
import "package:nexus/controllers/key.dart";
|
||||||
|
|
@ -191,7 +188,7 @@ class const SpacesRail({super.key}) extends ConsumerWidget {
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
const IconButton(
|
const IconButton(
|
||||||
tooltip: "Explore other rooms (Not yet implemented)",
|
tooltip: "Explore other rooms",
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
icon: Icon(Icons.explore),
|
icon: Icon(Icons.explore),
|
||||||
),
|
),
|
||||||
|
|
@ -235,33 +232,25 @@ class const RoomsPane({super.key}) extends ConsumerWidget {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
final isDm = selectedSpace.id == "dms";
|
final isDm = selectedSpace.id == "dms";
|
||||||
final spaceMetadata = selectedSpace.room?.metadata;
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: Appbar(
|
appBar: AppBar(
|
||||||
// Home and DMs aren't real spaces, so they don't have a summary.
|
|
||||||
onTap: spaceMetadata == null
|
|
||||||
? null
|
|
||||||
: () => context.showAdaptiveSheet(
|
|
||||||
(_) => RoomSummarySheet(.fromMetadata(spaceMetadata)),
|
|
||||||
),
|
|
||||||
windowControls: false,
|
|
||||||
leading: AvatarOrHash(
|
leading: AvatarOrHash(
|
||||||
spaceMetadata?.avatar,
|
selectedSpace.room?.metadata?.avatar,
|
||||||
fallback: selectedSpace.icon == null
|
fallback: selectedSpace.icon == null
|
||||||
? null
|
? null
|
||||||
: Icon(selectedSpace.icon),
|
: Icon(selectedSpace.icon),
|
||||||
selectedSpace.title,
|
selectedSpace.title,
|
||||||
),
|
),
|
||||||
title: RoomTitle(selectedSpace.title, topic: spaceMetadata?.topic),
|
title: Text(selectedSpace.title, overflow: .ellipsis),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
actions: .new([
|
actions: [
|
||||||
RoomMenuButton(
|
RoomMenuButton(
|
||||||
selectedSpace.room,
|
selectedSpace.room,
|
||||||
children: selectedSpace.allChildRooms,
|
children: selectedSpace.allChildRooms,
|
||||||
),
|
),
|
||||||
]),
|
],
|
||||||
),
|
),
|
||||||
body: MaterialUiCompatibilityBridge(
|
body: MaterialUiCompatibilityBridge(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
|
|
@ -284,81 +273,75 @@ class const RoomsPane({super.key}) extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: NavigationRailM3E(
|
||||||
padding: const .only(top: 4),
|
fab: selectedSpace.room == null
|
||||||
child: NavigationRailM3E(
|
? null
|
||||||
fab: selectedSpace.room == null
|
: .new(
|
||||||
? null
|
icon: const Icon(Icons.explore),
|
||||||
: .new(
|
label: "Browse space",
|
||||||
icon: const Icon(Icons.explore),
|
tooltip: "Browse and join rooms in this space",
|
||||||
label: "Browse space",
|
onPressed: () => context.showAdaptiveSheet(
|
||||||
tooltip: "Browse and join rooms in this space",
|
(_) => SpaceHierarchySheet(selectedSpace.id),
|
||||||
onPressed: () => context.showAdaptiveSheet(
|
|
||||||
(_) => SpaceHierarchySheet(selectedSpace.id),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
expandedWidth: double.infinity,
|
),
|
||||||
scrollable: true,
|
expandedWidth: double.infinity,
|
||||||
background: Colors.transparent,
|
scrollable: true,
|
||||||
type: .alwaysExpand,
|
background: Colors.transparent,
|
||||||
selectedIndex: max(
|
type: .alwaysExpand,
|
||||||
0,
|
selectedIndex: max(
|
||||||
selectedSpace.allChildRooms.indexWhere(
|
0,
|
||||||
(room) => room.metadata?.id == selectedRoomId,
|
selectedSpace.allChildRooms.indexWhere(
|
||||||
|
(room) => room.metadata?.id == selectedRoomId,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
sections: [
|
||||||
|
.new(
|
||||||
|
header: selectedSpace.room == null
|
||||||
|
? null
|
||||||
|
: const DividerWidget(Text("Rooms")),
|
||||||
|
destinations: selectedSpace.children.toDestinations(
|
||||||
|
isDm: isDm,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
sections: [
|
...selectedSpace.subSpaces.map(
|
||||||
.new(
|
(subSpace) => NavigationRailM3ESection(
|
||||||
header: selectedSpace.room == null
|
header: DividerWidget(
|
||||||
? null
|
Row(
|
||||||
: const DividerWidget(Text("Rooms")),
|
mainAxisSize: .min,
|
||||||
destinations: selectedSpace.children.toDestinations(
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
if (subSpace.room.metadata?.avatar != null)
|
||||||
|
AvatarOrHash(
|
||||||
|
subSpace.room.metadata?.avatar,
|
||||||
|
subSpace.room.metadata?.name ?? "Unnamed Room",
|
||||||
|
dimension: 16,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
subSpace.room.metadata?.name ?? "Unnamed Space",
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: .ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
destinations: subSpace.children.toDestinations(
|
||||||
isDm: isDm,
|
isDm: isDm,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
...selectedSpace.subSpaces.map(
|
),
|
||||||
(subSpace) => NavigationRailM3ESection(
|
],
|
||||||
header: DividerWidget(
|
onDestinationSelected: (value) {
|
||||||
Row(
|
ref
|
||||||
mainAxisSize: .min,
|
.read(
|
||||||
spacing: 8,
|
KeyController.provider(KeyController.roomKey).notifier,
|
||||||
children: [
|
)
|
||||||
if (subSpace.room.metadata?.avatar != null)
|
.set(selectedSpace.allChildRooms[value].metadata?.id);
|
||||||
AvatarOrHash(
|
if (Navigator.of(context).canPop()) {
|
||||||
subSpace.room.metadata?.avatar,
|
Navigator.of(context).pop();
|
||||||
subSpace.room.metadata?.name ??
|
}
|
||||||
"Unnamed Room",
|
},
|
||||||
dimension: 16,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
subSpace.room.metadata?.name ??
|
|
||||||
"Unnamed Space",
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: .ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
destinations: subSpace.children.toDestinations(
|
|
||||||
isDm: isDm,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onDestinationSelected: (value) {
|
|
||||||
ref
|
|
||||||
.read(
|
|
||||||
KeyController.provider(KeyController.roomKey)
|
|
||||||
.notifier,
|
|
||||||
)
|
|
||||||
.set(selectedSpace.allChildRooms[value].metadata?.id);
|
|
||||||
if (Navigator.of(context).canPop()) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import "package:material_ui/material_ui.dart";
|
|
||||||
|
|
||||||
/// A room or space's name, with its topic underneath if it has one, for app
|
|
||||||
/// bars.
|
|
||||||
class const RoomTitle(final String name, {final String? topic, super.key})
|
|
||||||
extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) => Column(
|
|
||||||
crossAxisAlignment: .start,
|
|
||||||
children: [
|
|
||||||
Text(name, overflow: .ellipsis, maxLines: 1),
|
|
||||||
if (topic?.isNotEmpty == true)
|
|
||||||
Text(
|
|
||||||
topic!,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: .ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.labelMedium
|
|
||||||
?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue