show topics and summaries for spaces
This commit is contained in:
parent
b71a7f0bd6
commit
ab3eda0beb
6 changed files with 60 additions and 38 deletions
|
|
@ -18,9 +18,8 @@ extension ShowLeaveRoomSheet on BuildContext {
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final client = ProviderScope.containerOf(
|
final client = ProviderScope.containerOf(context)
|
||||||
context,
|
.read(ClientController.provider.notifier);
|
||||||
).read(ClientController.provider.notifier);
|
|
||||||
context.withProgressSnackbar(
|
context.withProgressSnackbar(
|
||||||
"Leaving $name...",
|
"Leaving $name...",
|
||||||
() => client.leaveRoom(roomId),
|
() => client.leaveRoom(roomId),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ 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";
|
||||||
|
|
@ -40,6 +41,16 @@ 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,6 +13,9 @@ 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
|
||||||
|
|
@ -50,7 +53,7 @@ final class const Appbar({
|
||||||
flexibleSpace: GestureDetector(onDoubleTap: maximize),
|
flexibleSpace: GestureDetector(onDoubleTap: maximize),
|
||||||
actions: [
|
actions: [
|
||||||
...actions,
|
...actions,
|
||||||
if (!(Platform.isAndroid || Platform.isIOS)) ...[
|
if (windowControls && !(Platform.isAndroid || Platform.isIOS)) ...[
|
||||||
if (ref
|
if (ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.whenOrNull(
|
.whenOrNull(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ 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({
|
||||||
|
|
@ -30,17 +31,7 @@ final class const RoomAppbar({
|
||||||
onTap: room?.metadata == null
|
onTap: room?.metadata == null
|
||||||
? null
|
? null
|
||||||
: () => context.showAdaptiveSheet(
|
: () => context.showAdaptiveSheet(
|
||||||
(context) => RoomSummarySheet(
|
(context) => RoomSummarySheet(.fromMetadata(room!.metadata!)),
|
||||||
.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
|
||||||
|
|
@ -62,24 +53,9 @@ final class const RoomAppbar({
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
title: room == null
|
title: room == null
|
||||||
? null
|
? null
|
||||||
: Column(
|
: RoomTitle(
|
||||||
crossAxisAlignment: .start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
room.metadata?.name ?? "Unnamed Room",
|
room.metadata?.name ?? "Unnamed Room",
|
||||||
overflow: .ellipsis,
|
topic: room.metadata?.topic,
|
||||||
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,6 +9,8 @@ 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";
|
||||||
|
|
@ -16,6 +18,7 @@ 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";
|
||||||
|
|
@ -232,25 +235,33 @@ 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(
|
||||||
selectedSpace.room?.metadata?.avatar,
|
spaceMetadata?.avatar,
|
||||||
fallback: selectedSpace.icon == null
|
fallback: selectedSpace.icon == null
|
||||||
? null
|
? null
|
||||||
: Icon(selectedSpace.icon),
|
: Icon(selectedSpace.icon),
|
||||||
selectedSpace.title,
|
selectedSpace.title,
|
||||||
),
|
),
|
||||||
title: Text(selectedSpace.title, overflow: .ellipsis),
|
title: RoomTitle(selectedSpace.title, topic: spaceMetadata?.topic),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
actions: [
|
actions: .new([
|
||||||
RoomMenuButton(
|
RoomMenuButton(
|
||||||
selectedSpace.room,
|
selectedSpace.room,
|
||||||
children: selectedSpace.allChildRooms,
|
children: selectedSpace.allChildRooms,
|
||||||
),
|
),
|
||||||
],
|
]),
|
||||||
),
|
),
|
||||||
body: MaterialUiCompatibilityBridge(
|
body: MaterialUiCompatibilityBridge(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
|
|
|
||||||
22
lib/widgets/room_title.dart
Normal file
22
lib/widgets/room_title.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
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