Files
flutter/lib/widgets/core/settings.dart
Roland Geider eff176f035 Merge branch 'master' into feature/flexible-routines
# Conflicts:
#	lib/main.dart
#	lib/models/exercises/exercise.dart
#	lib/models/exercises/exercise_api.freezed.dart
#	lib/models/workouts/day.g.dart
#	lib/models/workouts/session.g.dart
#	lib/models/workouts/workout_plan.g.dart
#	lib/providers/exercises.dart
#	lib/widgets/core/settings.dart
#	pubspec.lock
#	test/auth/auth_screen_test.mocks.dart
#	test/core/settings_test.mocks.dart
#	test/exercises/contribute_exercise_test.mocks.dart
#	test/gallery/gallery_form_test.mocks.dart
#	test/gallery/gallery_screen_test.mocks.dart
#	test/measurements/measurement_categories_screen_test.mocks.dart
#	test/measurements/measurement_provider_test.mocks.dart
#	test/nutrition/nutritional_meal_form_test.mocks.dart
#	test/nutrition/nutritional_plan_form_test.mocks.dart
#	test/nutrition/nutritional_plan_screen_test.mocks.dart
#	test/nutrition/nutritional_plans_screen_test.mocks.dart
#	test/other/base_provider_test.mocks.dart
#	test/user/provider_test.mocks.dart
#	test/weight/weight_provider_test.mocks.dart
#	test/weight/weight_screen_test.mocks.dart
#	test/workout/gym_mode_screen_test.mocks.dart
#	test/workout/repetition_unit_form_widget_test.mocks.dart
#	test/workout/routine_screen_test.mocks.dart
#	test/workout/routines_provider_test.mocks.dart
#	test/workout/routines_screen_test.mocks.dart
#	test/workout/weight_unit_form_widget_test.mocks.dart
#	test/workout/workout_day_form_test.mocks.dart
#	test/workout/workout_form_test.mocks.dart
#	test/workout/workout_set_form_test.mocks.dart
2025-01-24 15:05:28 +01:00

119 lines
4.2 KiB
Dart

/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) 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:drift/drift.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:wger/providers/exercises.dart';
import 'package:wger/providers/nutrition.dart';
import 'package:wger/providers/user.dart';
class SettingsPage extends StatelessWidget {
static String routeName = '/SettingsPage';
const SettingsPage({super.key});
@override
Widget build(BuildContext context) {
final i18n = AppLocalizations.of(context);
final exerciseProvider = Provider.of<ExercisesProvider>(context, listen: false);
final nutritionProvider = Provider.of<NutritionPlansProvider>(context, listen: false);
final userProvider = Provider.of<UserProvider>(context);
final i18n = AppLocalizations.of(context);
return Scaffold(
appBar: AppBar(title: Text(i18n.settingsTitle)),
body: ListView(
children: [
ListTile(
title: Text(
i18n.settingsCacheTitle,
style: Theme.of(context).textTheme.headlineSmall,
)),
ListTile(
title: Text(i18n.settingsExerciseCacheDescription),
trailing: IconButton(
key: const ValueKey('cacheIconExercises'),
icon: const Icon(Icons.delete),
onPressed: () async {
await exerciseProvider.clearAllCachesAndPrefs();
if (context.mounted) {
final snackBar = SnackBar(
content: Text(i18n.settingsCacheDeletedSnackbar),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
),
),
ListTile(
title: Text(i18n.settingsIngredientCacheDescription),
trailing: IconButton(
key: const ValueKey('cacheIconIngredients'),
icon: const Icon(Icons.delete),
onPressed: () async {
await nutritionProvider.clearIngredientCache();
if (context.mounted) {
final snackBar = SnackBar(
content: Text(i18n.settingsCacheDeletedSnackbar),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
),
),
ListTile(
title: Text(i18n.themeMode),
trailing: DropdownButton<ThemeMode>(
key: const ValueKey('themeModeDropdown'),
value: userProvider.themeMode,
onChanged: (ThemeMode? newValue) {
if (newValue != null) {
userProvider.setThemeMode(newValue);
}
},
items: ThemeMode.values.map<DropdownMenuItem<ThemeMode>>((ThemeMode value) {
final label = (() {
switch (value) {
case ThemeMode.system:
return i18n.systemMode;
case ThemeMode.light:
return i18n.lightMode;
case ThemeMode.dark:
return i18n.darkMode;
}
})();
return DropdownMenuItem<ThemeMode>(
value: value,
child: Text(label),
);
}).toList(),
),
),
],
),
);
}
}