Skip to content

Commit 4d6f561

Browse files
committed
accounts ui: Add "About Zulip" page, reachable from "Choose account" page
From this new page, the user can tap a button to show [LicensePage], so resolving #99. Fixes: #99
1 parent cc69691 commit 4d6f561

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

lib/widgets/about_zulip.dart

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:package_info_plus/package_info_plus.dart';
3+
4+
class AboutZulipPage extends StatefulWidget {
5+
const AboutZulipPage({super.key});
6+
7+
static Route<void> buildRoute(BuildContext context) {
8+
return MaterialPageRoute(builder: (context) => const AboutZulipPage());
9+
}
10+
11+
@override
12+
State<AboutZulipPage> createState() => _AboutZulipPageState();
13+
}
14+
15+
class _AboutZulipPageState extends State<AboutZulipPage> {
16+
PackageInfo? _packageInfo;
17+
18+
@override
19+
void initState() {
20+
super.initState();
21+
(() async {
22+
final result = await PackageInfo.fromPlatform();
23+
setState(() {
24+
_packageInfo = result;
25+
});
26+
})();
27+
}
28+
29+
@override
30+
Widget build(BuildContext context) {
31+
return Scaffold(
32+
appBar: AppBar(title: const Text("About Zulip")),
33+
body: SingleChildScrollView(
34+
child: SafeArea(
35+
minimum: const EdgeInsets.all(8), // ListView pads vertical
36+
child: Center(
37+
child: ConstrainedBox(
38+
constraints: const BoxConstraints(maxWidth: 400),
39+
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
40+
ListTile(
41+
title: const Text('App version'),
42+
subtitle: Text(_packageInfo?.version ?? '(…)')),
43+
ListTile(
44+
title: const Text('Open-source licenses'),
45+
subtitle: const Text('Tap to view'),
46+
onTap: () {
47+
// TODO(upstream?): This route and its child routes (pushed
48+
// when you tap a package to view its licenses) can't be
49+
// popped on iOS with the swipe-away gesture; you have to
50+
// tap the "Back" button. Debug/fix.
51+
showLicensePage(context: context);
52+
}),
53+
])))),
54+
));
55+
}
56+
}

lib/widgets/app.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22

3+
import 'about_zulip.dart';
34
import 'compose_box.dart';
45
import 'login.dart';
56
import 'message_list.dart';
@@ -57,7 +58,9 @@ class ChooseAccountPage extends StatelessWidget {
5758
assert(!PerAccountStoreWidget.debugExistsOf(context));
5859
final globalStore = GlobalStoreWidget.of(context);
5960
return Scaffold(
60-
appBar: AppBar(title: const Text('Choose account')),
61+
appBar: AppBar(
62+
title: const Text('Choose account'),
63+
actions: const [ChooseAccountPageOverflowButton()]),
6164
body: SafeArea(
6265
minimum: const EdgeInsets.all(8),
6366
child: Center(
@@ -79,6 +82,28 @@ class ChooseAccountPage extends StatelessWidget {
7982
}
8083
}
8184

85+
enum ChooseAccountPageOverflowMenuItem { aboutZulip }
86+
87+
class ChooseAccountPageOverflowButton extends StatelessWidget {
88+
const ChooseAccountPageOverflowButton({super.key});
89+
90+
@override
91+
Widget build(BuildContext context) {
92+
return PopupMenuButton<ChooseAccountPageOverflowMenuItem>(
93+
itemBuilder: (BuildContext context) => const [
94+
PopupMenuItem(
95+
value: ChooseAccountPageOverflowMenuItem.aboutZulip,
96+
child: Text('About Zulip')),
97+
],
98+
onSelected: (item) {
99+
switch (item) {
100+
case ChooseAccountPageOverflowMenuItem.aboutZulip:
101+
Navigator.push(context, AboutZulipPage.buildRoute(context));
102+
}
103+
});
104+
}
105+
}
106+
82107
class HomePage extends StatelessWidget {
83108
const HomePage({super.key});
84109

0 commit comments

Comments
 (0)