Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

add typing indicators

Fixes #92
This commit is contained in:
Henry Hiles 2026-10-21 15:07:02 -04:00
commit 0fcbc275cd
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 326 additions and 1 deletions

View file

@ -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,

View file

@ -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,