|
| 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 | +} |
0 commit comments