Skip to content

Commit eba77d1

Browse files
committed
all_channels: Replace three dot menu with long press gesture and add on tap to feed
all_channels: Add empty SizedBox as placeholder when toggle isn't shown for layout consistency all_channels: Add on tap to channel feed if user has content access action_sheet: Refine button visibility conditions in channel bottom sheet onLongPress all_channels: Add additional end padding for row item Fixes #1914
1 parent cc2b97e commit eba77d1

File tree

3 files changed

+53
-30
lines changed

3 files changed

+53
-30
lines changed

lib/widgets/action_sheet.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,16 @@ void showChannelActionSheet(BuildContext context, {
451451
final unreadCount = store.unreads.countInChannelNarrow(channelId);
452452
final channel = store.streams[channelId];
453453
final isSubscribed = channel is Subscription;
454+
final hasContentAccess = channel != null && store.selfHasContentAccess(channel);
454455
final buttonSections = [
455-
if (!isSubscribed
456-
&& channel != null && store.selfHasContentAccess(channel))
456+
if (!isSubscribed && hasContentAccess)
457457
[SubscribeButton(pageContext: pageContext, channelId: channelId)],
458458
[
459-
if (unreadCount > 0)
459+
if (hasContentAccess && unreadCount > 0)
460460
MarkChannelAsReadButton(pageContext: pageContext, channelId: channelId),
461-
if (showTopicListButton)
461+
if (hasContentAccess && showTopicListButton)
462462
TopicListButton(pageContext: pageContext, channelId: channelId),
463-
if (!isOnChannelFeed)
463+
if (hasContentAccess && !isOnChannelFeed)
464464
ChannelFeedButton(pageContext: pageContext, channelId: channelId),
465465
CopyChannelLinkButton(channelId: channelId, pageContext: pageContext)
466466
],

lib/widgets/all_channels.dart

Lines changed: 29 additions & 21 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';
@@ -97,27 +99,33 @@ class AllChannelsListEntry extends StatelessWidget {
9799
final hasContentAccess = store.selfHasContentAccess(channel);
98100

99101
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-
]));
102+
padding: EdgeInsetsDirectional.only(start: 8, end: 12),
103+
child: GestureDetector(
104+
onTap: hasContentAccess ? () {
105+
Navigator.push(context, MessageListPage.buildRoute(
106+
context: context,
107+
narrow: ChannelNarrow(channel.streamId)));
108+
} : null,
109+
onLongPress: () {
110+
showChannelActionSheet(context, channelId: channel.streamId);
111+
},
112+
child: SizedBox(
113+
height: 38,
114+
child: Row(spacing: 6, children: [
115+
Icon(
116+
size: 20,
117+
color: colorSwatchFor(context, subscription).iconOnPlainBackground,
118+
iconDataForStream(channel)),
119+
Expanded(
120+
child: Text(
121+
style: TextStyle(
122+
color: designVariables.textMessage,
123+
fontSize: 17,
124+
height: 20 / 17,
125+
).merge(weightVariableTextStyle(context, wght: 600)),
126+
channel.name)),
127+
hasContentAccess ? _SubscribeToggle(channel: channel) : const SizedBox.shrink(),
128+
]))));
121129
}
122130
}
123131

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)