mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge branch 'master' into issue852/hide-diet-plan
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/core/wide_screen_wrapper.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
@@ -53,164 +54,166 @@ class AboutPage extends StatelessWidget {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(i18n.aboutPageTitle)),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 60,
|
||||
semanticLabel: 'wger logo',
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'wger',
|
||||
style: TextStyle(
|
||||
fontSize: 23,
|
||||
fontWeight: FontWeight.w600,
|
||||
body: WidescreenWrapper(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 60,
|
||||
semanticLabel: 'wger logo',
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'wger',
|
||||
style: TextStyle(
|
||||
fontSize: 23,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'App: ${authProvider.applicationVersion?.version ?? 'N/A'}\n'
|
||||
'Server: ${authProvider.serverVersion ?? 'N/A'}',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
'\u{a9} ${today.year} wger contributors',
|
||||
Text(
|
||||
'App: ${authProvider.applicationVersion?.version ?? 'N/A'}\n'
|
||||
'Server: ${authProvider.serverVersion ?? 'N/A'}',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutWhySupportTitle),
|
||||
Text(i18n.aboutDescription),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutContributeTitle),
|
||||
Text(i18n.aboutContributeText),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: Text(i18n.aboutBugsListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(GITHUB_ISSUES_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.translate),
|
||||
title: Text(i18n.aboutTranslationListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(WEBLATE_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.code),
|
||||
title: Text(i18n.aboutSourceListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(GITHUB_PROJECT_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.dumbbell, size: 18),
|
||||
title: Text(i18n.contributeExercise),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => Navigator.of(context).pushNamed(AddExerciseScreen.routeName),
|
||||
),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutDonateTitle),
|
||||
Text(i18n.aboutDonateText),
|
||||
const SizedBox(height: 15),
|
||||
// Using Wrap for buttons to handle different screen sizes potentially
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 10.0,
|
||||
runSpacing: 10.0,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.mugHot, size: 18),
|
||||
label: const Text('Buy me a coffee'),
|
||||
onPressed: () => launchURL(BUY_ME_A_COFFEE_URL, context),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.solidHeart, size: 18),
|
||||
label: const Text('Liberapay'),
|
||||
onPressed: () => launchURL(LIBERAPAY_URL, context),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.github, size: 18),
|
||||
label: const Text('GitHub Sponsors'),
|
||||
onPressed: () => launchURL(GITHUB_SPONSORS_URL, context),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
'\u{a9} ${today.year} wger contributors',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutJoinCommunityTitle),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.discord),
|
||||
trailing: const Icon(Icons.arrow_outward),
|
||||
title: Text(i18n.aboutDiscordTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(DISCORD_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.mastodon),
|
||||
trailing: const Icon(Icons.arrow_outward),
|
||||
title: Text(i18n.aboutMastodonTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(MASTODON_URL, context),
|
||||
),
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutWhySupportTitle),
|
||||
Text(i18n.aboutDescription),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.others),
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutContributeTitle),
|
||||
Text(i18n.aboutContributeText),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: Text(i18n.aboutBugsListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(GITHUB_ISSUES_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.translate),
|
||||
title: Text(i18n.aboutTranslationListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(WEBLATE_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.code),
|
||||
title: Text(i18n.aboutSourceListTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(GITHUB_PROJECT_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.dumbbell, size: 18),
|
||||
title: Text(i18n.contributeExercise),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => Navigator.of(context).pushNamed(AddExerciseScreen.routeName),
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.article),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: Text(i18n.applicationLogs),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(LogOverviewPage.routeName);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.article),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('View Licenses'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
showLicensePage(
|
||||
context: context,
|
||||
applicationName: 'wger',
|
||||
applicationVersion:
|
||||
'App: ${authProvider.applicationVersion?.version ?? 'N/A'} '
|
||||
'Server: ${authProvider.serverVersion ?? 'N/A'}',
|
||||
applicationLegalese: '\u{a9} ${today.year} wger contributors',
|
||||
applicationIcon: Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 60,
|
||||
semanticLabel: 'wger logo',
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutDonateTitle),
|
||||
Text(i18n.aboutDonateText),
|
||||
const SizedBox(height: 15),
|
||||
// Using Wrap for buttons to handle different screen sizes potentially
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 10.0,
|
||||
runSpacing: 10.0,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.mugHot, size: 18),
|
||||
label: const Text('Buy me a coffee'),
|
||||
onPressed: () => launchURL(BUY_ME_A_COFFEE_URL, context),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.solidHeart, size: 18),
|
||||
label: const Text('Liberapay'),
|
||||
onPressed: () => launchURL(LIBERAPAY_URL, context),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
icon: const FaIcon(FontAwesomeIcons.github, size: 18),
|
||||
label: const Text('GitHub Sponsors'),
|
||||
onPressed: () => launchURL(GITHUB_SPONSORS_URL, context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.aboutJoinCommunityTitle),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.discord),
|
||||
trailing: const Icon(Icons.arrow_outward),
|
||||
title: Text(i18n.aboutDiscordTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(DISCORD_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const FaIcon(FontAwesomeIcons.mastodon),
|
||||
trailing: const Icon(Icons.arrow_outward),
|
||||
title: Text(i18n.aboutMastodonTitle),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => launchURL(MASTODON_URL, context),
|
||||
),
|
||||
|
||||
_buildSectionSpacer(),
|
||||
_buildSectionHeader(context, i18n.others),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.article),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: Text(i18n.applicationLogs),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(LogOverviewPage.routeName);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.article),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('View Licenses'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
showLicensePage(
|
||||
context: context,
|
||||
applicationName: 'wger',
|
||||
applicationVersion:
|
||||
'App: ${authProvider.applicationVersion?.version ?? 'N/A'} '
|
||||
'Server: ${authProvider.serverVersion ?? 'N/A'}',
|
||||
applicationLegalese: '\u{a9} ${today.year} wger contributors',
|
||||
applicationIcon: Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 60,
|
||||
semanticLabel: 'wger logo',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,20 +1,73 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
|
||||
class ImageFormatNotSupported extends StatelessWidget {
|
||||
Widget handleImageError(
|
||||
BuildContext context,
|
||||
Object error,
|
||||
StackTrace? stackTrace,
|
||||
String imageUrl,
|
||||
) {
|
||||
final imageFormat = imageUrl.split('.').last.toUpperCase();
|
||||
final logger = Logger('handleImageError');
|
||||
logger.warning('Failed to load image $imageUrl: $error, $stackTrace');
|
||||
|
||||
// NOTE: for the moment the other error messages are not localized
|
||||
String message = '';
|
||||
switch (error.runtimeType) {
|
||||
case NetworkImageLoadException:
|
||||
message = 'Network error';
|
||||
case HttpException:
|
||||
message = 'Http error';
|
||||
case FormatException:
|
||||
//TODO: not sure if this is the right exception for unsupported image formats?
|
||||
message = AppLocalizations.of(context).imageFormatNotSupported(imageFormat);
|
||||
default:
|
||||
message = 'Other exception';
|
||||
}
|
||||
|
||||
return AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: ImageError(
|
||||
message,
|
||||
errorMessage: error.toString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class ImageError extends StatelessWidget {
|
||||
final String title;
|
||||
final String? errorMessage;
|
||||
|
||||
const ImageFormatNotSupported(this.title, {super.key});
|
||||
const ImageError(this.title, {this.errorMessage, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(5),
|
||||
color: theme.colorScheme.errorContainer,
|
||||
child: Row(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [const Icon(Icons.broken_image), Text(title)],
|
||||
children: [
|
||||
if (errorMessage != null)
|
||||
Tooltip(message: errorMessage, child: const Icon(Icons.broken_image))
|
||||
else
|
||||
const Icon(Icons.broken_image),
|
||||
|
||||
Text(
|
||||
title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
//import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/core/wide_screen_wrapper.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/screens/configure_plates_screen.dart';
|
||||
import 'package:wger/widgets/core/settings/exercise_cache.dart';
|
||||
|
||||
Reference in New Issue
Block a user