mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Add user preference in settings to hide diet plan if not used
This commit is contained in:
32
ios/Flutter/ephemeral/flutter_lldb_helper.py
Normal file
32
ios/Flutter/ephemeral/flutter_lldb_helper.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
import lldb
|
||||
|
||||
def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
|
||||
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
|
||||
base = frame.register["x0"].GetValueAsAddress()
|
||||
page_len = frame.register["x1"].GetValueAsUnsigned()
|
||||
|
||||
# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
|
||||
# first page to see if handled it correctly. This makes diagnosing
|
||||
# misconfiguration (e.g. missing breakpoint) easier.
|
||||
data = bytearray(page_len)
|
||||
data[0:8] = b'IHELPED!'
|
||||
|
||||
error = lldb.SBError()
|
||||
frame.GetThread().GetProcess().WriteMemory(base, data, error)
|
||||
if not error.Success():
|
||||
print(f'Failed to write into {base}[+{page_len}]', error)
|
||||
return
|
||||
|
||||
def __lldb_init_module(debugger: lldb.SBDebugger, _):
|
||||
target = debugger.GetDummyTarget()
|
||||
# Caveat: must use BreakpointCreateByRegEx here and not
|
||||
# BreakpointCreateByName. For some reasons callback function does not
|
||||
# get carried over from dummy target for the later.
|
||||
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
|
||||
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
|
||||
bp.SetAutoContinue(True)
|
||||
print("-- LLDB integration loaded --")
|
||||
5
ios/Flutter/ephemeral/flutter_lldbinit
Normal file
5
ios/Flutter/ephemeral/flutter_lldbinit
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
command script import --relative-to-command-file flutter_lldb_helper.py
|
||||
@@ -29,10 +29,13 @@ class UserProvider with ChangeNotifier {
|
||||
ThemeMode themeMode = ThemeMode.system;
|
||||
final WgerBaseProvider baseProvider;
|
||||
late SharedPreferencesAsync prefs;
|
||||
bool hideNutrition = false;
|
||||
|
||||
UserProvider(this.baseProvider, {SharedPreferencesAsync? prefs}) {
|
||||
this.prefs = prefs ?? PreferenceHelper.asyncPref;
|
||||
_loadThemeMode();
|
||||
_loadHideNutrition();
|
||||
|
||||
}
|
||||
|
||||
static const PROFILE_URL = 'userprofile';
|
||||
@@ -67,6 +70,13 @@ class UserProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _loadHideNutrition() async {
|
||||
final val = await prefs.getBool('hideNutrition');
|
||||
hideNutrition = val ?? false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
// Change mode on switch button click
|
||||
void setThemeMode(ThemeMode mode) async {
|
||||
themeMode = mode;
|
||||
@@ -81,6 +91,12 @@ class UserProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setHideNutrition(bool value) async {
|
||||
hideNutrition = value;
|
||||
await prefs.setBool('hideNutrition', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Fetch the current user's profile
|
||||
Future<void> fetchAndSetProfile() async {
|
||||
final userData = await baseProvider.fetch(baseProvider.makeUrl(PROFILE_URL));
|
||||
@@ -91,6 +107,7 @@ class UserProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Save the user's profile to the server
|
||||
Future<void> saveProfile() async {
|
||||
await baseProvider.post(
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/dashboard/calendar.dart';
|
||||
@@ -24,6 +25,7 @@ import 'package:wger/widgets/dashboard/widgets/measurements.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nutrition.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/routines.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/weight.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
const DashboardScreen();
|
||||
@@ -32,17 +34,19 @@ class DashboardScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = Provider.of<UserProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: MainAppBar(AppLocalizations.of(context).labelDashboard),
|
||||
body: const SingleChildScrollView(
|
||||
padding: EdgeInsets.all(10),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
DashboardRoutineWidget(),
|
||||
DashboardNutritionWidget(),
|
||||
DashboardWeightWidget(),
|
||||
DashboardMeasurementWidget(),
|
||||
DashboardCalendarWidget(),
|
||||
if (!user.hideNutrition) DashboardNutritionWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -23,6 +23,9 @@ 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:provider/provider.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
|
||||
|
||||
class SettingsPage extends StatelessWidget {
|
||||
static String routeName = '/SettingsPage';
|
||||
@@ -44,6 +47,18 @@ class SettingsPage extends StatelessWidget {
|
||||
const SettingsIngredientCache(),
|
||||
ListTile(title: Text(i18n.others, style: Theme.of(context).textTheme.headlineSmall)),
|
||||
const SettingsTheme(),
|
||||
Consumer<UserProvider>(
|
||||
builder: (context, user, _) {
|
||||
return SwitchListTile(
|
||||
title: const Text('Show nutrition section on dashboard'),
|
||||
value: !user.hideNutrition,
|
||||
onChanged: (v) {
|
||||
Provider.of<UserProvider>(context, listen: false)
|
||||
.setHideNutrition(!v);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(i18n.selectAvailablePlates),
|
||||
onTap: () {
|
||||
|
||||
Reference in New Issue
Block a user