mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-30 01:41:05 +01:00
Merge branch 'master' into feature/offline-mode
# Conflicts: # lib/helpers/errors.dart # lib/main.dart # lib/widgets/nutrition/forms.dart # lib/widgets/routines/forms/slot_entry.dart
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
<locale android:name="fa"/>
|
||||
<locale android:name="fil"/>
|
||||
<locale android:name="fr"/>
|
||||
<locale android:name="gl"/>
|
||||
<locale android:name="he"/>
|
||||
<locale android:name="hi"/>
|
||||
<locale android:name="hr"/>
|
||||
@@ -29,6 +30,7 @@
|
||||
<locale android:name="ro"/>
|
||||
<locale android:name="ru"/>
|
||||
<locale android:name="sk"/>
|
||||
<locale android:name="sn"/>
|
||||
<locale android:name="ta"/>
|
||||
<locale android:name="th"/>
|
||||
<locale android:name="tr"/>
|
||||
|
||||
@@ -1,6 +1,38 @@
|
||||
wger (ˈvɛɡɐ) er gemenhetslig fri programvare som hjelper din helse.
|
||||
Fra treningsentusiaster til treningsentusiaster – få helsen din organisert med WGER, din treningsmanager!
|
||||
|
||||
- Planlegg treningsøkter og ernæring
|
||||
- Lagre øvelser og kommenter dem
|
||||
- Helsestudio-modus
|
||||
- Dagbok og utviklingssporing
|
||||
Har du allerede funnet din favoritt treningsapp og elsker du å lage dine egne treningsrutiner? Uansett hvilken type treningsgal du er – vi har alle noe til felles: Vi elsker å holde oversikt over helsedata <3
|
||||
|
||||
Så vi dømmer deg ikke for at du fortsatt styrer treningsreisen din med den lille treningsdagboken din, men velkommen til 2025!
|
||||
|
||||
Vi har utviklet en 100% gratis digital helse- og treningssporer-app for deg, trimmet ned til de mest relevante funksjonene for å gjøre livet ditt enklere. Kom i gang, fortsett å trene og feir fremgangen din!
|
||||
|
||||
wger er et Open Source-prosjekt og handler om:
|
||||
* Kroppen din
|
||||
* Treningene dine
|
||||
* Fremgangen din
|
||||
* Dataene dine
|
||||
|
||||
Kroppen din: Ikke noe behov for å google ingrediensene i favorittmatene dine – velg dine daglige måltider fra mer enn 78 000 produkter og se næringsverdiene. Legg til måltider i ernæringsplanen og hold oversikt over kostholdet ditt i kalenderen.
|
||||
|
||||
Treningene dine:
|
||||
Du vet hva som er best for kroppen din. Lag dine egne treningsøkter fra et voksende utvalg på 200 forskjellige øvelser. Bruk deretter Gym-modus for å guide deg gjennom treningen mens du logger vektene dine med ett trykk.
|
||||
|
||||
Fremgangen din:
|
||||
Mist aldri målet av syne. Spor vekten din og hold statistikken din.
|
||||
|
||||
Dataene dine:
|
||||
Wger er din personlige treningsdagbok – men du eier dataene dine. Bruk REST API-et for å få tilgang til dem og gjøre fantastiske ting med dem.
|
||||
|
||||
Vær oppmerksom på: Denne gratis appen er ikke basert på ekstern finansiering, og vi ber deg ikke om å donere penger. Den er et fellesskapsprosjekt som vokser konstant. Så vær forberedt på nye funksjoner når som helst!
|
||||
|
||||
#OpenSource – hva betyr det?
|
||||
|
||||
Open Source betyr at hele kildekoden for denne appen og serveren den kommuniserer med er gratis og tilgjengelig for alle:
|
||||
* Vil du kjøre wger på din egen server for deg selv eller det lokale treningssenteret ditt? Bare gjør det!
|
||||
* Savner du en funksjon og vil implementere den? Start nå!
|
||||
* Vil du sjekke at ingenting sendes noe sted? Det kan du!
|
||||
|
||||
Bli med i fellesskapet vårt og bli en del av treningsentusiaster og IT-nerder fra hele verden. Vi jobber kontinuerlig med å tilpasse og optimalisere appen etter våre behov. Vi elsker dine innspill, så hopp gjerne inn når som helst og bidra med ønsker og ideer!
|
||||
|
||||
-> finn kildekoden på https://github.com/wger-project
|
||||
-> still spørsmål eller si hei på vår Discord-server https://discord.gg/rPWFv6W
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<string>fa</string>
|
||||
<string>fil</string>
|
||||
<string>fr</string>
|
||||
<string>gl</string>
|
||||
<string>he</string>
|
||||
<string>hi</string>
|
||||
<string>hr</string>
|
||||
@@ -43,6 +44,7 @@
|
||||
<string>ro</string>
|
||||
<string>ru</string>
|
||||
<string>sk</string>
|
||||
<string>sn</string>
|
||||
<string>ta</string>
|
||||
<string>th</string>
|
||||
<string>tr</string>
|
||||
|
||||
@@ -129,6 +129,9 @@ const GITHUB_REPO_URL = '$GITHUB_PROJECT_URL/flutter';
|
||||
const GITHUB_ISSUES_URL = '$GITHUB_REPO_URL/issues/new/choose';
|
||||
const GITHUB_ISSUES_BUG_URL = '$GITHUB_REPO_URL/issues/new?template=1_bug.yml';
|
||||
const GITHUB_SPONSORS_URL = 'https://github.com/sponsors/wger-project';
|
||||
|
||||
/// Maximum length for a pre-filled GitHub issue URL
|
||||
const GITHUB_ISSUES_MAX_URL_LENGTH = 8000;
|
||||
const DISCORD_URL = 'https://discord.gg/rPWFv6W';
|
||||
const MASTODON_URL = 'https://fosstodon.org/@wger';
|
||||
const READTHEDOCS_URL = 'https://wger.readthedocs.io';
|
||||
|
||||
@@ -24,6 +24,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
@@ -36,6 +37,24 @@ import 'package:wger/providers/workout_logs_notifier.dart';
|
||||
import 'consts.dart';
|
||||
import 'logs.dart';
|
||||
|
||||
/// Whether an error dialog is currently on screen.
|
||||
///
|
||||
/// Errors can fire in quick succession; this guards against stacking several
|
||||
/// modal dialogs on top of each other.
|
||||
bool _errorDialogVisible = false;
|
||||
|
||||
/// How an error should be surfaced to the user.
|
||||
enum ErrorSeverity {
|
||||
/// Logged only; not worth interrupting the user (e.g. layout overflows).
|
||||
cosmetic,
|
||||
|
||||
/// A brief, non-blocking snackbar (e.g. transient connectivity problems).
|
||||
transient,
|
||||
|
||||
/// A blocking error dialog.
|
||||
fatal,
|
||||
}
|
||||
|
||||
void showHttpExceptionErrorDialog(WgerHttpException exception, {BuildContext? context}) {
|
||||
final logger = Logger('showHttpExceptionErrorDialog');
|
||||
|
||||
@@ -51,6 +70,12 @@ void showHttpExceptionErrorDialog(WgerHttpException exception, {BuildContext? co
|
||||
return;
|
||||
}
|
||||
|
||||
if (_errorDialogVisible) {
|
||||
logger.info('Suppressing error dialog, one is already visible: $exception');
|
||||
return;
|
||||
}
|
||||
_errorDialogVisible = true;
|
||||
|
||||
showDialog(
|
||||
context: dialogContext,
|
||||
builder: (ctx) => AlertDialog(
|
||||
@@ -76,7 +101,7 @@ void showHttpExceptionErrorDialog(WgerHttpException exception, {BuildContext? co
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
).whenComplete(() => _errorDialogVisible = false);
|
||||
}
|
||||
|
||||
void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext? context}) {
|
||||
@@ -85,7 +110,7 @@ void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext
|
||||
// of a widget's build method.
|
||||
final BuildContext? dialogContext = context ?? navigatorKey.currentContext;
|
||||
|
||||
final logger = Logger('showHttpExceptionErrorDialog');
|
||||
final logger = Logger('showGeneralErrorDialog');
|
||||
|
||||
if (dialogContext == null) {
|
||||
if (kDebugMode) {
|
||||
@@ -94,32 +119,24 @@ void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext
|
||||
return;
|
||||
}
|
||||
|
||||
if (_errorDialogVisible) {
|
||||
logger.info('Suppressing error dialog, one is already visible: $error');
|
||||
return;
|
||||
}
|
||||
_errorDialogVisible = true;
|
||||
|
||||
final i18n = AppLocalizations.of(dialogContext);
|
||||
|
||||
// If possible, determine the error title and message based on the error type.
|
||||
// If possible, determine the issue title and message based on the error type.
|
||||
// (Note that issue titles and error messages are not localized)
|
||||
bool allowReportIssue = true;
|
||||
String issueTitle = 'An error occurred';
|
||||
String issueErrorMessage = error.toString();
|
||||
String errorTitle = i18n.anErrorOccurred;
|
||||
String errorDescription = i18n.errorInfoDescription;
|
||||
var icon = Icons.error;
|
||||
|
||||
if (error is TimeoutException) {
|
||||
issueTitle = 'Network Timeout';
|
||||
issueErrorMessage =
|
||||
'The connection to the server timed out. Please check your '
|
||||
'internet connection and try again.';
|
||||
} else if (error is FlutterErrorDetails) {
|
||||
if (error is FlutterErrorDetails) {
|
||||
issueTitle = 'Application Error';
|
||||
issueErrorMessage = error.exceptionAsString();
|
||||
} else if (error is MissingRequiredKeysException) {
|
||||
issueTitle = 'Missing Required Key';
|
||||
} else if (error is SocketException) {
|
||||
allowReportIssue = false;
|
||||
icon = Icons.signal_wifi_connected_no_internet_4_outlined;
|
||||
errorTitle = i18n.errorCouldNotConnectToServer;
|
||||
errorDescription = i18n.errorCouldNotConnectToServerDetails;
|
||||
}
|
||||
|
||||
final String fullStackTrace = stackTrace?.toString() ?? 'No stack trace available.';
|
||||
@@ -134,16 +151,19 @@ void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext
|
||||
spacing: 8,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, color: Theme.of(context).colorScheme.error),
|
||||
Icon(Icons.error, color: Theme.of(context).colorScheme.error),
|
||||
Expanded(
|
||||
child: Text(errorTitle, style: TextStyle(color: Theme.of(context).colorScheme.error)),
|
||||
child: Text(
|
||||
i18n.anErrorOccurred,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: [
|
||||
Text(errorDescription),
|
||||
Text(i18n.errorInfoDescription),
|
||||
const SizedBox(height: 8),
|
||||
Text(i18n.errorInfoDescription2),
|
||||
const SizedBox(height: 10),
|
||||
@@ -198,42 +218,29 @@ void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (allowReportIssue)
|
||||
TextButton(
|
||||
child: const Text('Report issue'),
|
||||
onPressed: () async {
|
||||
final logText = applicationLogs.isEmpty
|
||||
? '-- No logs available --'
|
||||
: applicationLogs.join('\n');
|
||||
final description = Uri.encodeComponent(
|
||||
'## Description\n\n'
|
||||
'[Please describe what you were doing when the error occurred.]\n\n'
|
||||
'## Error details\n\n'
|
||||
'Error title: $issueTitle\n'
|
||||
'Error message: $issueErrorMessage\n'
|
||||
'Stack trace:\n'
|
||||
'```\n$stackTrace\n```\n\n'
|
||||
'App logs (last ${applicationLogs.length} entries):\n'
|
||||
'```\n$logText\n```',
|
||||
);
|
||||
final githubIssueUrl =
|
||||
'$GITHUB_ISSUES_BUG_URL'
|
||||
'&title=$issueTitle'
|
||||
'&description=$description';
|
||||
final Uri reportUri = Uri.parse(githubIssueUrl);
|
||||
TextButton(
|
||||
child: const Text('Report issue'),
|
||||
onPressed: () async {
|
||||
final githubIssueUrl = buildGithubIssueUrl(
|
||||
issueTitle: issueTitle,
|
||||
issueErrorMessage: issueErrorMessage,
|
||||
stackTrace: fullStackTrace,
|
||||
applicationLogs: applicationLogs,
|
||||
);
|
||||
final Uri reportUri = Uri.parse(githubIssueUrl);
|
||||
|
||||
try {
|
||||
await launchUrl(reportUri, mode: LaunchMode.externalApplication);
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
logger.warning('Error launching URL: $e');
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Error opening issue tracker: $e')));
|
||||
try {
|
||||
await launchUrl(reportUri, mode: LaunchMode.externalApplication);
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
logger.warning('Error launching URL: $e');
|
||||
}
|
||||
},
|
||||
),
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Error opening issue tracker: $e')));
|
||||
}
|
||||
},
|
||||
),
|
||||
FilledButton(
|
||||
child: Text(MaterialLocalizations.of(context).okButtonLabel),
|
||||
onPressed: () {
|
||||
@@ -243,7 +250,101 @@ void showGeneralErrorDialog(dynamic error, StackTrace? stackTrace, {BuildContext
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
).whenComplete(() => _errorDialogVisible = false);
|
||||
}
|
||||
|
||||
/// Classifies [error] to decide how it should be surfaced.
|
||||
ErrorSeverity classifyError(Object? error) {
|
||||
// Flutter reports layout overflows as a plain FlutterError without a
|
||||
// dedicated type, so matching the message is the only option.
|
||||
final isLayoutOverflow = error is FlutterError && error.toString().contains('overflowed');
|
||||
|
||||
if (error is NetworkImageLoadException || isLayoutOverflow) {
|
||||
return ErrorSeverity.cosmetic;
|
||||
}
|
||||
if (error is SocketException || error is http.ClientException || error is TimeoutException) {
|
||||
return ErrorSeverity.transient;
|
||||
}
|
||||
return ErrorSeverity.fatal;
|
||||
}
|
||||
|
||||
/// Routes [error] to the appropriate UI based on its [ErrorSeverity].
|
||||
///
|
||||
/// The caller is responsible for logging the error beforehand.
|
||||
void handleError(Object? error, StackTrace? stackTrace) {
|
||||
switch (classifyError(error)) {
|
||||
case ErrorSeverity.cosmetic:
|
||||
break;
|
||||
case ErrorSeverity.transient:
|
||||
showTransientErrorSnackbar();
|
||||
case ErrorSeverity.fatal:
|
||||
if (error is WgerHttpException) {
|
||||
showHttpExceptionErrorDialog(error);
|
||||
} else {
|
||||
showGeneralErrorDialog(error, stackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows a brief, non-blocking snackbar telling the user about a (hopefully)
|
||||
/// transient error such as network problems, etc.
|
||||
void showTransientErrorSnackbar() {
|
||||
final messenger = scaffoldMessengerKey.currentState;
|
||||
final context = navigatorKey.currentContext;
|
||||
|
||||
if (messenger == null || context == null) {
|
||||
if (kDebugMode) {
|
||||
Logger(
|
||||
'showNetworkErrorSnackbar',
|
||||
).warning('Could not show snackbar: no messenger or context available.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
messenger
|
||||
..clearSnackBars()
|
||||
..showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).errorCouldNotConnectToServer)),
|
||||
);
|
||||
}
|
||||
|
||||
/// Builds the URL that opens a pre-filled GitHub bug report.
|
||||
///
|
||||
/// The error details are passed to GitHub as query parameters and since
|
||||
/// GitHub rejects URLs longer than [GITHUB_ISSUES_MAX_URL_LENGTH], when
|
||||
/// the report would exceed that limit, the oldest log entries are pruned
|
||||
/// until the URL fits.
|
||||
String buildGithubIssueUrl({
|
||||
required String issueTitle,
|
||||
required String issueErrorMessage,
|
||||
required String stackTrace,
|
||||
required List<String> applicationLogs,
|
||||
}) {
|
||||
String composeUrl(List<String> logs) {
|
||||
final logText = logs.isEmpty ? '-- No logs available --' : logs.join('\n');
|
||||
final description =
|
||||
'## Description\n\n'
|
||||
'[Please describe what you were doing when the error occurred.]\n\n'
|
||||
'## Error details\n\n'
|
||||
'Error title: $issueTitle\n'
|
||||
'Error message: $issueErrorMessage\n'
|
||||
'Stack trace:\n```\n$stackTrace\n```\n\n'
|
||||
'App logs (last ${logs.length} entries):\n```\n$logText\n```';
|
||||
return '$GITHUB_ISSUES_BUG_URL'
|
||||
'&title=${Uri.encodeComponent(issueTitle)}'
|
||||
'&description=${Uri.encodeComponent(description)}';
|
||||
}
|
||||
|
||||
// The logs come newest-first, so the oldest entry is the last one. Drop it
|
||||
// and retry until the URL fits within the limit.
|
||||
var logs = applicationLogs;
|
||||
while (true) {
|
||||
final url = composeUrl(logs);
|
||||
if (url.length <= GITHUB_ISSUES_MAX_URL_LENGTH || logs.isEmpty) {
|
||||
return url;
|
||||
}
|
||||
logs = logs.sublist(0, logs.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// A widget to render HTML errors returned by the server
|
||||
|
||||
1801
lib/l10n/app_cs.arb
1801
lib/l10n/app_cs.arb
File diff suppressed because it is too large
Load Diff
@@ -969,11 +969,8 @@
|
||||
},
|
||||
"superset": "Superset",
|
||||
"isVegan": "Vegan",
|
||||
"@isVegan": {},
|
||||
"isVegetarian": "Vegetarisch",
|
||||
"@isVegetarian": {},
|
||||
"filter": "Filtern",
|
||||
"@filter": {},
|
||||
"searchLanguageCurrent": "Nur aktuelle Sprache ({lang})",
|
||||
"@searchLanguageCurrent": {
|
||||
"type": "text",
|
||||
@@ -993,5 +990,17 @@
|
||||
}
|
||||
},
|
||||
"searchLanguageAll": "Alle Sprachen",
|
||||
"@searchLanguageAll": {}
|
||||
"dashboardWidgets": "Dashboard Widgets",
|
||||
"slotEntryTypeWarmup": "Aufwärmtraining",
|
||||
"trophies": "Trophäen",
|
||||
"topSet": "Höchster Satz: {value}",
|
||||
"@topSet": {
|
||||
"description": "Value is a representation of the set, like '10 x 80kg'",
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,5 +994,8 @@
|
||||
"dashboardWidgets": "Widgets del panel",
|
||||
"trophies": "Trofeos",
|
||||
"personalRecords": "Registros personales",
|
||||
"noTrophies": "No tienes trofeos todavía"
|
||||
"noTrophies": "No tienes trofeos todavía",
|
||||
"slotEntryTypeWarmup": "Calentamiento",
|
||||
"preview": "Vista previa",
|
||||
"serverUpdateTitle": "Actualización de servidor requerida"
|
||||
}
|
||||
|
||||
1
lib/l10n/app_gl.arb
Normal file
1
lib/l10n/app_gl.arb
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -1126,5 +1126,64 @@
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"preview": "Pregledaj",
|
||||
"filterNutriscore": "Nutri-Score filtar",
|
||||
"@filterNutriscore": {
|
||||
"description": "Heading for the Nutri-Score slider in the ingredient search filter dialog"
|
||||
},
|
||||
"filterNutriscoreOff": "Isključeno",
|
||||
"@filterNutriscoreOff": {
|
||||
"description": "Label for the first slider stop, which disables the Nutri-Score filter"
|
||||
},
|
||||
"filterNutriscoreNoFilter": "Bez filtra",
|
||||
"@filterNutriscoreNoFilter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when it is at the Off position"
|
||||
},
|
||||
"filterNutriscoreOrBetter": "{grade} ili bolje",
|
||||
"@filterNutriscoreOrBetter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when a grade is selected (e.g. 'C or better')",
|
||||
"placeholders": {
|
||||
"grade": {
|
||||
"type": "String",
|
||||
"example": "C"
|
||||
}
|
||||
}
|
||||
},
|
||||
"serverConfigIssueTitle": "Problem s konfiguracijom servera",
|
||||
"@serverConfigIssueTitle": {
|
||||
"description": "Title of the dialog shown when server misconfiguration is detected"
|
||||
},
|
||||
"serverConfigIssueMessage": "Otkrivena je pogrešna konfiguracija servera, zaglavlja se ne prosljeđuju ispravno. Pogledaj dokumentaciju.",
|
||||
"@serverConfigIssueMessage": {
|
||||
"description": "Message explaining server misconfiguration and linking to documentation"
|
||||
},
|
||||
"understand": "Razumijem",
|
||||
"@understand": {
|
||||
"description": "Button label to acknowledge and dismiss the server configuration warning"
|
||||
},
|
||||
"viewDocumentation": "Prikaži dokumentaciju",
|
||||
"@viewDocumentation": {
|
||||
"description": "Button label to open the documentation about server configuration"
|
||||
},
|
||||
"slotEntryTypeWarmup": "Zagrijavanje",
|
||||
"useBasicMarkdown": "Za formatiranje teksta se može koristiti osnovni Markdown",
|
||||
"editorBold": "Podebljano",
|
||||
"@editorBold": {
|
||||
"description": "Label for bold formatting"
|
||||
},
|
||||
"editorItalic": "Kursiv",
|
||||
"editorList": "Popis",
|
||||
"exerciseSearchMode": "Modus pretrage",
|
||||
"@exerciseSearchMode": {
|
||||
"description": "Heading above the segmented control that lets the user pick between fuzzy and exact name matching"
|
||||
},
|
||||
"searchModeFuzzy": "Otprilike",
|
||||
"@searchModeFuzzy": {
|
||||
"description": "Label for the search mode that performs a fuzzy/substring search on exercise names"
|
||||
},
|
||||
"searchModeExact": "Točno",
|
||||
"@searchModeExact": {
|
||||
"description": "Label for the search mode that only matches exercises with this exact name"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -941,5 +941,8 @@
|
||||
"applicationLogs": "Registri dell'applicazione",
|
||||
"dayTypeCustom": "Personalizzato",
|
||||
"dayTypeAfap": "Più velocemente possibile",
|
||||
"dayTypeHiit": "Allenamento a intervalli ad alta intensità"
|
||||
"dayTypeHiit": "Allenamento a intervalli ad alta intensità",
|
||||
"workoutCompleted": "Allenamento Completato",
|
||||
"noTrophies": "Non ci sono trofei",
|
||||
"preview": "Anteprima"
|
||||
}
|
||||
|
||||
@@ -191,15 +191,15 @@
|
||||
"@passwordsDontMatch": {
|
||||
"description": "Error message when the user enters two different passwords during registration"
|
||||
},
|
||||
"invalidUrl": "Skriv inn en gyldig nettadresse",
|
||||
"invalidUrl": "Skriv inn en gyldig nettadresse (URL)",
|
||||
"@invalidUrl": {
|
||||
"description": "Error message when the user enters an invalid URL, e.g. in the login form"
|
||||
},
|
||||
"useCustomServer": "Bruk egendefinert tjener",
|
||||
"useCustomServer": "Bruk egendefinert server",
|
||||
"@useCustomServer": {
|
||||
"description": "Toggle button allowing users to switch between the default and a custom wger server"
|
||||
},
|
||||
"useDefaultServer": "Bruk forvalgt tjener",
|
||||
"useDefaultServer": "Bruk standardserver",
|
||||
"@useDefaultServer": {
|
||||
"description": "Toggle button allowing users to switch between the default and a custom wger server"
|
||||
},
|
||||
@@ -229,7 +229,7 @@
|
||||
"@value": {
|
||||
"description": "The value of a measurement entry"
|
||||
},
|
||||
"userProfile": "Din Profil",
|
||||
"userProfile": "Din profil",
|
||||
"usernameValidChars": "Et brukernavn kan bare inneholde bokstaver, sifre og tegnene @,+,.,-, og _",
|
||||
"@usernameValidChars": {
|
||||
"description": "Error message when the user tries to register a username with forbidden characters"
|
||||
|
||||
@@ -1040,5 +1040,64 @@
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"slotEntryTypeWarmup": "Mobilização geral",
|
||||
"preview": "Ensaio",
|
||||
"useBasicMarkdown": "Podes usar markdown básico para formatar o texto",
|
||||
"editorBold": "Negrito",
|
||||
"@editorBold": {
|
||||
"description": "Label for bold formatting"
|
||||
},
|
||||
"editorItalic": "Itálico",
|
||||
"editorList": "Lista",
|
||||
"filterNutriscore": "Filtro Nutri-score",
|
||||
"@filterNutriscore": {
|
||||
"description": "Heading for the Nutri-Score slider in the ingredient search filter dialog"
|
||||
},
|
||||
"filterNutriscoreOff": "Desligado",
|
||||
"@filterNutriscoreOff": {
|
||||
"description": "Label for the first slider stop, which disables the Nutri-Score filter"
|
||||
},
|
||||
"filterNutriscoreNoFilter": "Sem filtro",
|
||||
"@filterNutriscoreNoFilter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when it is at the Off position"
|
||||
},
|
||||
"filterNutriscoreOrBetter": "{grade} ou melhor",
|
||||
"@filterNutriscoreOrBetter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when a grade is selected (e.g. 'C or better')",
|
||||
"placeholders": {
|
||||
"grade": {
|
||||
"type": "String",
|
||||
"example": "C"
|
||||
}
|
||||
}
|
||||
},
|
||||
"viewDocumentation": "Ver documentação",
|
||||
"@viewDocumentation": {
|
||||
"description": "Button label to open the documentation about server configuration"
|
||||
},
|
||||
"exerciseSearchMode": "Modo de pesquisa",
|
||||
"@exerciseSearchMode": {
|
||||
"description": "Heading above the segmented control that lets the user pick between fuzzy and exact name matching"
|
||||
},
|
||||
"searchModeFuzzy": "Busca aproximada",
|
||||
"@searchModeFuzzy": {
|
||||
"description": "Label for the search mode that performs a fuzzy/substring search on exercise names"
|
||||
},
|
||||
"searchModeExact": "Busca exata",
|
||||
"@searchModeExact": {
|
||||
"description": "Label for the search mode that only matches exercises with this exact name"
|
||||
},
|
||||
"serverConfigIssueTitle": "Problema de configuração do servidor",
|
||||
"@serverConfigIssueTitle": {
|
||||
"description": "Title of the dialog shown when server misconfiguration is detected"
|
||||
},
|
||||
"serverConfigIssueMessage": "Configuração incorreta do servidor; os cabeçalhos não estão a ser transmitidos corretamente. Consulta a documentação.",
|
||||
"@serverConfigIssueMessage": {
|
||||
"description": "Message explaining server misconfiguration and linking to documentation"
|
||||
},
|
||||
"understand": "Entendo",
|
||||
"@understand": {
|
||||
"description": "Button label to acknowledge and dismiss the server configuration warning"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
"@pause": {
|
||||
"description": "Noun, not an imperative! Label used for the pause when using the gym mode"
|
||||
},
|
||||
"success": "Bem sucedido",
|
||||
"success": "Sucesso",
|
||||
"@success": {
|
||||
"description": "Message when an action completed successfully, usually used as a heading"
|
||||
},
|
||||
@@ -1126,5 +1126,72 @@
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"preview": "Pré-visualização",
|
||||
"slotEntryTypeWarmup": "Aquecimento",
|
||||
"useBasicMarkdown": "Você pode usar Markdown básico para formatar o texto",
|
||||
"editorBold": "Audacioso",
|
||||
"@editorBold": {
|
||||
"description": "Label for bold formatting"
|
||||
},
|
||||
"editorItalic": "Itálico",
|
||||
"editorList": "Lista",
|
||||
"filterNutriscore": "Filtro Nutri-Score",
|
||||
"@filterNutriscore": {
|
||||
"description": "Heading for the Nutri-Score slider in the ingredient search filter dialog"
|
||||
},
|
||||
"filterNutriscoreOff": "Desligado",
|
||||
"@filterNutriscoreOff": {
|
||||
"description": "Label for the first slider stop, which disables the Nutri-Score filter"
|
||||
},
|
||||
"filterNutriscoreNoFilter": "Sem filtro",
|
||||
"@filterNutriscoreNoFilter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when it is at the Off position"
|
||||
},
|
||||
"filterNutriscoreOrBetter": "{grade} ou melhor",
|
||||
"@filterNutriscoreOrBetter": {
|
||||
"description": "Helper text shown under the Nutri-Score slider when a grade is selected (e.g. 'C or better')",
|
||||
"placeholders": {
|
||||
"grade": {
|
||||
"type": "String",
|
||||
"example": "C"
|
||||
}
|
||||
}
|
||||
},
|
||||
"exerciseSearchMode": "Modo de pesquisa",
|
||||
"@exerciseSearchMode": {
|
||||
"description": "Heading above the segmented control that lets the user pick between fuzzy and exact name matching"
|
||||
},
|
||||
"searchModeFuzzy": "Busca aproximada",
|
||||
"@searchModeFuzzy": {
|
||||
"description": "Label for the search mode that performs a fuzzy/substring search on exercise names"
|
||||
},
|
||||
"searchModeExact": "Busca exata",
|
||||
"@searchModeExact": {
|
||||
"description": "Label for the search mode that only matches exercises with this exact name"
|
||||
},
|
||||
"serverConfigIssueTitle": "Problema de configuração do servidor",
|
||||
"@serverConfigIssueTitle": {
|
||||
"description": "Title of the dialog shown when server misconfiguration is detected"
|
||||
},
|
||||
"serverConfigIssueMessage": "Foi detectada uma configuração incorreta do servidor; os cabeçalhos não estão sendo transmitidos corretamente. Consulte a documentação.",
|
||||
"@serverConfigIssueMessage": {
|
||||
"description": "Message explaining server misconfiguration and linking to documentation"
|
||||
},
|
||||
"understand": "Eu entendo",
|
||||
"@understand": {
|
||||
"description": "Button label to acknowledge and dismiss the server configuration warning"
|
||||
},
|
||||
"viewDocumentation": "Ver documentação",
|
||||
"@viewDocumentation": {
|
||||
"description": "Button label to open the documentation about server configuration"
|
||||
},
|
||||
"appLanguage": "Idioma do aplicativo",
|
||||
"@appLanguage": {
|
||||
"description": "Label for the in-app language selector in settings"
|
||||
},
|
||||
"appLanguageSystem": "Padrão do sistema",
|
||||
"@appLanguageSystem": {
|
||||
"description": "Dropdown entry that follows the device system language"
|
||||
}
|
||||
}
|
||||
|
||||
15
lib/l10n/app_sn.arb
Normal file
15
lib/l10n/app_sn.arb
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"userProfile": "Profile Yako",
|
||||
"login": "Pinda muApp",
|
||||
"@login": {
|
||||
"description": "Text for login button"
|
||||
},
|
||||
"logout": "Buda muApp",
|
||||
"@logout": {
|
||||
"description": "Text for logout button"
|
||||
},
|
||||
"register": "Kuzvinyoresa",
|
||||
"@register": {
|
||||
"description": "Text for registration button"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ const Map<String, String> languageNativeNames = {
|
||||
'fa': 'فارسی',
|
||||
'fil': 'Filipino',
|
||||
'fr': 'Français',
|
||||
'gl': 'Galego',
|
||||
'he': 'עברית',
|
||||
'hi': 'हिन्दी',
|
||||
'hr': 'Hrvatski',
|
||||
@@ -47,6 +48,7 @@ const Map<String, String> languageNativeNames = {
|
||||
'ro': 'Română',
|
||||
'ru': 'Русский',
|
||||
'sk': 'Slovenčina',
|
||||
'sn': 'chiShona',
|
||||
'ta': 'தமிழ்',
|
||||
'th': 'ไทย',
|
||||
'tr': 'Türkçe',
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:wger/core/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/errors.dart';
|
||||
import 'package:wger/helpers/locale.dart';
|
||||
import 'package:wger/helpers/shared_preferences.dart';
|
||||
@@ -87,6 +86,7 @@ void _setupLogging() {
|
||||
}
|
||||
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
void main() async {
|
||||
// Needs to be called before runApp
|
||||
@@ -99,26 +99,14 @@ void main() async {
|
||||
|
||||
// SharedPreferences to SharedPreferencesAsync migration function
|
||||
await PreferenceHelper.instance.migrationSupportFunctionForSharedPreferences();
|
||||
|
||||
// Catch errors from Flutter itself (widget build, layout, paint, etc.)
|
||||
//
|
||||
// NOTE: it seems this sometimes makes problems and even freezes the flutter
|
||||
// process when widgets overflow, so it is disabled in dev mode.
|
||||
if (!kDebugMode) {
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
final stack = details.stack ?? StackTrace.empty;
|
||||
logger.severe('Error caught by FlutterError.onError: ${details.exception}');
|
||||
|
||||
FlutterError.dumpErrorToConsole(details);
|
||||
|
||||
// Don't show the full error dialog for network image loading errors.
|
||||
if (details.exception is NetworkImageLoadException) {
|
||||
return;
|
||||
}
|
||||
|
||||
showGeneralErrorDialog(details.exception, stack);
|
||||
// throw details.exception;
|
||||
};
|
||||
}
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
final stack = details.stack ?? StackTrace.empty;
|
||||
logger.severe('Error caught by FlutterError.onError: ${details.exception}');
|
||||
FlutterError.dumpErrorToConsole(details);
|
||||
handleError(details.exception, stack);
|
||||
};
|
||||
|
||||
// Catch errors that happen outside of the Flutter framework (e.g., in async operations)
|
||||
PlatformDispatcher.instance.onError = (error, stack) {
|
||||
@@ -133,11 +121,7 @@ void main() async {
|
||||
logger.severe('Error caught by PlatformDispatcher.instance.onError: $error');
|
||||
logger.severe('Stack trace: $stack');
|
||||
|
||||
if (error is WgerHttpException) {
|
||||
showHttpExceptionErrorDialog(error);
|
||||
} else {
|
||||
showGeneralErrorDialog(error, stack);
|
||||
}
|
||||
handleError(error, stack);
|
||||
|
||||
// Return true to indicate that the error has been handled.
|
||||
return true;
|
||||
@@ -197,6 +181,7 @@ class MainApp extends ConsumerWidget {
|
||||
return MaterialApp(
|
||||
title: 'wger',
|
||||
navigatorKey: navigatorKey,
|
||||
scaffoldMessengerKey: scaffoldMessengerKey,
|
||||
theme: wgerLightTheme,
|
||||
darkTheme: wgerDarkTheme,
|
||||
highContrastTheme: wgerLightThemeHc,
|
||||
|
||||
@@ -280,7 +280,7 @@ class IngredientFormState extends ConsumerState<IngredientForm> {
|
||||
keyboardType: textInputTypeDecimal,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
final v = double.tryParse(value);
|
||||
final v = numberFormat.tryParse(value);
|
||||
if (v != null) {
|
||||
_mealItem.amount = v;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ class IngredientFormState extends ConsumerState<IngredientForm> {
|
||||
if (text.isEmpty) {
|
||||
return i18n.enterValue;
|
||||
}
|
||||
final parsed = double.tryParse(text);
|
||||
final parsed = numberFormat.tryParse(text);
|
||||
if (parsed == null) {
|
||||
return i18n.enterValidNumber;
|
||||
}
|
||||
|
||||
@@ -69,12 +69,23 @@ class _SlotEntryFormState extends ConsumerState<SlotEntryForm> {
|
||||
|
||||
var _edit = false;
|
||||
|
||||
bool _controllersInitialized = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.entry.nrOfSetsConfigs.isNotEmpty) {
|
||||
setsSliderValue = widget.entry.nrOfSetsConfigs.first.value.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (_controllersInitialized) {
|
||||
return;
|
||||
}
|
||||
_controllersInitialized = true;
|
||||
|
||||
if (widget.entry.weightConfigs.isNotEmpty) {
|
||||
_weight = widget.entry.weightConfigs.first.value;
|
||||
@@ -97,7 +108,8 @@ class _SlotEntryFormState extends ConsumerState<SlotEntryForm> {
|
||||
}
|
||||
|
||||
if (widget.entry.rirConfigs.isNotEmpty) {
|
||||
rirController.text = widget.entry.rirConfigs.first.value.round().toString();
|
||||
// RiR uses 0.5 steps, so the fractional part must be kept
|
||||
rirController.text = widget.entry.rirConfigs.first.value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +353,8 @@ class _SlotEntryFormState extends ConsumerState<SlotEntryForm> {
|
||||
),
|
||||
provider.handleConfig(
|
||||
widget.entry,
|
||||
numberFormat.tryParse(rirController.text),
|
||||
// RiR is slider-driven and held as an invariant string
|
||||
num.tryParse(rirController.text),
|
||||
ConfigType.rir,
|
||||
),
|
||||
]);
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:wger/core/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/errors.dart';
|
||||
|
||||
void main() {
|
||||
@@ -120,4 +127,95 @@ void main() {
|
||||
expect(error2.errorMessages[0], 'Password does not match');
|
||||
});
|
||||
});
|
||||
|
||||
group('buildGithubIssueUrl', () {
|
||||
test('Encodes the title and pre-fills the description', () {
|
||||
final url = buildGithubIssueUrl(
|
||||
issueTitle: 'An error occurred',
|
||||
issueErrorMessage: 'Something broke',
|
||||
stackTrace: '#0 main (file.dart:1)',
|
||||
applicationLogs: ['log line 1', 'log line 2'],
|
||||
);
|
||||
|
||||
expect(url, startsWith(GITHUB_ISSUES_BUG_URL));
|
||||
expect(url, contains('&title=An%20error%20occurred'));
|
||||
expect(url.length, lessThanOrEqualTo(GITHUB_ISSUES_MAX_URL_LENGTH));
|
||||
|
||||
final description = Uri.parse(url).queryParameters['description']!;
|
||||
expect(description, contains('Error message: Something broke'));
|
||||
expect(description, contains('#0 main (file.dart:1)'));
|
||||
expect(description, contains('log line 1'));
|
||||
});
|
||||
|
||||
test('Drops the oldest log entries, keeps the newest', () {
|
||||
// Logs come newest-first, so index 0 is the most recent entry.
|
||||
final logs = List.generate(3000, (i) => 'log entry $i');
|
||||
|
||||
final url = buildGithubIssueUrl(
|
||||
issueTitle: 'Application Error',
|
||||
issueErrorMessage: 'boom',
|
||||
stackTrace: 'short trace',
|
||||
applicationLogs: logs,
|
||||
);
|
||||
|
||||
expect(url.length, lessThanOrEqualTo(GITHUB_ISSUES_MAX_URL_LENGTH));
|
||||
final description = Uri.parse(url).queryParameters['description']!;
|
||||
expect(description, contains('log entry 0\n')); // newest kept
|
||||
expect(description, isNot(contains('log entry 2999'))); // oldest dropped
|
||||
});
|
||||
|
||||
test('Keeps the full stack trace and drops logs instead', () {
|
||||
final longTrace = List.generate(
|
||||
80,
|
||||
(i) => '#$i SomeClass.someMethod (package:wger/some/file.dart:$i:11)',
|
||||
).join('\n');
|
||||
|
||||
final url = buildGithubIssueUrl(
|
||||
issueTitle: 'Application Error',
|
||||
issueErrorMessage: 'boom',
|
||||
stackTrace: longTrace,
|
||||
applicationLogs: List.generate(3000, (i) => 'log entry number $i'),
|
||||
);
|
||||
|
||||
expect(url.length, lessThanOrEqualTo(GITHUB_ISSUES_MAX_URL_LENGTH));
|
||||
final description = Uri.parse(url).queryParameters['description']!;
|
||||
// The stack trace is never trimmed: first and last frame survive.
|
||||
expect(description, contains('#0 SomeClass.someMethod'));
|
||||
expect(description, contains('#79 SomeClass.someMethod'));
|
||||
});
|
||||
});
|
||||
|
||||
group('classifyError', () {
|
||||
test('Connectivity errors are transient', () {
|
||||
expect(
|
||||
classifyError(const SocketException('no route to host')),
|
||||
ErrorSeverity.transient,
|
||||
);
|
||||
expect(
|
||||
classifyError(http.ClientException('connection refused')),
|
||||
ErrorSeverity.transient,
|
||||
);
|
||||
expect(classifyError(TimeoutException('request timed out')), ErrorSeverity.transient);
|
||||
});
|
||||
|
||||
test('Network image and layout overflow errors are cosmetic', () {
|
||||
expect(
|
||||
classifyError(
|
||||
NetworkImageLoadException(statusCode: 404, uri: Uri.parse('https://x/y.png')),
|
||||
),
|
||||
ErrorSeverity.cosmetic,
|
||||
);
|
||||
expect(
|
||||
classifyError(FlutterError('A RenderFlex overflowed by 99 pixels on the right.')),
|
||||
ErrorSeverity.cosmetic,
|
||||
);
|
||||
});
|
||||
|
||||
test('Other errors are fatal', () {
|
||||
expect(classifyError(WgerHttpException.fromMap({'detail': 'invalid'})), ErrorSeverity.fatal);
|
||||
expect(classifyError(Exception('boom')), ErrorSeverity.fatal);
|
||||
expect(classifyError(StateError('bad state')), ErrorSeverity.fatal);
|
||||
expect(classifyError(null), ErrorSeverity.fatal);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ void main() {
|
||||
when(mockRepo.watchAllLogsHydrated()).thenAnswer((_) => Stream.value(const []));
|
||||
});
|
||||
|
||||
Widget createHomeScreen(NutritionalPlan plan, {locale = 'en'}) {
|
||||
Widget createNutritionalPlanScreen(NutritionalPlan plan, {locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ProviderScope(
|
||||
@@ -80,7 +80,7 @@ void main() {
|
||||
}
|
||||
|
||||
testWidgets('Test the widgets on the nutritional plan form', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(plan1));
|
||||
await tester.pumpWidget(createNutritionalPlanScreen(plan1));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(TextFormField), findsNWidgets(3));
|
||||
@@ -89,7 +89,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Test editing an existing nutritional plan', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(plan1));
|
||||
await tester.pumpWidget(createNutritionalPlanScreen(plan1));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('test plan 1'), findsOneWidget, reason: 'Description is filled in');
|
||||
@@ -104,8 +104,43 @@ void main() {
|
||||
verifyNever(mockRepo.addPlanLocalDrift(any));
|
||||
});
|
||||
|
||||
testWidgets('Goal macros survive a no-op save in a comma-decimal locale', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final planWithGoals = NutritionalPlan(
|
||||
id: 'cc000000-0000-4000-8000-000000000002',
|
||||
creationDate: DateTime(2021, 1, 1),
|
||||
startDate: DateTime(2021, 1, 1),
|
||||
description: 'plan with goals',
|
||||
goalEnergy: 2000.0,
|
||||
goalProtein: 150.0,
|
||||
goalCarbohydrates: 250.0,
|
||||
goalFat: 70.0,
|
||||
);
|
||||
|
||||
tester.view.physicalSize = const Size(800, 2000);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
await tester.pumpWidget(createNutritionalPlanScreen(planWithGoals, locale: 'de'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The field shows the locale-formatted value, not the invariant "2000.0"
|
||||
expect(find.text('2.000'), findsOneWidget);
|
||||
|
||||
// Save without touching anything
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final saved = verify(mockRepo.editLocalDrift(captureAny)).captured.single as NutritionalPlan;
|
||||
expect(saved.goalEnergy, 2000.0);
|
||||
expect(saved.goalProtein, 150.0);
|
||||
expect(saved.goalCarbohydrates, 250.0);
|
||||
expect(saved.goalFat, 70.0);
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new nutritional plan', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(plan2));
|
||||
await tester.pumpWidget(createNutritionalPlanScreen(plan2));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/workouts/base_config.dart';
|
||||
import 'package:wger/models/workouts/slot_entry.dart';
|
||||
import 'package:wger/providers/routines_notifier.dart';
|
||||
import 'package:wger/providers/routines_repository.dart';
|
||||
@@ -49,7 +50,7 @@ void main() {
|
||||
).thenAnswer((_) => Future.value(getTestRoutine()));
|
||||
});
|
||||
|
||||
Widget renderWidget({simpleMode = true, locale = 'en'}) {
|
||||
Widget renderWidget({simpleMode = true, locale = 'en', SlotEntry? entry}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ProviderScope(
|
||||
@@ -68,7 +69,7 @@ void main() {
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
home: Scaffold(body: SlotEntryForm(slotEntry, 1, simpleMode: simpleMode)),
|
||||
home: Scaffold(body: SlotEntryForm(entry ?? slotEntry, 1, simpleMode: simpleMode)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -166,4 +167,47 @@ void main() {
|
||||
expect(capturedArgs[(6 * 3) + 1], 100);
|
||||
expect(capturedArgs[(6 * 3) + 2], ConfigType.maxRest);
|
||||
});
|
||||
|
||||
testWidgets('Fractional weight survives a no-op save in a comma-decimal locale', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final entry = getTestRoutine().days[0].slots[0].entries[0];
|
||||
entry.weightConfigs.first.value = 2.5;
|
||||
|
||||
await tester.pumpWidget(renderWidget(simpleMode: false, locale: 'de', entry: entry));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The field shows the locale-formatted value, not the invariant "2.5"
|
||||
expect(find.text('2,5'), findsOneWidget);
|
||||
|
||||
// Save without touching anything
|
||||
await tester.tap(find.byKey(const ValueKey(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final capturedArgs = verify(
|
||||
mockRoutinesRepository.handleConfigServer(captureAny, captureAny, captureAny),
|
||||
).captured;
|
||||
|
||||
expect(capturedArgs[(1 * 3) + 2], ConfigType.weight);
|
||||
expect(capturedArgs[(1 * 3) + 1], 2.5);
|
||||
});
|
||||
|
||||
testWidgets('Fractional RiR survives a no-op save', (WidgetTester tester) async {
|
||||
final entry = getTestRoutine().days[0].slots[0].entries[0];
|
||||
entry.rirConfigs = [BaseConfig.firstIteration(2.5, 1)];
|
||||
|
||||
await tester.pumpWidget(renderWidget(simpleMode: false, entry: entry));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Save without touching anything
|
||||
await tester.tap(find.byKey(const ValueKey(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final capturedArgs = verify(
|
||||
mockRoutinesRepository.handleConfigServer(captureAny, captureAny, captureAny),
|
||||
).captured;
|
||||
|
||||
expect(capturedArgs[(7 * 3) + 2], ConfigType.rir);
|
||||
expect(capturedArgs[(7 * 3) + 1], 2.5);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user