mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-02 10:09:11 +01:00
Merge branch 'master' into feature/better-error-handling
# Conflicts: # lib/screens/home_tabs_screen.dart # test/workout/day_form_test.mocks.dart # test/workout/gym_mode_session_screen_test.mocks.dart # test/workout/repetition_unit_form_widget_test.mocks.dart # test/workout/routine_edit_screen_test.mocks.dart # test/workout/routine_edit_test.mocks.dart # test/workout/routine_form_test.mocks.dart # test/workout/routine_logs_screen_test.mocks.dart # test/workout/slot_entry_form_test.mocks.dart # test/workout/weight_unit_form_widget_test.mocks.dart
This commit is contained in:
@@ -63,7 +63,7 @@ class RoutinesProvider with ChangeNotifier {
|
||||
static const _routineConfigRestTime = 'rest-config';
|
||||
static const _routineConfigMaxRestTime = 'max-rest-config';
|
||||
|
||||
Routine? _currentRoutine;
|
||||
Routine? activeRoutine;
|
||||
late ExercisesProvider _exerciseProvider;
|
||||
final WgerBaseProvider baseProvider;
|
||||
List<Routine> _routines = [];
|
||||
@@ -97,7 +97,7 @@ class RoutinesProvider with ChangeNotifier {
|
||||
|
||||
/// Clears all lists
|
||||
void clear() {
|
||||
_currentRoutine = null;
|
||||
activeRoutine = null;
|
||||
_routines = [];
|
||||
_weightUnits = [];
|
||||
_repetitionUnits = [];
|
||||
@@ -138,28 +138,14 @@ class RoutinesProvider with ChangeNotifier {
|
||||
return _routines.indexWhere((routine) => routine.id == id);
|
||||
}
|
||||
|
||||
/// Set the currently "active" workout plan
|
||||
void setCurrentPlan(int id) {
|
||||
_currentRoutine = findById(id);
|
||||
}
|
||||
|
||||
/// Returns the currently "active" workout plan
|
||||
Routine? get currentRoutine {
|
||||
return _currentRoutine;
|
||||
}
|
||||
|
||||
/// Reset the currently "active" workout plan to null
|
||||
void resetCurrentRoutine() {
|
||||
_currentRoutine = null;
|
||||
}
|
||||
|
||||
/// Returns the current active workout plan. At the moment this is just
|
||||
/// the latest, but this might change in the future.
|
||||
Routine? get activeRoutine {
|
||||
/// Sets the current active routine. At the moment this is just the latest,
|
||||
/// but this might change in the future.
|
||||
void setActiveRoutine() {
|
||||
if (_routines.isNotEmpty) {
|
||||
return _routines.first;
|
||||
activeRoutine = _routines.first;
|
||||
} else {
|
||||
activeRoutine = null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -179,12 +165,13 @@ class RoutinesProvider with ChangeNotifier {
|
||||
await fetchAndSetRoutineFull(entry['id']);
|
||||
}
|
||||
|
||||
setActiveRoutine();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Fetches all workout plan sparsely, i.e. only with the data on the plan
|
||||
/// object itself and no child attributes
|
||||
Future<void> fetchAndSetAllPlansSparse() async {
|
||||
/// Fetches all routines sparsely, i.e. only with the data on the object itself
|
||||
/// and no child attributes
|
||||
Future<void> fetchAndSetAllRoutinesSparse() async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_routinesUrlPath, query: {'limit': '1000', 'is_template': 'false'}),
|
||||
);
|
||||
@@ -194,7 +181,7 @@ class RoutinesProvider with ChangeNotifier {
|
||||
_routines.add(plan);
|
||||
}
|
||||
|
||||
// _workoutPlans.sort((a, b) => b.created.compareTo(a.created));
|
||||
setActiveRoutine();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -216,18 +203,19 @@ class RoutinesProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetches a workout plan sparsely, i.e. only with the data on the plan
|
||||
/// object itself and no child attributes
|
||||
/// Fetches a routine sparsely, i.e. only with the data on the object itself
|
||||
/// and no child attributes
|
||||
Future<Routine> fetchAndSetRoutineSparse(int planId) async {
|
||||
final fullPlanData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_routinesUrlPath, id: planId),
|
||||
);
|
||||
final plan = Routine.fromJson(fullPlanData);
|
||||
_routines.add(plan);
|
||||
final routine = Routine.fromJson(fullPlanData);
|
||||
_routines.add(routine);
|
||||
_routines.sort((a, b) => b.created.compareTo(a.created));
|
||||
|
||||
setActiveRoutine();
|
||||
notifyListeners();
|
||||
return plan;
|
||||
return routine;
|
||||
}
|
||||
|
||||
/// Fetches a workout plan fully, i.e. with all corresponding child attributes
|
||||
@@ -306,7 +294,7 @@ class RoutinesProvider with ChangeNotifier {
|
||||
routine.dayDataGym = dayDataEntriesGym;
|
||||
|
||||
// Logs
|
||||
routine.sessions = List<WorkoutSessionApi>.from(sessionDataEntries);
|
||||
routine.sessions = List<WorkoutSessionApi>.of(sessionDataEntries);
|
||||
for (final session in routine.sessions) {
|
||||
for (final log in session.logs) {
|
||||
if (log.weightUnitId != null) {
|
||||
@@ -327,6 +315,7 @@ class RoutinesProvider with ChangeNotifier {
|
||||
_routines.add(routine);
|
||||
}
|
||||
|
||||
setActiveRoutine();
|
||||
notifyListeners();
|
||||
return routine;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/dashboard/calendar.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets.dart';
|
||||
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';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
const DashboardScreen();
|
||||
@@ -35,7 +38,7 @@ class DashboardScreen extends StatelessWidget {
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
DashboardWorkoutWidget(),
|
||||
DashboardRoutineWidget(),
|
||||
DashboardNutritionWidget(),
|
||||
DashboardWeightWidget(),
|
||||
DashboardMeasurementWidget(),
|
||||
|
||||
@@ -101,7 +101,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
await Future.wait([
|
||||
galleryProvider.fetchAndSetGallery(),
|
||||
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
routinesProvider.fetchAndSetAllPlansSparse(),
|
||||
routinesProvider.fetchAndSetAllRoutinesSparse(),
|
||||
// routinesProvider.fetchAndSetAllRoutinesFull(),
|
||||
weightProvider.fetchAndSetEntries(),
|
||||
measurementProvider.fetchAndSetAllCategoriesAndEntries(),
|
||||
@@ -114,12 +114,11 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
await nutritionPlansProvider.fetchAndSetPlanFull(plan.id!);
|
||||
}
|
||||
|
||||
// Current workout plan
|
||||
// Current routine
|
||||
widget._logger.info('Loading current routine');
|
||||
if (routinesProvider.activeRoutine != null) {
|
||||
final planId = routinesProvider.activeRoutine!.id!;
|
||||
await routinesProvider.fetchAndSetRoutineFull(planId);
|
||||
routinesProvider.setCurrentPlan(planId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,581 +0,0 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg_icons/flutter_svg_icons.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/nutrition/nutritional_plan.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
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/gym_mode.dart';
|
||||
import 'package:wger/screens/log_meals_screen.dart';
|
||||
import 'package:wger/screens/measurement_categories_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plan_screen.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/measurements/categories_card.dart';
|
||||
import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/measurements/forms.dart';
|
||||
import 'package:wger/widgets/measurements/helpers.dart';
|
||||
import 'package:wger/widgets/nutrition/charts.dart';
|
||||
import 'package:wger/widgets/nutrition/forms.dart';
|
||||
import 'package:wger/widgets/routines/forms/routine.dart';
|
||||
import 'package:wger/widgets/weight/forms.dart';
|
||||
|
||||
class DashboardNutritionWidget extends StatefulWidget {
|
||||
const DashboardNutritionWidget();
|
||||
|
||||
@override
|
||||
_DashboardNutritionWidgetState createState() => _DashboardNutritionWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
NutritionalPlan? _plan;
|
||||
bool _hasContent = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_plan = Provider.of<NutritionPlansProvider>(context, listen: false).currentPlan;
|
||||
_hasContent = _plan != null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
_hasContent ? _plan!.description : AppLocalizations.of(context).nutritionalPlan,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
subtitle: Text(
|
||||
_hasContent
|
||||
? DateFormat.yMd(Localizations.localeOf(context).languageCode)
|
||||
.format(_plan!.creationDate)
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
Icons.restaurant,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
),
|
||||
if (_hasContent)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 15),
|
||||
child: FlNutritionalPlanGoalWidget(nutritionalPlan: _plan!),
|
||||
),
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noNutritionalPlans,
|
||||
AppLocalizations.of(context).newNutritionalPlan,
|
||||
PlanForm(),
|
||||
),
|
||||
if (_hasContent)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).goToDetailPage),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/ingredient-diary.svg'),
|
||||
),
|
||||
tooltip: AppLocalizations.of(context).logIngredient,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).logIngredient,
|
||||
IngredientLogForm(_plan!),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-diary.svg'),
|
||||
),
|
||||
tooltip: AppLocalizations.of(context).logMeal,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(LogMealsScreen.routeName, arguments: _plan);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DashboardWeightWidget extends StatelessWidget {
|
||||
const DashboardWeightWidget();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final profile = context.read<UserProvider>().profile;
|
||||
final weightProvider = context.read<BodyWeightProvider>();
|
||||
|
||||
final (entriesAll, entries7dAvg) = sensibleRange(
|
||||
weightProvider.items.map((e) => MeasurementChartEntry(e.weight, e.date)).toList(),
|
||||
);
|
||||
|
||||
return Consumer<BodyWeightProvider>(
|
||||
builder: (context, workoutProvider, child) => Card(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
AppLocalizations.of(context).weight,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
leading: FaIcon(
|
||||
FontAwesomeIcons.weightScale,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
if (weightProvider.items.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 200,
|
||||
child: MeasurementChartWidgetFl(
|
||||
entriesAll,
|
||||
weightUnit(profile!.isMetric, context),
|
||||
avgs: entries7dAvg,
|
||||
),
|
||||
),
|
||||
if (entries7dAvg.isNotEmpty)
|
||||
MeasurementOverallChangeWidget(
|
||||
entries7dAvg.first,
|
||||
entries7dAvg.last,
|
||||
weightUnit(profile.isMetric, context),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).goToDetailPage,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(WeightScreen.routeName);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newEntry,
|
||||
WeightForm(weightProvider
|
||||
.getNewestEntry()
|
||||
?.copyWith(id: null, date: DateTime.now())),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noWeightEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
WeightForm(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DashboardMeasurementWidget extends StatefulWidget {
|
||||
const DashboardMeasurementWidget();
|
||||
|
||||
@override
|
||||
_DashboardMeasurementWidgetState createState() => _DashboardMeasurementWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget> {
|
||||
int _current = 0;
|
||||
final _controller = CarouselSliderController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<MeasurementProvider>(context, listen: false);
|
||||
|
||||
final items =
|
||||
provider.categories.map<Widget>((item) => CategoriesCard(item, elevation: 0)).toList();
|
||||
if (items.isNotEmpty) {
|
||||
items.add(
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).moreMeasurementEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementCategoryForm(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Consumer<MeasurementProvider>(
|
||||
builder: (context, workoutProvider, child) => Card(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
AppLocalizations.of(context).measurements,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
leading: FaIcon(
|
||||
FontAwesomeIcons.chartLine,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
// TODO: this icon feels out of place and inconsistent with all
|
||||
// other dashboard widgets.
|
||||
// maybe we should just add a "Go to all" at the bottom of the widget
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
MeasurementCategoriesScreen.routeName,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
if (items.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
CarouselSlider(
|
||||
items: items,
|
||||
carouselController: _controller,
|
||||
options: CarouselOptions(
|
||||
autoPlay: false,
|
||||
enlargeCenterPage: false,
|
||||
viewportFraction: 1,
|
||||
enableInfiniteScroll: false,
|
||||
aspectRatio: 1.1,
|
||||
onPageChanged: (index, reason) {
|
||||
setState(() {
|
||||
_current = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: items.asMap().entries.map((entry) {
|
||||
return GestureDetector(
|
||||
onTap: () => _controller.animateToPage(entry.key),
|
||||
child: Container(
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal: 4.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color:
|
||||
Theme.of(context).textTheme.headlineSmall!.color!.withOpacity(
|
||||
_current == entry.key ? 0.9 : 0.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noMeasurementEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementCategoryForm(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DashboardWorkoutWidget extends StatefulWidget {
|
||||
const DashboardWorkoutWidget();
|
||||
|
||||
@override
|
||||
_DashboardWorkoutWidgetState createState() => _DashboardWorkoutWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
var _showDetail = false;
|
||||
bool _hasContent = false;
|
||||
|
||||
Routine? _routine;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_routine = context.read<RoutinesProvider>().activeRoutine;
|
||||
_hasContent = _routine != null;
|
||||
}
|
||||
|
||||
List<Widget> getContent() {
|
||||
final List<Widget> out = [];
|
||||
|
||||
if (!_hasContent) {
|
||||
return out;
|
||||
}
|
||||
|
||||
for (final dayData in _routine!.dayDataCurrentIteration) {
|
||||
if (dayData.day == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out.add(SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
children: [
|
||||
if (dayData.date.isSameDayAs(DateTime.now())) const Icon(Icons.today),
|
||||
Expanded(
|
||||
child: Text(
|
||||
dayData.day == null || dayData.day!.isRest
|
||||
? AppLocalizations.of(context).restDay
|
||||
: dayData.day!.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: MutedText(
|
||||
dayData.day != null ? dayData.day!.description : '',
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (dayData.day == null || dayData.day!.isRest)
|
||||
const Icon(Icons.hotel)
|
||||
else
|
||||
IconButton(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
color: wgerPrimaryButtonColor,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
GymModeScreen.routeName,
|
||||
arguments: GymModeArguments(_routine!.id!, dayData.day!.id!, dayData.iteration),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
for (final slotData in dayData.slots) {
|
||||
out.add(SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...slotData.setConfigs.map(
|
||||
(s) => _showDetail
|
||||
? Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(s.exercise
|
||||
.getTranslation(Localizations.localeOf(context).languageCode)
|
||||
.name),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: MutedText(s.textRepr, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
out.add(const Divider());
|
||||
}
|
||||
|
||||
// if (_routine!.fitInWeek) {
|
||||
// out.add(Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// AppLocalizations.of(context).tillEndOfWeek,
|
||||
// style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// const Icon(Icons.hotel),
|
||||
// ],
|
||||
// ));
|
||||
// out.add(const Divider());
|
||||
// }
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
_hasContent ? _routine!.name : AppLocalizations.of(context).labelWorkoutPlan,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
subtitle: Text(
|
||||
_hasContent
|
||||
? '${dateFormat.format(_routine!.start)} - ${dateFormat.format(_routine!.end)}'
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
Icons.fitness_center,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
trailing: _hasContent
|
||||
? Tooltip(
|
||||
message: AppLocalizations.of(context).toggleDetails,
|
||||
child: _showDetail ? const Icon(Icons.info) : const Icon(Icons.info_outline),
|
||||
)
|
||||
: const SizedBox(),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showDetail = !_showDetail;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (_hasContent)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(children: [...getContent()]),
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noRoutines,
|
||||
AppLocalizations.of(context).newRoutine,
|
||||
RoutineForm(Routine.empty()),
|
||||
),
|
||||
if (_hasContent)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).goToDetailPage),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
RoutineScreen.routeName,
|
||||
arguments: _routine!.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class NothingFound extends StatelessWidget {
|
||||
final String _title;
|
||||
final String _titleForm;
|
||||
final Widget _form;
|
||||
|
||||
const NothingFound(this._title, this._titleForm, this._form);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 150,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(_title),
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(Icons.add_box, color: wgerPrimaryButtonColor),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
_titleForm,
|
||||
hasListView: true,
|
||||
_form,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
143
lib/widgets/dashboard/widgets/measurements.dart
Normal file
143
lib/widgets/dashboard/widgets/measurements.dart
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/screens/measurement_categories_screen.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nothing_found.dart';
|
||||
import 'package:wger/widgets/measurements/categories_card.dart';
|
||||
import 'package:wger/widgets/measurements/forms.dart';
|
||||
|
||||
class DashboardMeasurementWidget extends StatefulWidget {
|
||||
const DashboardMeasurementWidget();
|
||||
|
||||
@override
|
||||
_DashboardMeasurementWidgetState createState() => _DashboardMeasurementWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget> {
|
||||
int _current = 0;
|
||||
final _controller = CarouselSliderController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<MeasurementProvider>(context, listen: false);
|
||||
|
||||
final items =
|
||||
provider.categories.map<Widget>((item) => CategoriesCard(item, elevation: 0)).toList();
|
||||
if (items.isNotEmpty) {
|
||||
items.add(
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).moreMeasurementEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementCategoryForm(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Consumer<MeasurementProvider>(
|
||||
builder: (context, _, __) => Card(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
AppLocalizations.of(context).measurements,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
leading: FaIcon(
|
||||
FontAwesomeIcons.chartLine,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
// TODO: this icon feels out of place and inconsistent with all
|
||||
// other dashboard widgets.
|
||||
// maybe we should just add a "Go to all" at the bottom of the widget
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
MeasurementCategoriesScreen.routeName,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
if (items.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
CarouselSlider(
|
||||
items: items,
|
||||
carouselController: _controller,
|
||||
options: CarouselOptions(
|
||||
autoPlay: false,
|
||||
enlargeCenterPage: false,
|
||||
viewportFraction: 1,
|
||||
enableInfiniteScroll: false,
|
||||
aspectRatio: 1.1,
|
||||
onPageChanged: (index, reason) {
|
||||
setState(() {
|
||||
_current = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: items.asMap().entries.map((entry) {
|
||||
return GestureDetector(
|
||||
onTap: () => _controller.animateToPage(entry.key),
|
||||
child: Container(
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal: 4.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color:
|
||||
Theme.of(context).textTheme.headlineSmall!.color!.withOpacity(
|
||||
_current == entry.key ? 0.9 : 0.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noMeasurementEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementCategoryForm(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
57
lib/widgets/dashboard/widgets/nothing_found.dart
Normal file
57
lib/widgets/dashboard/widgets/nothing_found.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:flutter/material.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
class NothingFound extends StatelessWidget {
|
||||
final String _title;
|
||||
final String _titleForm;
|
||||
final Widget _form;
|
||||
|
||||
const NothingFound(this._title, this._titleForm, this._form);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 150,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(_title),
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(Icons.add_box, color: wgerPrimaryButtonColor),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
_titleForm,
|
||||
hasListView: true,
|
||||
_form,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
132
lib/widgets/dashboard/widgets/nutrition.dart
Normal file
132
lib/widgets/dashboard/widgets/nutrition.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:flutter/material.dart';
|
||||
import 'package:flutter_svg_icons/flutter_svg_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/nutrition/nutritional_plan.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/log_meals_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plan_screen.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nothing_found.dart';
|
||||
import 'package:wger/widgets/nutrition/charts.dart';
|
||||
import 'package:wger/widgets/nutrition/forms.dart';
|
||||
|
||||
class DashboardNutritionWidget extends StatefulWidget {
|
||||
const DashboardNutritionWidget();
|
||||
|
||||
@override
|
||||
_DashboardNutritionWidgetState createState() => _DashboardNutritionWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
NutritionalPlan? _plan;
|
||||
bool _hasContent = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_plan = Provider.of<NutritionPlansProvider>(context, listen: false).currentPlan;
|
||||
_hasContent = _plan != null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
_hasContent ? _plan!.description : AppLocalizations.of(context).nutritionalPlan,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
subtitle: Text(
|
||||
_hasContent
|
||||
? DateFormat.yMd(Localizations.localeOf(context).languageCode)
|
||||
.format(_plan!.creationDate)
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
Icons.restaurant,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
),
|
||||
if (_hasContent)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 15),
|
||||
child: FlNutritionalPlanGoalWidget(nutritionalPlan: _plan!),
|
||||
),
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noNutritionalPlans,
|
||||
AppLocalizations.of(context).newNutritionalPlan,
|
||||
PlanForm(),
|
||||
),
|
||||
if (_hasContent)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).goToDetailPage),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/ingredient-diary.svg'),
|
||||
),
|
||||
tooltip: AppLocalizations.of(context).logIngredient,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).logIngredient,
|
||||
IngredientLogForm(_plan!),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const SvgIcon(
|
||||
icon: SvgIconData('assets/icons/meal-diary.svg'),
|
||||
),
|
||||
tooltip: AppLocalizations.of(context).logMeal,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(LogMealsScreen.routeName, arguments: _plan);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
205
lib/widgets/dashboard/widgets/routines.dart
Normal file
205
lib/widgets/dashboard/widgets/routines.dart
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/workouts/day_data.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nothing_found.dart';
|
||||
import 'package:wger/widgets/routines/forms/routine.dart';
|
||||
|
||||
class DashboardRoutineWidget extends StatefulWidget {
|
||||
const DashboardRoutineWidget();
|
||||
|
||||
@override
|
||||
_DashboardRoutineWidgetState createState() => _DashboardRoutineWidgetState();
|
||||
}
|
||||
|
||||
class _DashboardRoutineWidgetState extends State<DashboardRoutineWidget> {
|
||||
var _showDetail = false;
|
||||
bool _hasContent = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final routine = context.watch<RoutinesProvider>().activeRoutine;
|
||||
_hasContent = routine != null;
|
||||
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
_hasContent ? routine!.name : AppLocalizations.of(context).labelWorkoutPlan,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
subtitle: Text(
|
||||
_hasContent
|
||||
? '${dateFormat.format(routine!.start)} - ${dateFormat.format(routine!.end)}'
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
Icons.fitness_center,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
trailing: _hasContent
|
||||
? Tooltip(
|
||||
message: AppLocalizations.of(context).toggleDetails,
|
||||
child: _showDetail ? const Icon(Icons.info) : const Icon(Icons.info_outline),
|
||||
)
|
||||
: const SizedBox(),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showDetail = !_showDetail;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (_hasContent) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: DetailContentWidget(routine!.dayDataCurrentIteration, _showDetail),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).goToDetailPage),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
RoutineScreen.routeName,
|
||||
arguments: routine.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
] else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noRoutines,
|
||||
AppLocalizations.of(context).newRoutine,
|
||||
RoutineForm(Routine.empty()),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailContentWidget extends StatelessWidget {
|
||||
final List<DayData> dayDataList;
|
||||
final bool showDetail;
|
||||
|
||||
const DetailContentWidget(this.dayDataList, this.showDetail, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
...dayDataList.where((dayData) => dayData.day != null).map((dayData) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
children: [
|
||||
if (dayData.date.isSameDayAs(DateTime.now())) const Icon(Icons.today),
|
||||
Expanded(
|
||||
child: Text(
|
||||
dayData.day == null || dayData.day!.isRest
|
||||
? AppLocalizations.of(context).restDay
|
||||
: dayData.day!.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: MutedText(
|
||||
dayData.day != null ? dayData.day!.description : '',
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (dayData.day == null || dayData.day!.isRest)
|
||||
const Icon(Icons.hotel)
|
||||
else
|
||||
IconButton(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
color: wgerPrimaryButtonColor,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
GymModeScreen.routeName,
|
||||
arguments: GymModeArguments(
|
||||
dayData.day!.routineId,
|
||||
dayData.day!.id!,
|
||||
dayData.iteration,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
...dayData.slots.map(
|
||||
(slotData) => SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...slotData.setConfigs.map(
|
||||
(s) => showDetail
|
||||
? Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(s.exercise
|
||||
.getTranslation(
|
||||
Localizations.localeOf(context).languageCode)
|
||||
.name),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child:
|
||||
MutedText(s.textRepr, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
121
lib/widgets/dashboard/widgets/weight.dart
Normal file
121
lib/widgets/dashboard/widgets/weight.dart
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 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:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nothing_found.dart';
|
||||
import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/measurements/helpers.dart';
|
||||
import 'package:wger/widgets/weight/forms.dart';
|
||||
|
||||
class DashboardWeightWidget extends StatelessWidget {
|
||||
const DashboardWeightWidget();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final profile = context.read<UserProvider>().profile;
|
||||
final weightProvider = context.read<BodyWeightProvider>();
|
||||
|
||||
final (entriesAll, entries7dAvg) = sensibleRange(
|
||||
weightProvider.items.map((e) => MeasurementChartEntry(e.weight, e.date)).toList(),
|
||||
);
|
||||
|
||||
return Consumer<BodyWeightProvider>(
|
||||
builder: (context, _, __) => Card(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
AppLocalizations.of(context).weight,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
leading: FaIcon(
|
||||
FontAwesomeIcons.weightScale,
|
||||
color: Theme.of(context).textTheme.headlineSmall!.color,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
if (weightProvider.items.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 200,
|
||||
child: MeasurementChartWidgetFl(
|
||||
entriesAll,
|
||||
weightUnit(profile!.isMetric, context),
|
||||
avgs: entries7dAvg,
|
||||
),
|
||||
),
|
||||
if (entries7dAvg.isNotEmpty)
|
||||
MeasurementOverallChangeWidget(
|
||||
entries7dAvg.first,
|
||||
entries7dAvg.last,
|
||||
weightUnit(profile.isMetric, context),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).goToDetailPage,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(WeightScreen.routeName);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newEntry,
|
||||
WeightForm(weightProvider
|
||||
.getNewestEntry()
|
||||
?.copyWith(id: null, date: DateTime.now())),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noWeightEntries,
|
||||
AppLocalizations.of(context).newEntry,
|
||||
WeightForm(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class _RoutinesListState extends State<RoutinesList> {
|
||||
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => widget._routineProvider.fetchAndSetAllPlansSparse(),
|
||||
onRefresh: () => widget._routineProvider.fetchAndSetAllRoutinesSparse(),
|
||||
child: widget._routineProvider.items.isEmpty
|
||||
? const TextPrompt()
|
||||
: ListView.builder(
|
||||
@@ -53,7 +53,7 @@ class _RoutinesListState extends State<RoutinesList> {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
onTap: () async {
|
||||
widget._routineProvider.setCurrentPlan(currentRoutine.id!);
|
||||
widget._routineProvider.activeRoutine = currentRoutine;
|
||||
|
||||
setState(() {
|
||||
_loadingRoutine = currentRoutine.id;
|
||||
|
||||
12
pubspec.lock
12
pubspec.lock
@@ -285,18 +285,18 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: drift
|
||||
sha256: "14a61af39d4584faf1d73b5b35e4b758a43008cf4c0fdb0576ec8e7032c0d9a5"
|
||||
sha256: b584ddeb2b74436735dd2cf746d2d021e19a9a6770f409212fd5cbc2814ada85
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.26.0"
|
||||
version: "2.26.1"
|
||||
drift_dev:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: drift_dev
|
||||
sha256: "0d3f8b33b76cf1c6a82ee34d9511c40957549c4674b8f1688609e6d6c7306588"
|
||||
sha256: "54dc207c6e4662741f60e5752678df183957ab907754ffab0372a7082f6d2816"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.26.0"
|
||||
version: "2.26.1"
|
||||
equatable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1048,10 +1048,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: provider
|
||||
sha256: "489024f942069c2920c844ee18bb3d467c69e48955a4f32d1677f71be103e310"
|
||||
sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
version: "6.1.5"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -36,7 +36,7 @@ dependencies:
|
||||
clock: ^1.1.2
|
||||
collection: ^1.18.0
|
||||
cupertino_icons: ^1.0.8
|
||||
drift: ^2.26.0
|
||||
drift: ^2.26.1
|
||||
equatable: ^2.0.7
|
||||
fl_chart: ^0.69.2
|
||||
flex_color_scheme: ^8.1.1
|
||||
@@ -58,7 +58,7 @@ dependencies:
|
||||
package_info_plus: ^8.3.0
|
||||
path: ^1.9.0
|
||||
path_provider: ^2.1.5
|
||||
provider: ^6.1.4
|
||||
provider: ^6.1.5
|
||||
rive: ^0.13.20
|
||||
shared_preferences: ^2.5.3
|
||||
sqlite3_flutter_libs: ^0.5.31
|
||||
@@ -79,7 +79,7 @@ dev_dependencies:
|
||||
sdk: flutter
|
||||
build_runner: ^2.4.15
|
||||
cider: ^0.2.7
|
||||
drift_dev: ^2.26.0
|
||||
drift_dev: ^2.26.1
|
||||
flutter_lints: ^5.0.0
|
||||
freezed: ^3.0.6
|
||||
json_serializable: ^6.9.5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.5 from annotations
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/measurements/measurement_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -25,19 +25,43 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
|
||||
_FakeAuthProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeAuthProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
|
||||
_FakeClient_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeClient_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeUri_2 extends _i1.SmartFake implements Uri {
|
||||
_FakeUri_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeUri_2(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
_FakeResponse_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeResponse_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
@@ -51,32 +75,46 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
@override
|
||||
_i2.AuthProvider get auth => (super.noSuchMethod(
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(this, Invocation.getter(#auth)),
|
||||
returnValue: _FakeAuthProvider_0(
|
||||
this,
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(#auth, _auth),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(this, Invocation.getter(#client)),
|
||||
returnValue: _FakeClient_1(
|
||||
this,
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#auth,
|
||||
_auth,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(#client, _client),
|
||||
Invocation.setter(
|
||||
#client,
|
||||
_client,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
}),
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
{#includeAuth: includeAuth},
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@@ -91,37 +129,58 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
) as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(
|
||||
#fetchPaginated,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(Map<String, dynamic>? data, Uri? uri) =>
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#post, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#post,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -130,20 +189,38 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#patch, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#patch,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
returnValue: _i5.Future<_i3.Response>.value(
|
||||
_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
),
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
int? id,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<_i3.Response>);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.5 from annotations
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/user/provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -25,19 +25,43 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
|
||||
_FakeAuthProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeAuthProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
|
||||
_FakeClient_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeClient_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeUri_2 extends _i1.SmartFake implements Uri {
|
||||
_FakeUri_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeUri_2(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
_FakeResponse_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeResponse_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
@@ -51,32 +75,46 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
@override
|
||||
_i2.AuthProvider get auth => (super.noSuchMethod(
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(this, Invocation.getter(#auth)),
|
||||
returnValue: _FakeAuthProvider_0(
|
||||
this,
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(#auth, _auth),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(this, Invocation.getter(#client)),
|
||||
returnValue: _FakeClient_1(
|
||||
this,
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#auth,
|
||||
_auth,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(#client, _client),
|
||||
Invocation.setter(
|
||||
#client,
|
||||
_client,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
}),
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
{#includeAuth: includeAuth},
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@@ -91,37 +129,58 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
) as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(
|
||||
#fetchPaginated,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(Map<String, dynamic>? data, Uri? uri) =>
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#post, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#post,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -130,20 +189,38 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#patch, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#patch,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
returnValue: _i5.Future<_i3.Response>.value(
|
||||
_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
),
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
int? id,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<_i3.Response>);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.5 from annotations
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/weight/weight_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -25,19 +25,43 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
|
||||
_FakeAuthProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeAuthProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
|
||||
_FakeClient_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeClient_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeUri_2 extends _i1.SmartFake implements Uri {
|
||||
_FakeUri_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeUri_2(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
_FakeResponse_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
_FakeResponse_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
@@ -51,32 +75,46 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
@override
|
||||
_i2.AuthProvider get auth => (super.noSuchMethod(
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(this, Invocation.getter(#auth)),
|
||||
returnValue: _FakeAuthProvider_0(
|
||||
this,
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(#auth, _auth),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(this, Invocation.getter(#client)),
|
||||
returnValue: _FakeClient_1(
|
||||
this,
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#auth,
|
||||
_auth,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(#client, _client),
|
||||
Invocation.setter(
|
||||
#client,
|
||||
_client,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
}),
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
{#includeAuth: includeAuth},
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@@ -91,37 +129,58 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
) as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(
|
||||
#fetchPaginated,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(Map<String, dynamic>? data, Uri? uri) =>
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#post, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#post,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -130,20 +189,38 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#patch, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
Invocation.method(
|
||||
#patch,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
returnValue: _i5.Future<_i3.Response>.value(
|
||||
_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
),
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
int? id,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<_i3.Response>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user