Skip to content

Commit

Permalink
msglist: Add MessageListPageState.narrow
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice authored and chrisbobbe committed Jul 17, 2024
1 parent 7a2c9d2 commit 7285325
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import 'theme.dart';
///
/// To obtain one of these, see [MessageListPage.ancestorOf].
abstract class MessageListPageState {
/// The narrow for this page's message list.
Narrow get narrow;

/// The controller for this [MessageListPage]'s compose box,
/// if this [MessageListPage] offers a compose box.
ComposeBoxController? get composeBoxController;
Expand Down Expand Up @@ -65,6 +68,9 @@ class MessageListPage extends StatefulWidget {
const _kUnsubscribedStreamRecipientHeaderColor = Color(0xfff5f5f5);

class _MessageListPageState extends State<MessageListPage> implements MessageListPageState {
@override
Narrow get narrow => widget.narrow;

@override
ComposeBoxController? get composeBoxController => _composeBoxKey.currentState;

Expand Down
8 changes: 8 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ void main() {
.throws<void>();
});

testWidgets('MessageListPageState.narrow', (tester) async {
final stream = eg.stream();
await setupMessageListPage(tester, narrow: StreamNarrow(stream.streamId),
messages: [eg.streamMessage(stream: stream, content: "<p>a message</p>")]);
final state = MessageListPage.ancestorOf(tester.element(find.text("a message")));
check(state.narrow).equals(StreamNarrow(stream.streamId));
});

testWidgets('composeBoxController finds compose box', (tester) async {
final stream = eg.stream();
await setupMessageListPage(tester, narrow: StreamNarrow(stream.streamId),
Expand Down

0 comments on commit 7285325

Please sign in to comment.