Compare commits

..

No commits in common. "5e2d5944fe612ce4764cf757f274f84da73ca700" and "be5cbb5988a5259cbc9162be0b338b82ea3fe9de" have entirely different histories.

15 changed files with 57 additions and 97 deletions

View File

@ -1,3 +0,0 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart

View File

@ -4,7 +4,6 @@ import 'package:calorimeter/storage/storage.dart';
import 'package:flutter/material.dart';
import 'package:calorimeter/food_entry/food_entry_bloc.dart';
import 'package:calorimeter/utils/row_with_spacers_widget.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class EnterFoodWidget extends StatefulWidget {
final Function(BuildContext context, FoodEntryState entry) onAdd;
@ -43,8 +42,8 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
return TextFormField(
controller: controller,
focusNode: focusNode,
decoration: InputDecoration(
label: Text(AppLocalizations.of(context)!.name),
decoration: const InputDecoration(
label: Text("Name"),
),
);
},
@ -71,11 +70,9 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
}),
TextField(
textAlign: TextAlign.end,
decoration: InputDecoration(
label: Align(
alignment: Alignment.centerRight,
child: Text(AppLocalizations.of(context)!.amount),
),
decoration: const InputDecoration(
label:
Align(alignment: Alignment.centerRight, child: Text("Menge")),
),
keyboardType: TextInputType.number,
controller: massController,
@ -83,10 +80,9 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
),
TextField(
textAlign: TextAlign.end,
decoration: InputDecoration(
decoration: const InputDecoration(
label: Align(
alignment: Alignment.centerRight,
child: Text(AppLocalizations.of(context)!.kcalper))),
alignment: Alignment.centerRight, child: Text("kcal pro"))),
keyboardType: TextInputType.number,
controller: kcalPerMassController,
onSubmitted: (value) => onSubmitAction(),
@ -111,8 +107,7 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
try {
massAsNumber = int.parse(massController.text.replaceAll(",", "."));
} catch (e) {
var snackbar = SnackBar(
content: Text(AppLocalizations.of(context)!.errAmountNotANumber));
var snackbar = const SnackBar(content: Text("Menge muss eine Zahl sein"));
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(snackbar);
return;
@ -122,8 +117,8 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
kcalPerMassAsNumber =
int.parse(kcalPerMassController.text.replaceAll(",", "."));
} catch (e) {
var snackbar = SnackBar(
content: Text(AppLocalizations.of(context)!.errKcalNotANumber));
var snackbar =
const SnackBar(content: Text("'kcal pro 100g' muss eine Zahl sein"));
ScaffoldMessenger.of(context).removeCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(snackbar);
return;

View File

@ -3,7 +3,6 @@
import 'package:flutter/material.dart';
import 'package:calorimeter/food_entry/food_entry_bloc.dart';
import 'package:calorimeter/utils/row_with_spacers_widget.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class FoodEntryWidget extends StatefulWidget {
final FoodEntryState entry;
@ -166,8 +165,8 @@ class _FoodEntryChangeDialogState extends State<FoodEntryChangeDialog> {
child: TextField(
onSubmitted: (val) => _onSubmitAction(),
controller: nameController,
decoration: InputDecoration(
label: Text(AppLocalizations.of(context)!.name),
decoration: const InputDecoration(
label: Text("Name"),
),
),
),
@ -178,8 +177,8 @@ class _FoodEntryChangeDialogState extends State<FoodEntryChangeDialog> {
child: TextField(
onSubmitted: (val) => _onSubmitAction(),
controller: massController,
decoration: InputDecoration(
label: Text(AppLocalizations.of(context)!.amount),
decoration: const InputDecoration(
label: Text("Menge"),
),
),
),
@ -190,8 +189,8 @@ class _FoodEntryChangeDialogState extends State<FoodEntryChangeDialog> {
child: TextField(
onSubmitted: (val) => _onSubmitAction(),
controller: kcalPer100Controller,
decoration: InputDecoration(
label: Text(AppLocalizations.of(context)!.kcalper),
decoration: const InputDecoration(
label: Text("kcal pro Menge"),
),
),
)

View File

@ -1,13 +0,0 @@
{
"ok": "OK",
"name": "Name",
"amount": "Menge in 100 g/ml",
"kcalper": "kcal pro Menge",
"kcalToday": "kcal heute",
"menu": "Menü",
"settings": "Einstellungen",
"yourSettings": "Deine persönlichen Einstellungen",
"dayLimit": "Kalorienlimit pro Tag",
"errAmountNotANumber": "Menge muss eine Zahl sein",
"errKcalNotANumber": "kcal muss eine Zahl sein"
}

View File

@ -1,13 +0,0 @@
{
"ok": "OK",
"name": "Name",
"amount": "Amount in 100 grams/ml",
"kcalper": "kcal per amount",
"kcalToday": "kcal today",
"menu": "Menu",
"settings": "Settings",
"yourSettings": "Your personal settings",
"dayLimit": "Calorie limit per day",
"errAmountNotANumber": "Amount must be a number",
"errKcalNotANumber": "kcal must be a number"
}

View File

@ -8,8 +8,8 @@ import 'package:calorimeter/utils/settings_bloc.dart';
import 'package:calorimeter/utils/theme_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
List<FoodEntryState> entriesForToday = [];
DateTime timeNow = DateTime.now();
@ -17,6 +17,8 @@ DateTime timeNow = DateTime.now();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
var storage = await FoodStorage.create();
await storage.buildFoodLookupDatabase();
@ -77,7 +79,6 @@ class MainApp extends StatelessWidget {
}
return MaterialApp.router(
//locale: Locale('de'),
routerConfig: GoRouter(
routes: [
GoRoute(
@ -90,8 +91,14 @@ class MainApp extends StatelessWidget {
),
],
),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('de'),
],
theme: ThemeData(
dividerTheme: const DividerThemeData(space: 2),
colorScheme: ColorScheme.fromSeed(

View File

@ -58,10 +58,8 @@ class PerDatePageViewController extends StatelessWidget {
child: Scaffold(
appBar: AppBar(
title: Builder(builder: (context) {
return Text(DateFormat.yMMMMd(
Localizations.localeOf(context).toString())
.format(
context.watch<PageViewStateProvider>().displayedDate));
return Text(DateFormat.yMMMMd('de').format(
context.watch<PageViewStateProvider>().displayedDate));
}),
actions: const [ThemeSwitcherButton()],
),

View File

@ -2,7 +2,6 @@
/* Copyright (C) 2024 Marco Groß <mgross@sw-gross.de> */
import 'package:calorimeter/utils/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class AppDrawer extends StatelessWidget {
const AppDrawer({
@ -20,17 +19,16 @@ class AppDrawer extends StatelessWidget {
color: Colors.redAccent,
),
child: ListTile(
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(AppLocalizations.of(context)!.menu),
),
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.of(context).pop();
},
),
title: const Text('Menü')),
),
ListTile(
title: Text(AppLocalizations.of(context)!.settings),
title: const Text('Einstellungen'),
trailing: const Icon(Icons.settings),
onTap: () {
Navigator.of(context).pop();

View File

@ -15,6 +15,7 @@ class CalendarFAB extends StatelessWidget {
return FloatingActionButton(
onPressed: () async {
var datePicked = await showDatePicker(
locale: const Locale('de'),
context: context,
initialDate: startFromDate,
currentDate: DateTimeHelper.now(),

View File

@ -5,7 +5,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:calorimeter/utils/app_drawer.dart';
import 'package:calorimeter/utils/settings_bloc.dart';
import 'package:settings_ui/settings_ui.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SettingsWidget extends StatefulWidget {
const SettingsWidget({super.key});
@ -24,24 +23,33 @@ class _SettingsWidgetState extends State<SettingsWidget> {
builder: (context, state) {
return SettingsList(sections: [
SettingsSection(
title: Text(AppLocalizations.of(context)!.yourSettings),
title: const Text('Deine persönlichen Einstellungen'),
tiles: [
SettingsTile.navigation(
leading: const Icon(Icons.food_bank),
title: Text(AppLocalizations.of(context)!.dayLimit),
title: const Text('Kalorienlimit pro Tag'),
value: Text(state.kcalLimit.toString()),
onPressed: (context) async {
await showDialog(
builder: (ctx) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.dayLimit),
content: TextField(
controller: kcalPerDayCtrl,
onSubmitted: (val) => submitDailyKcal()),
title: const Text("Kalorienlimit pro Tag"),
content: TextField(controller: kcalPerDayCtrl),
actions: [
TextButton(
onPressed: () => submitDailyKcal(),
child: Text(AppLocalizations.of(context)!.ok))
onPressed: () {
double setting;
try {
setting =
double.parse(kcalPerDayCtrl.text);
} catch (e) {
setting = 2000.0;
}
context.read<SettingsDataBloc>().add(
DailyKcalLimitUpdated(kcal: setting));
Navigator.of(context).pop();
},
child: const Text('Ok'))
],
);
},
@ -52,18 +60,7 @@ class _SettingsWidgetState extends State<SettingsWidget> {
]);
}),
drawer: const AppDrawer(),
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings)),
appBar: AppBar(title: const Text('Einstellungen')),
);
}
void submitDailyKcal() {
double setting;
try {
setting = double.parse(kcalPerDayCtrl.text);
} catch (e) {
setting = 2000.0;
}
context.read<SettingsDataBloc>().add(DailyKcalLimitUpdated(kcal: setting));
Navigator.of(context).pop();
}
}

View File

@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:calorimeter/food_entry/food_entry_bloc.dart';
import 'package:calorimeter/utils/settings_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SumWidget extends StatelessWidget {
final DateTime date;
@ -49,7 +48,7 @@ class SumWidget extends StatelessWidget {
return Align(
alignment: Alignment.centerLeft,
child: Text(
'${AppLocalizations.of(context)!.kcalToday}: ${sum.ceil().toString()}/${settingsState.kcalLimit.ceil()}',
'kcal heute: ${sum.ceil().toString()}/${settingsState.kcalLimit.ceil()}',
style: Theme.of(context)
.textTheme
.bodyLarge!

View File

@ -1,2 +0,0 @@
With Calorimeter you can track your daily calorie intake.
As simple as it gets.

View File

@ -1 +0,0 @@
Track your calories!

View File

@ -1 +0,0 @@
Calorimeter

View File

@ -30,7 +30,6 @@ dev_dependencies:
flutter:
uses-material-design: true
generate: true
flutter_launcher_icons:
android: "launcher_icon"