Skip to content

Commit 4b42f7a

Browse files
chungwweignprice
authored andcommitted
all_channels: Remove three dot menu and add gesture controls
Make the All Channels Page consistent with the Channel Page, as navigating to channel feed and opening the bottom sheet currently uses the three-dot menu icon, which differs from the gesture pattern used in the Channel Page. Fixes part of zulip#1914
1 parent 9043c5f commit 4b42f7a

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

lib/widgets/all_channels.dart

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import '../api/route/channels.dart';
55
import '../generated/l10n/zulip_localizations.dart';
66
import '../log.dart';
77
import '../model/channel.dart';
8+
import '../model/narrow.dart';
89
import 'action_sheet.dart';
910
import 'actions.dart';
1011
import 'app_bar.dart';
1112
import 'button.dart';
1213
import 'icons.dart';
14+
import 'message_list.dart';
1315
import 'page.dart';
1416
import 'remote_settings.dart';
1517
import 'store.dart';
@@ -96,29 +98,28 @@ class AllChannelsListEntry extends StatelessWidget {
9698
final Subscription? subscription = channel is Subscription ? channel : null;
9799
final hasContentAccess = store.selfHasContentAccess(channel);
98100

99-
return ConstrainedBox(constraints: const BoxConstraints(minHeight: 44),
100-
child: Padding(
101-
padding: EdgeInsetsDirectional.only(start: 8, end: 4),
102-
child: Row(spacing: 6, children: [
103-
Icon(
104-
size: 20,
105-
color: colorSwatchFor(context, subscription).iconOnPlainBackground,
106-
iconDataForStream(channel)),
107-
Expanded(
108-
child: Text(
109-
style: TextStyle(
110-
color: designVariables.textMessage,
111-
fontSize: 17,
112-
height: 20 / 17,
113-
).merge(weightVariableTextStyle(context, wght: 600)),
114-
channel.name)),
115-
if (hasContentAccess) _SubscribeToggle(channel: channel),
116-
ZulipIconButton(
117-
icon: ZulipIcons.more_horizontal,
118-
onPressed: () {
119-
showChannelActionSheet(context, channelId: channel.streamId);
120-
}),
121-
])));
101+
return InkWell(
102+
onTap: !hasContentAccess ? null : () => Navigator.push(context,
103+
MessageListPage.buildRoute(context: context,
104+
narrow: ChannelNarrow(channel.streamId))),
105+
onLongPress: () => showChannelActionSheet(context, channelId: channel.streamId),
106+
child: ConstrainedBox(constraints: const BoxConstraints(minHeight: 44),
107+
child: Padding(padding: const EdgeInsetsDirectional.only(start: 8, end: 12),
108+
child: Row(spacing: 6, children: [
109+
Icon(
110+
size: 20,
111+
color: colorSwatchFor(context, subscription).iconOnPlainBackground,
112+
iconDataForStream(channel)),
113+
Expanded(
114+
child: Text(
115+
style: TextStyle(
116+
color: designVariables.textMessage,
117+
fontSize: 17,
118+
height: 20 / 17,
119+
).merge(weightVariableTextStyle(context, wght: 600)),
120+
channel.name)),
121+
if (hasContentAccess) _SubscribeToggle(channel: channel),
122+
]))));
122123
}
123124
}
124125

test/widgets/all_channels_test.dart

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:zulip/widgets/app_bar.dart';
1212
import 'package:zulip/widgets/button.dart';
1313
import 'package:zulip/widgets/home.dart';
1414
import 'package:zulip/widgets/icons.dart';
15+
import 'package:zulip/widgets/message_list.dart';
1516
import 'package:zulip/widgets/page.dart';
1617
import 'package:zulip/widgets/remote_settings.dart';
1718
import 'package:zulip/widgets/theme.dart';
@@ -203,23 +204,37 @@ void main() {
203204
check(maybeToggle).isNull();
204205
}
205206

206-
check(findInRow(find.byIcon(ZulipIcons.more_horizontal))).findsOne();
207-
208207
final touchTargetSize = tester.getSize(findElement);
209208
check(touchTargetSize.height).equals(44);
210209
}
211210
});
212211

213-
testWidgets('tapping three-dots button opens channel action sheet', (tester) async {
212+
testWidgets('open channel action sheet on long press', (tester) async {
214213
await setupAllChannelsPage(tester, channels: [eg.stream()]);
215214

216-
await tester.tap(find.byIcon(ZulipIcons.more_horizontal));
215+
await tester.longPress(find.byType(AllChannelsListEntry));
217216
await tester.pump();
218217
await transitionDurationObserver.pumpPastTransition(tester);
219218

220219
check(find.byType(BottomSheet)).findsOne();
221220
});
222221

222+
testWidgets('navigate to channel feed on tap', (tester) async {
223+
final channel = eg.stream(name: 'some-channel');
224+
await setupAllChannelsPage(tester, channels: [channel]);
225+
226+
connection.prepare(json: eg.newestGetMessagesResult(
227+
foundOldest: true, messages: [eg.streamMessage(stream: channel)]).toJson());
228+
await tester.tap(find.byType(AllChannelsListEntry));
229+
await tester.pump();
230+
await transitionDurationObserver.pumpPastTransition(tester);
231+
232+
check(find.descendant(
233+
of: find.byType(MessageListPage),
234+
matching: find.text('some-channel')),
235+
).findsOne();
236+
});
237+
223238
testWidgets('use toggle switch to subscribe/unsubscribe', (tester) async {
224239
final channel = eg.stream();
225240
await setupAllChannelsPage(tester, channels: [channel]);

0 commit comments

Comments
 (0)