Skip to content

Commit 3e2fe5c

Browse files
committed
all_channels: Remove three dot menu and add gesture controls
Make the All channels view UI consistent with the Channels view. Specifically, onTap on a row item should lead to channel feed page and onLongPress should launch the channel bottom sheet. - all_channels: Add SizedBox(height: 40, width: 52) as a placeholder when toggle shouldn't shown. The top and bottom padding at 2 will make the Row height at least 44 px. Width is set to 52 to match the width of the toggle, so long text wouldn't extend all the way before text ellipsis - all_channels: Add on tap to channel feed if user has content access - all_channels: Add additional end padding for row item, also setting top and bottom padding to 2 so that widget height is at least 44px Fixes #1914
1 parent cc2b97e commit 3e2fe5c

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

lib/widgets/all_channels.dart

Lines changed: 26 additions & 22 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,28 +98,30 @@ class AllChannelsListEntry extends StatelessWidget {
9698
final Subscription? subscription = channel is Subscription ? channel : null;
9799
final hasContentAccess = store.selfHasContentAccess(channel);
98100

99-
return Padding(
100-
padding: EdgeInsetsDirectional.only(start: 8, end: 4),
101-
child: Row(spacing: 6, children: [
102-
Icon(
103-
size: 20,
104-
color: colorSwatchFor(context, subscription).iconOnPlainBackground,
105-
iconDataForStream(channel)),
106-
Expanded(
107-
child: Text(
108-
style: TextStyle(
109-
color: designVariables.textMessage,
110-
fontSize: 17,
111-
height: 20 / 17,
112-
).merge(weightVariableTextStyle(context, wght: 600)),
113-
channel.name)),
114-
if (hasContentAccess) _SubscribeToggle(channel: channel),
115-
ZulipIconButton(
116-
icon: ZulipIcons.more_horizontal,
117-
onPressed: () {
118-
showChannelActionSheet(context, channelId: channel.streamId);
119-
}),
120-
]));
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: Padding(
107+
padding: const EdgeInsets.fromLTRB(8, 2, 12, 2),
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+
maxLines: 1,
116+
overflow: TextOverflow.ellipsis,
117+
style: TextStyle(
118+
color: designVariables.textMessage,
119+
fontSize: 17,
120+
height: 20 / 17,
121+
).merge(weightVariableTextStyle(context, wght: 600)),
122+
channel.name)),
123+
hasContentAccess ? _SubscribeToggle(channel: channel) : const SizedBox(height: 40, width: 52),
124+
])));
121125
}
122126
}
123127

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';
@@ -202,21 +203,35 @@ void main() {
202203
} else {
203204
check(maybeToggle).isNull();
204205
}
205-
206-
check(findInRow(find.byIcon(ZulipIcons.more_horizontal))).findsOne();
207206
}
208207
});
209208

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

213-
await tester.tap(find.byIcon(ZulipIcons.more_horizontal));
212+
await tester.longPress(find.byType(AllChannelsListEntry));
214213
await tester.pump();
215214
await transitionDurationObserver.pumpPastTransition(tester);
216215

217216
check(find.byType(BottomSheet)).findsOne();
218217
});
219218

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

0 commit comments

Comments
 (0)