Skip to content

Commit 766f071

Browse files
chrisbobbegnprice
authored andcommitted
action_sheet: Put mark-channel-as-read button at top of action sheet
As in the Figma: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6812-34593&m=dev
1 parent 8d3c128 commit 766f071

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

lib/widgets/action_sheet.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,25 @@ void showChannelActionSheet(BuildContext context, {
241241
final pageContext = PageRoot.contextOf(context);
242242
final store = PerAccountStoreWidget.of(pageContext);
243243

244-
final optionButtons = <ActionSheetMenuItemButton>[
245-
TopicListButton(pageContext: pageContext, channelId: channelId),
246-
];
244+
final optionButtons = <ActionSheetMenuItemButton>[];
247245

248246
final unreadCount = store.unreads.countInChannelNarrow(channelId);
249247
if (unreadCount > 0) {
250248
optionButtons.add(
251249
MarkChannelAsReadButton(pageContext: pageContext, channelId: channelId));
252250
}
253251

252+
optionButtons.add(
253+
TopicListButton(pageContext: pageContext, channelId: channelId));
254+
254255
optionButtons.add(
255256
CopyChannelLinkButton(channelId: channelId, pageContext: pageContext));
256257

257258
_showActionSheet(pageContext, optionButtons: optionButtons);
258259
}
259260

260-
class TopicListButton extends ActionSheetMenuItemButton {
261-
const TopicListButton({
261+
class MarkChannelAsReadButton extends ActionSheetMenuItemButton {
262+
const MarkChannelAsReadButton({
262263
super.key,
263264
required this.channelId,
264265
required super.pageContext,
@@ -267,22 +268,22 @@ class TopicListButton extends ActionSheetMenuItemButton {
267268
final int channelId;
268269

269270
@override
270-
IconData get icon => ZulipIcons.topics;
271+
IconData get icon => ZulipIcons.message_checked;
271272

272273
@override
273274
String label(ZulipLocalizations zulipLocalizations) {
274-
return zulipLocalizations.actionSheetOptionListOfTopics;
275+
return zulipLocalizations.actionSheetOptionMarkChannelAsRead;
275276
}
276277

277278
@override
278-
void onPressed() {
279-
Navigator.push(pageContext,
280-
TopicListPage.buildRoute(context: pageContext, streamId: channelId));
279+
void onPressed() async {
280+
final narrow = ChannelNarrow(channelId);
281+
await ZulipAction.markNarrowAsRead(pageContext, narrow);
281282
}
282283
}
283284

284-
class MarkChannelAsReadButton extends ActionSheetMenuItemButton {
285-
const MarkChannelAsReadButton({
285+
class TopicListButton extends ActionSheetMenuItemButton {
286+
const TopicListButton({
286287
super.key,
287288
required this.channelId,
288289
required super.pageContext,
@@ -291,17 +292,17 @@ class MarkChannelAsReadButton extends ActionSheetMenuItemButton {
291292
final int channelId;
292293

293294
@override
294-
IconData get icon => ZulipIcons.message_checked;
295+
IconData get icon => ZulipIcons.topics;
295296

296297
@override
297298
String label(ZulipLocalizations zulipLocalizations) {
298-
return zulipLocalizations.actionSheetOptionMarkChannelAsRead;
299+
return zulipLocalizations.actionSheetOptionListOfTopics;
299300
}
300301

301302
@override
302-
void onPressed() async {
303-
final narrow = ChannelNarrow(channelId);
304-
await ZulipAction.markNarrowAsRead(pageContext, narrow);
303+
void onPressed() {
304+
Navigator.push(pageContext,
305+
TopicListPage.buildRoute(context: pageContext, streamId: channelId));
305306
}
306307
}
307308

test/widgets/action_sheet_test.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ void main() {
247247
group('showChannelActionSheet', () {
248248
void checkButtons() {
249249
check(actionSheetFinder).findsOne();
250-
checkButton('List of topics');
251250
checkButton('Mark channel as read');
251+
checkButton('List of topics');
252252
checkButton('Copy link to channel');
253253
}
254254

@@ -291,19 +291,6 @@ void main() {
291291
});
292292
});
293293

294-
testWidgets('TopicListButton', (tester) async {
295-
await prepare();
296-
await showFromAppBar(tester,
297-
narrow: ChannelNarrow(someChannel.streamId));
298-
299-
connection.prepare(json: GetStreamTopicsResult(topics: [
300-
eg.getStreamTopicsEntry(name: 'some topic foo'),
301-
]).toJson());
302-
await tester.tap(findButtonForLabel('List of topics'));
303-
await tester.pumpAndSettle();
304-
check(find.text('some topic foo')).findsOne();
305-
});
306-
307294
group('MarkChannelAsReadButton', () {
308295
void checkRequest(int channelId) {
309296
check(connection.takeRequests()).single.isA<http.Request>()
@@ -350,6 +337,19 @@ void main() {
350337
});
351338
});
352339

340+
testWidgets('TopicListButton', (tester) async {
341+
await prepare();
342+
await showFromAppBar(tester,
343+
narrow: ChannelNarrow(someChannel.streamId));
344+
345+
connection.prepare(json: GetStreamTopicsResult(topics: [
346+
eg.getStreamTopicsEntry(name: 'some topic foo'),
347+
]).toJson());
348+
await tester.tap(findButtonForLabel('List of topics'));
349+
await tester.pumpAndSettle();
350+
check(find.text('some topic foo')).findsOne();
351+
});
352+
353353
group('CopyChannelLinkButton', () {
354354
setUp(() async {
355355
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(

0 commit comments

Comments
 (0)