Merge branch 'master' into feature/trophies

# Conflicts:
#	lib/main.dart
#	lib/screens/dashboard.dart
This commit is contained in:
Roland Geider
2026-01-17 13:50:18 +01:00
18 changed files with 1047 additions and 124 deletions

View File

@@ -1,6 +1,6 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) 2020, 2021 wger Team
* Copyright (c) 2026 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
@@ -26,6 +26,7 @@ import 'package:wger/providers/nutrition.dart';
import 'package:wger/providers/routines.dart';
import 'package:wger/providers/user.dart';
import 'package:wger/screens/form_screen.dart';
import 'package:wger/screens/settings_dashboard_widgets_screen.dart';
import 'package:wger/widgets/core/about.dart';
import 'package:wger/widgets/core/settings.dart';
import 'package:wger/widgets/user/forms.dart';
@@ -40,71 +41,19 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
return AppBar(
title: Text(_title),
actions: [
IconButton(
icon: const Icon(Icons.widgets_outlined),
onPressed: () {
Navigator.of(context).pushNamed(ConfigureDashboardWidgetsScreen.routeName);
},
),
IconButton(
icon: const Icon(Icons.settings),
onPressed: () async {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context).optionsLabel),
actions: [
TextButton(
child: Text(
MaterialLocalizations.of(context).closeButtonLabel,
),
onPressed: () => Navigator.of(context).pop(),
),
],
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
//dense: true,
leading: const Icon(Icons.person),
title: Text(AppLocalizations.of(context).userProfile),
onTap: () => Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).userProfile,
UserProfileForm(
context.read<UserProvider>().profile!,
),
),
),
),
ListTile(
leading: const Icon(Icons.settings),
onTap: () => Navigator.of(context).pushNamed(SettingsPage.routeName),
title: Text(AppLocalizations.of(context).settingsTitle),
),
ListTile(
leading: const Icon(Icons.info),
onTap: () => Navigator.of(context).pushNamed(AboutPage.routeName),
title: Text(AppLocalizations.of(context).aboutPageTitle),
),
const Divider(),
ListTile(
//dense: true,
leading: const Icon(Icons.exit_to_app),
title: Text(AppLocalizations.of(context).logout),
onTap: () {
context.read<AuthProvider>().logout();
context.read<RoutinesProvider>().clear();
context.read<NutritionPlansProvider>().clear();
context.read<BodyWeightProvider>().clear();
context.read<GalleryProvider>().clear();
context.read<UserProvider>().clear();
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/');
},
),
],
),
);
return const MainSettingsDialog();
},
);
},
@@ -117,6 +66,73 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
class MainSettingsDialog extends StatelessWidget {
const MainSettingsDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context).optionsLabel),
actions: [
TextButton(
child: Text(
MaterialLocalizations.of(context).closeButtonLabel,
),
onPressed: () => Navigator.of(context).pop(),
),
],
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
//dense: true,
leading: const Icon(Icons.person),
title: Text(AppLocalizations.of(context).userProfile),
onTap: () => Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).userProfile,
UserProfileForm(
context.read<UserProvider>().profile!,
),
),
),
),
ListTile(
leading: const Icon(Icons.settings),
onTap: () => Navigator.of(context).pushNamed(SettingsPage.routeName),
title: Text(AppLocalizations.of(context).settingsTitle),
),
ListTile(
leading: const Icon(Icons.info),
onTap: () => Navigator.of(context).pushNamed(AboutPage.routeName),
title: Text(AppLocalizations.of(context).aboutPageTitle),
),
const Divider(),
ListTile(
//dense: true,
leading: const Icon(Icons.exit_to_app),
title: Text(AppLocalizations.of(context).logout),
onTap: () {
context.read<AuthProvider>().logout();
context.read<RoutinesProvider>().clear();
context.read<NutritionPlansProvider>().clear();
context.read<BodyWeightProvider>().clear();
context.read<GalleryProvider>().clear();
context.read<UserProvider>().clear();
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/');
},
),
],
),
);
}
}
/// App bar that only displays a title
class EmptyAppBar extends StatelessWidget implements PreferredSizeWidget {
final String _title;

View File

@@ -1,13 +1,13 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) wger Team
* Copyright (c) 2026 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,
* This program 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.
@@ -16,14 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//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';
import 'package:wger/widgets/core/settings/ingredient_cache.dart';
import 'package:wger/widgets/core/settings/theme.dart';
import 'package:wger/screens/settings_plates_screen.dart';
import './settings/exercise_cache.dart';
import './settings/ingredient_cache.dart';
import './settings/theme.dart';
class SettingsPage extends StatelessWidget {
static String routeName = '/SettingsPage';
@@ -36,28 +35,23 @@ class SettingsPage extends StatelessWidget {
return Scaffold(
appBar: AppBar(title: Text(i18n.settingsTitle)),
body: WidescreenWrapper(
child: ListView(
children: [
ListTile(
title: Text(
i18n.settingsCacheTitle,
style: Theme.of(context).textTheme.headlineSmall,
),
),
const SettingsExerciseCache(),
const SettingsIngredientCache(),
ListTile(title: Text(i18n.others, style: Theme.of(context).textTheme.headlineSmall)),
const SettingsTheme(),
ListTile(
title: Text(i18n.selectAvailablePlates),
onTap: () {
Navigator.of(context).pushNamed(ConfigurePlatesScreen.routeName);
},
trailing: const Icon(Icons.chevron_right),
),
],
),
body: ListView(
children: [
ListTile(
title: Text(i18n.settingsCacheTitle, style: Theme.of(context).textTheme.headlineSmall),
),
const SettingsExerciseCache(),
const SettingsIngredientCache(),
ListTile(title: Text(i18n.others, style: Theme.of(context).textTheme.headlineSmall)),
const SettingsTheme(),
ListTile(
title: Text(i18n.selectAvailablePlates),
onTap: () {
Navigator.of(context).pushNamed(ConfigurePlatesScreen.routeName);
},
trailing: const Icon(Icons.chevron_right),
),
],
),
);
}

View File

@@ -0,0 +1,78 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2026 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.
*
* This program 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:provider/provider.dart';
import 'package:wger/l10n/generated/app_localizations.dart';
import 'package:wger/providers/user.dart';
class SettingsDashboardVisibility extends StatelessWidget {
const SettingsDashboardVisibility({super.key});
@override
Widget build(BuildContext context) {
final i18n = AppLocalizations.of(context);
String getTitle(DashboardWidget w) {
switch (w) {
case DashboardWidget.routines:
return i18n.routines;
case DashboardWidget.weight:
return i18n.weight;
case DashboardWidget.measurements:
return i18n.measurements;
case DashboardWidget.calendar:
return i18n.calendar;
case DashboardWidget.nutrition:
return i18n.nutritionalPlans;
}
}
return Consumer<UserProvider>(
builder: (context, user, _) {
return ReorderableListView(
physics: const NeverScrollableScrollPhysics(),
buildDefaultDragHandles: false,
onReorder: user.setDashboardOrder,
children: user.dashboardOrder.asMap().entries.map((entry) {
final index = entry.key;
final w = entry.value;
return ListTile(
key: ValueKey(w),
title: Text(getTitle(w)),
leading: IconButton(
icon: user.isDashboardWidgetVisible(w)
? const Icon(Icons.visibility)
: const Icon(Icons.visibility_off, color: Colors.grey),
onPressed: () => user.setDashboardWidgetVisible(
w,
!user.isDashboardWidgetVisible(w),
),
),
trailing: ReorderableDragStartListener(
index: index,
child: const Icon(Icons.drag_handle),
),
);
}).toList(),
);
},
);
}
}

View File

@@ -31,7 +31,7 @@ import 'package:wger/providers/gym_log_state.dart';
import 'package:wger/providers/gym_state.dart';
import 'package:wger/providers/plate_weights.dart';
import 'package:wger/providers/routines.dart';
import 'package:wger/screens/configure_plates_screen.dart';
import 'package:wger/screens/settings_plates_screen.dart';
import 'package:wger/widgets/core/core.dart';
import 'package:wger/widgets/core/progress_indicator.dart';
import 'package:wger/widgets/routines/forms/reps_unit.dart';