Skip to content

Commit f0b710a

Browse files
committed
channel_list: Show a label when no channels are found
1 parent 71199d6 commit f0b710a

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@
491491
"@channelListPageTitle": {
492492
"description": "Title for the page of all channels."
493493
},
494+
"noChannelsFound": "There are no channels you can view in this organization.",
495+
"@noChannelsFound": {
496+
"description": "Message when no channels are found"
497+
},
494498
"notifGroupDmConversationLabel": "{senderFullName} to you and {numOthers, plural, =1{1 other} other{{numOthers} others}}",
495499
"@notifGroupDmConversationLabel": {
496500
"description": "Label for a group DM conversation notification.",

lib/widgets/channel_list.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@ class ChannelListPage extends StatelessWidget {
2424
return Scaffold(
2525
appBar: AppBar(title: Text(zulipLocalizations.channelListPageTitle)),
2626
body: SafeArea(
27-
child: ListView.builder(
27+
child: streams.isEmpty ? const _NoStreamsItem() : ListView.builder(
2828
itemCount: streams.length,
2929
itemBuilder: (context, index) => ChannelItem(stream: streams[index]))));
3030
}
3131
}
3232

33+
class _NoStreamsItem extends StatelessWidget {
34+
const _NoStreamsItem();
35+
36+
@override
37+
Widget build(BuildContext context) {
38+
final zulipLocalizations = ZulipLocalizations.of(context);
39+
return Center(
40+
child: Padding(
41+
padding: const EdgeInsets.all(10),
42+
child: Text(zulipLocalizations.noChannelsFound,
43+
textAlign: TextAlign.center,
44+
style: TextStyle(
45+
// TODO(#95) need dark-theme color
46+
color: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
47+
fontSize: 18,
48+
height: (20 / 18),
49+
))));
50+
}
51+
}
52+
3353
@visibleForTesting
3454
class ChannelItem extends StatelessWidget {
3555
const ChannelItem({super.key, required this.stream});

test/widgets/channel_list_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:checks/checks.dart';
22
import 'package:flutter_test/flutter_test.dart';
33
import 'package:zulip/api/model/model.dart';
4+
import 'package:zulip/model/localizations.dart';
45
import 'package:zulip/widgets/channel_list.dart';
56

67
import '../model/binding.dart';
@@ -30,8 +31,10 @@ void main() {
3031
}
3132

3233
testWidgets('smoke', (tester) async {
34+
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
3335
await setupChannelListPage(tester, streams: [], subscriptions: []);
3436
check(getItemCount()).equals(0);
37+
check(find.text(zulipLocalizations.noChannelsFound).evaluate()).isNotEmpty();
3538
});
3639

3740
testWidgets('basic list', (tester) async {

0 commit comments

Comments
 (0)