Files
flutter/lib/widgets/app_drawer.dart
Roland Geider ff22d830b2 Rework the about page
This now has more structure and direct links to important places
2021-04-21 22:05:50 +02:00

214 lines
7.6 KiB
Dart

/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wger Workout Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:wger/providers/auth.dart';
class AppDrawer extends StatelessWidget {
void _launchURL(String url, BuildContext context) async {
await canLaunch(url)
? await launch(url)
: ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Could not open $url.")),
);
}
@override
Widget build(BuildContext context) {
final authProvider = Provider.of<Auth>(context, listen: false);
return Drawer(
child: Column(
children: [
AppBar(
title: Text('wger'),
automaticallyImplyLeading: false,
),
/*
ListTile(
leading: Icon(Icons.home),
title: Text(AppLocalizations.of(context)!.labelDashboard),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed(DashboardScreen.routeName);
},
),
Divider(),
ListTile(
leading: Icon(Icons.shop),
title: Text('Training'),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed(WorkoutPlansScreen.routeName);
},
),
Divider(),
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Nutrition'),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed(NutritionScreen.routeName);
},
),
Divider(),
ListTile(
leading: Icon(Icons.bar_chart),
title: Text('Weight'),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed(WeightScreen.routeName);
},
),
Divider(),
Expanded(child: Container()),
*/
/*
ListTile(
//dense: true,
leading: Icon(Icons.build),
title: Text('Options'),
onTap: () {
showDialog(
context: context,
builder: (context) => AlertDialog(
content: Text("Would show options dialog"),
actions: [
TextButton(
child: Text(
"Close",
),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
),
*/
ListTile(
//dense: true,
leading: Icon(Icons.exit_to_app),
title: Text(AppLocalizations.of(context)!.logout),
onTap: () {
Provider.of<Auth>(context, listen: false).logout();
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/');
},
),
AboutListTile(
//dense: true,
icon: Icon(Icons.info),
applicationName: 'wger',
applicationVersion: 'App: ${authProvider.applicationVersion!.version}\n'
'Server: ${authProvider.serverVersion}',
applicationLegalese: '\u{a9} 2020 - 2021 contributors',
applicationIcon: Padding(
padding: const EdgeInsets.only(top: 10),
child: Image.asset(
'assets/images/logo.png',
width: 60,
),
),
aboutBoxChildren: [
SizedBox(height: 10),
Text(AppLocalizations.of(context)!.aboutDescription),
SizedBox(height: 20),
ListTile(
leading: Icon(Icons.code),
title: Text(AppLocalizations.of(context)!.aboutSourceTitle),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context)!.aboutSourceText),
Text(
'https://github.com/wger-project',
style: TextStyle(color: Colors.blue),
),
],
),
contentPadding: EdgeInsets.zero,
onTap: () async => _launchURL("https://github.com/wger-project", context),
),
SizedBox(height: 10),
ListTile(
leading: Icon(Icons.bug_report),
title: Text(AppLocalizations.of(context)!.aboutBugsTitle),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context)!.aboutBugsText),
Text(
'https://github.com/wger-project/flutter/issues/new/choose',
style: TextStyle(color: Colors.blue),
)
],
),
contentPadding: EdgeInsets.zero,
onTap: () async => _launchURL(
'https://github.com/wger-project/flutter/issues/new/choose', context),
),
SizedBox(height: 10),
ListTile(
leading: Icon(Icons.chat),
title: Text(AppLocalizations.of(context)!.aboutContactUsTitle),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context)!.aboutContactUsText),
Text(
'https://discord.gg/rPWFv6W',
style: TextStyle(color: Colors.blue),
),
],
),
contentPadding: EdgeInsets.zero,
onTap: () async => _launchURL('https://discord.gg/rPWFv6W', context),
),
SizedBox(height: 10),
ListTile(
leading: Icon(Icons.translate),
title: Text(AppLocalizations.of(context)!.aboutTranslationTitle),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context)!.aboutTranslationText),
Text(
'https://hosted.weblate.org/engage/wger/',
style: TextStyle(color: Colors.blue),
),
],
),
contentPadding: EdgeInsets.zero,
onTap: () async => _launchURL('https://hosted.weblate.org/engage/wger/', context),
),
],
),
],
),
);
}
}