forked from Nexus/nexus
use a double scaffold approach for pins drawer
This commit is contained in:
parent
177c057337
commit
1f776c2a77
4 changed files with 355 additions and 355 deletions
|
|
@ -33,22 +33,10 @@ class MemberList extends HookConsumerWidget {
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
shape: Border(),
|
shape: Border(),
|
||||||
child: Column(
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
if (Scaffold.of(context).hasEndDrawer)
|
|
||||||
AppBar(
|
|
||||||
scrolledUnderElevation: 0,
|
|
||||||
leading: Icon(Icons.people),
|
|
||||||
title: Text("Members"),
|
|
||||||
actionsPadding: .only(right: 4),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: Scaffold.of(context).closeEndDrawer,
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
tooltip: "Close member list",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: .symmetric(vertical: 8),
|
padding: .symmetric(vertical: 8),
|
||||||
child: M3EToggleButtonGroup(
|
child: M3EToggleButtonGroup(
|
||||||
|
|
@ -180,6 +168,22 @@ class MemberList extends HookConsumerWidget {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
appBar: Scaffold.of(context).hasEndDrawer
|
||||||
|
? AppBar(
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
leading: Icon(Icons.people),
|
||||||
|
title: Text("Members"),
|
||||||
|
actionsPadding: .only(right: 4),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: Scaffold.of(context).closeEndDrawer,
|
||||||
|
icon: Icon(Icons.close),
|
||||||
|
tooltip: "Close member list",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,16 @@ class PinnedEventsDrawer extends HookConsumerWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final pinsAsync = ref.watch(PinnedEventsController.provider(roomId));
|
final pinsProvider = ref.watch(PinnedEventsController.provider(roomId));
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
return Column(
|
return Drawer(
|
||||||
children: [
|
width: 600,
|
||||||
if (Scaffold.of(context).hasEndDrawer)
|
child: Scaffold(
|
||||||
AppBar(
|
backgroundColor: Colors.transparent,
|
||||||
|
appBar: AppBar(
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
leading: Icon(Icons.pin),
|
leading: Icon(Icons.push_pin),
|
||||||
title: Text("Pinned Messages"),
|
title: Text("Pinned Messages"),
|
||||||
actionsPadding: .only(right: 4),
|
actionsPadding: .only(right: 4),
|
||||||
actions: [
|
actions: [
|
||||||
|
|
@ -32,8 +33,7 @@ class PinnedEventsDrawer extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
body: switch (pinsProvider) {
|
||||||
child: switch (pinsAsync) {
|
|
||||||
AsyncData(:final value) when value.isEmpty => Center(
|
AsyncData(:final value) when value.isEmpty => Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -103,7 +103,6 @@ class PinnedEventsDrawer extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ import "package:nexus/widgets/room_menu.dart";
|
||||||
class RoomAppbar extends ConsumerWidget implements PreferredSizeWidget {
|
class RoomAppbar extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
final bool isDesktop;
|
final bool isDesktop;
|
||||||
final void Function(BuildContext context)? onOpenMemberList;
|
final void Function(BuildContext context)? onOpenMemberList;
|
||||||
final void Function(BuildContext context)? onOpenPinnedMessagesList;
|
final void Function()? onOpenPinnedMessagesList;
|
||||||
final void Function(BuildContext context) onOpenDrawer;
|
final void Function() onOpenDrawer;
|
||||||
final String? roomId;
|
final String? roomId;
|
||||||
const RoomAppbar({
|
const RoomAppbar({
|
||||||
required this.roomId,
|
required this.roomId,
|
||||||
|
|
@ -103,7 +103,7 @@ class RoomAppbar extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
height: 24,
|
height: 24,
|
||||||
fallback: Icon(Icons.numbers),
|
fallback: Icon(Icons.numbers),
|
||||||
)
|
)
|
||||||
: DrawerButton(onPressed: () => onOpenDrawer(context)),
|
: DrawerButton(onPressed: onOpenDrawer),
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
title: room == null
|
title: room == null
|
||||||
? null
|
? null
|
||||||
|
|
@ -130,7 +130,7 @@ class RoomAppbar extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
? .new()
|
? .new()
|
||||||
: .new([
|
: .new([
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => onOpenPinnedMessagesList?.call(context),
|
onPressed: onOpenPinnedMessagesList?.call,
|
||||||
icon: Icon(Icons.push_pin),
|
icon: Icon(Icons.push_pin),
|
||||||
tooltip: "Open pinned messages",
|
tooltip: "Open pinned messages",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,7 @@ class RoomChat extends HookConsumerWidget {
|
||||||
appBar: RoomAppbar(
|
appBar: RoomAppbar(
|
||||||
roomId: this.roomId,
|
roomId: this.roomId,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
onOpenDrawer: (_) => Scaffold.of(context).openDrawer(),
|
onOpenDrawer: () => Scaffold.of(context).openDrawer(),
|
||||||
onOpenMemberList: null,
|
|
||||||
onOpenPinnedMessagesList: null,
|
|
||||||
),
|
),
|
||||||
body: nothing,
|
body: nothing,
|
||||||
);
|
);
|
||||||
|
|
@ -386,21 +384,20 @@ class RoomChat extends HookConsumerWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
endDrawer: PinnedEventsDrawer(roomId, getEventOptions: getEventOptions),
|
||||||
|
body: Builder(
|
||||||
|
builder: (middleContext) => Scaffold(
|
||||||
|
endDrawer: showMembersByDefault ? null : MemberList(roomId),
|
||||||
appBar: RoomAppbar(
|
appBar: RoomAppbar(
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
onOpenDrawer: (_) => Scaffold.of(context).openDrawer(),
|
onOpenDrawer: Scaffold.of(context).openDrawer,
|
||||||
onOpenMemberList: (thisContext) {
|
onOpenMemberList: (thisContext) {
|
||||||
memberListOpened.value = !memberListOpened.value;
|
memberListOpened.value = !memberListOpened.value;
|
||||||
if (!showMembersByDefault) {
|
|
||||||
Scaffold.of(thisContext).openEndDrawer();
|
Scaffold.of(thisContext).openEndDrawer();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onOpenPinnedMessagesList: (thisContext) {
|
onOpenPinnedMessagesList: () {
|
||||||
memberListOpened.value = false;
|
Scaffold.of(middleContext).openEndDrawer();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
Scaffold.of(thisContext).openEndDrawer();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
body: Row(
|
body: Row(
|
||||||
|
|
@ -435,7 +432,9 @@ class RoomChat extends HookConsumerWidget {
|
||||||
itemCount: value.length,
|
itemCount: value.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final event = value[index];
|
final event = value[index];
|
||||||
final previousEvent = value.getOrNull(index - 1);
|
final previousEvent = value.getOrNull(
|
||||||
|
index - 1,
|
||||||
|
);
|
||||||
return HighlightWrapper(
|
return HighlightWrapper(
|
||||||
EventRenderer(
|
EventRenderer(
|
||||||
event,
|
event,
|
||||||
|
|
@ -443,19 +442,25 @@ class RoomChat extends HookConsumerWidget {
|
||||||
final replyId = event.replyTo;
|
final replyId = event.replyTo;
|
||||||
listController.value.animateToItem(
|
listController.value.animateToItem(
|
||||||
index: value.indexWhere(
|
index: value.indexWhere(
|
||||||
(element) => element.eventId == replyId,
|
(element) =>
|
||||||
|
element.eventId == replyId,
|
||||||
),
|
),
|
||||||
scrollController: scrollController,
|
scrollController: scrollController,
|
||||||
alignment: 0.5,
|
alignment: 0.5,
|
||||||
duration: (_) => .new(milliseconds: 700),
|
duration: (_) =>
|
||||||
|
.new(milliseconds: 700),
|
||||||
curve: (_) => Curves.easeInOut,
|
curve: (_) => Curves.easeInOut,
|
||||||
);
|
);
|
||||||
highlightedEvent.value = replyId;
|
highlightedEvent.value = replyId;
|
||||||
await Future.delayed(.new(seconds: 1), () {
|
await Future.delayed(
|
||||||
if (highlightedEvent.value == replyId) {
|
.new(seconds: 1),
|
||||||
|
() {
|
||||||
|
if (highlightedEvent.value ==
|
||||||
|
replyId) {
|
||||||
highlightedEvent.value = null;
|
highlightedEvent.value = null;
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
getEventOptions: getEventOptions,
|
getEventOptions: getEventOptions,
|
||||||
isGrouped:
|
isGrouped:
|
||||||
|
|
@ -494,7 +499,8 @@ class RoomChat extends HookConsumerWidget {
|
||||||
child: Composer(
|
child: Composer(
|
||||||
roomId,
|
roomId,
|
||||||
node: composerNode,
|
node: composerNode,
|
||||||
onSend: (text, {required shouldMention, required tags}) =>
|
onSend:
|
||||||
|
(text, {required shouldMention, required tags}) =>
|
||||||
notifier
|
notifier
|
||||||
.send(
|
.send(
|
||||||
text,
|
text,
|
||||||
|
|
@ -518,15 +524,6 @@ class RoomChat extends HookConsumerWidget {
|
||||||
MemberList(roomId),
|
MemberList(roomId),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
endDrawer: showMembersByDefault && memberListOpened.value
|
|
||||||
? null
|
|
||||||
: Drawer(
|
|
||||||
shape: Border(),
|
|
||||||
child: memberListOpened.value
|
|
||||||
? MemberList(roomId)
|
|
||||||
: PinnedEventsDrawer(
|
|
||||||
roomId,
|
|
||||||
getEventOptions: getEventOptions,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue