Skip to content

Commit cfc3354

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 7771f4b commit cfc3354

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-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+
if (_packageInfo != null) ...[
41+
ListTile(title: const Text('App version'), subtitle: Text(_packageInfo!.version)),
42+
],
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: 28 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,30 @@ 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+
final navigator = Navigator.of(context);
93+
94+
return PopupMenuButton<ChooseAccountPageOverflowMenuItem>(
95+
itemBuilder: (BuildContext context) => const [
96+
PopupMenuItem(
97+
value: ChooseAccountPageOverflowMenuItem.aboutZulip,
98+
child: Text('About Zulip')),
99+
],
100+
onSelected: (item) {
101+
switch (item) {
102+
case ChooseAccountPageOverflowMenuItem.aboutZulip:
103+
navigator.push(AboutZulipPage.buildRoute(context));
104+
}
105+
});
106+
}
107+
}
108+
82109
class HomePage extends StatelessWidget {
83110
const HomePage({super.key});
84111

0 commit comments

Comments
 (0)