reorganize and rename widgets
This commit is contained in:
parent
05d25869ef
commit
d5f29dc344
1 changed files with 568 additions and 547 deletions
86
lib/widgets/room_chat/room_appbar.dart
Normal file
86
lib/widgets/room_chat/room_appbar.dart
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
||||
import "package:nexus/controllers/rooms.dart";
|
||||
import "package:nexus/widgets/common/appbar.dart";
|
||||
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
|
||||
import "package:nexus/widgets/common/count_badge.dart";
|
||||
import "package:nexus/widgets/rooms/room_menu_button.dart";
|
||||
import "package:nexus/widgets/rooms/room_summary_sheet.dart";
|
||||
import "package:nexus/widgets/rooms/room_title.dart";
|
||||
import "package:nexus/widgets/sidebar/sidebar.dart";
|
||||
|
||||
final class const RoomAppbar({
|
||||
required final String? roomId,
|
||||
required final bool isDesktop,
|
||||
required final void Function() onOpenDrawer,
|
||||
final void Function(BuildContext context)? onOpenMemberList,
|
||||
final void Function()? onOpenPinnedMessagesList,
|
||||
final void Function()? onOpenSearch,
|
||||
final void Function()? onOpenThreads,
|
||||
super.key,
|
||||
}) extends ConsumerWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Size get preferredSize => AppBar().preferredSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final room = roomId == null
|
||||
? null
|
||||
: ref.watch(RoomsController.provider.select((value) => value[roomId!]));
|
||||
|
||||
return Appbar(
|
||||
onTap: room?.metadata == null
|
||||
? null
|
||||
: () => context.showAdaptiveSheet(
|
||||
(context) => RoomSummarySheet(.fromMetadata(room!.metadata!)),
|
||||
),
|
||||
leading: isDesktop
|
||||
? room == null
|
||||
? null
|
||||
: AvatarOrHash(
|
||||
room.metadata?.avatar,
|
||||
room.metadata?.name ?? "Unnamed Room",
|
||||
dimension: 24,
|
||||
fallback: Icon(Icons.numbers),
|
||||
)
|
||||
: IconButton(
|
||||
onPressed: onOpenDrawer,
|
||||
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
|
||||
icon: CountBadge(
|
||||
Sidebar.totalBadgeCount(ref),
|
||||
child: const DrawerButtonIcon(),
|
||||
),
|
||||
),
|
||||
scrolledUnderElevation: 0,
|
||||
title: room == null
|
||||
? null
|
||||
: RoomTitle(
|
||||
room.metadata?.name ?? "Unnamed Room",
|
||||
topic: room.metadata?.topic,
|
||||
),
|
||||
actions: .new(
|
||||
room == null
|
||||
? []
|
||||
: [
|
||||
IconButton(
|
||||
onPressed: onOpenThreads?.call,
|
||||
icon: Icon(Icons.forum),
|
||||
tooltip: "Open threads",
|
||||
),
|
||||
IconButton(
|
||||
onPressed: onOpenPinnedMessagesList?.call,
|
||||
icon: Icon(Icons.push_pin),
|
||||
tooltip: "Open pinned messages",
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => onOpenMemberList?.call(context),
|
||||
tooltip: "Open member list",
|
||||
icon: Icon(Icons.people),
|
||||
),
|
||||
RoomMenuButton(room, onOpenSearch: onOpenSearch),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue