forked from Nexus/nexus
parent
a54004736b
commit
0fcbc275cd
2 changed files with 326 additions and 1 deletions
|
|
@ -13,6 +13,9 @@ class const ChatTimeline({
|
|||
required final IList<PopupMenuEntry> Function(Event) getEventOptions,
|
||||
required final int? highlightedEvent,
|
||||
required final double composerHeight,
|
||||
|
||||
/// The typing indicator's height, or zero while it's hidden.
|
||||
required final double typingIndicatorHeight,
|
||||
final void Function(int rowId)? onSwipe,
|
||||
super.key,
|
||||
}) extends StatelessWidget {
|
||||
|
|
@ -40,7 +43,22 @@ class const ChatTimeline({
|
|||
keyboardDismissBehavior: .onDrag,
|
||||
controller: scroll.scrollController,
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: SizedBox(height: composerHeight)),
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
// Makes room for the typing indicator, with a small gap above it,
|
||||
// so it doesn't cover messages
|
||||
AnimatedContainer(
|
||||
duration: Durations.medium2,
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
height: typingIndicatorHeight == 0
|
||||
? 0
|
||||
: typingIndicatorHeight + 4,
|
||||
),
|
||||
SizedBox(height: composerHeight),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SuperSliverList.builder(
|
||||
itemCount: scroll.liveRows.length,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import "package:nexus/helpers/hooks/chat_scroll.dart";
|
|||
import "package:nexus/models/event.dart";
|
||||
import "package:nexus/models/relation_type.dart";
|
||||
import "package:nexus/widgets/composer/composer.dart";
|
||||
import "package:nexus/widgets/composer/typing_indicator.dart";
|
||||
import "package:nexus/widgets/error_dialog.dart";
|
||||
import "package:nexus/widgets/loading.dart";
|
||||
import "package:nexus/widgets/pinned_events_drawer.dart";
|
||||
|
|
@ -46,6 +47,7 @@ final class const RoomChat({
|
|||
final highlightedEvent = useState<int?>(null);
|
||||
|
||||
final composerSize = useState<double>(64);
|
||||
final typingIndicatorSize = useState<double>(0);
|
||||
|
||||
final userId = ref.watch(ClientStateController.provider)?.userId;
|
||||
final memberListOpened = ref
|
||||
|
|
@ -252,6 +254,8 @@ final class const RoomChat({
|
|||
: null,
|
||||
highlightedEvent: highlightedEvent.value,
|
||||
composerHeight: composerSize.value,
|
||||
typingIndicatorHeight:
|
||||
typingIndicatorSize.value,
|
||||
),
|
||||
AsyncLoading _ => Loading(),
|
||||
AsyncError(
|
||||
|
|
@ -262,6 +266,17 @@ final class const RoomChat({
|
|||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: composerSize.value,
|
||||
left: 12,
|
||||
// To give space for jump to bottom button
|
||||
right: 72,
|
||||
child: MeasureSize(
|
||||
onChange: (size) =>
|
||||
typingIndicatorSize.value = size.height,
|
||||
child: TypingIndicator(roomId),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 16,
|
||||
bottom: composerSize.value,
|
||||
|
|
|
|||
Loading…
Reference in a new issue