mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Add detail view for exercises
This commit is contained in:
@@ -29,6 +29,7 @@ import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'package:wger/screens/auth_screen.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
import 'package:wger/screens/exercise_screen.dart';
|
||||
import 'package:wger/screens/exercises_screen.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/gallery_screen.dart';
|
||||
@@ -136,6 +137,7 @@ class MyApp extends StatelessWidget {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
WorkoutPlansScreen.routeName: (ctx) => WorkoutPlansScreen(),
|
||||
ExercisesScreen.routeName: (ctx) => ExercisesScreen(),
|
||||
ExerciseDetailScreen.routeName: (ctx) => ExerciseDetailScreen(),
|
||||
AddExerciseScreen.routeName: (ctx) => AddExerciseScreen(),
|
||||
},
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
|
||||
41
lib/screens/exercise_screen.dart
Normal file
41
lib/screens/exercise_screen.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/exercises/exercises.dart';
|
||||
|
||||
class ExerciseDetailScreen extends StatelessWidget {
|
||||
static const routeName = '/exercise-detail';
|
||||
|
||||
const ExerciseDetailScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final exerciseBase = ModalRoute.of(context)!.settings.arguments as Exercise;
|
||||
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).exercise),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: ExerciseDetail(exerciseBase)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -37,3 +37,24 @@ class MutedText extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Pill extends StatelessWidget {
|
||||
const Pill({Key? key, required this.title}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColorLight.withOpacity(0.15),
|
||||
border: Border.all(color: Colors.grey[300]!),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
import 'package:wger/widgets/exercises/list_tile.dart';
|
||||
|
||||
class ExerciseDetail extends StatelessWidget {
|
||||
final Exercise _exercise;
|
||||
@@ -36,40 +39,22 @@ class ExerciseDetail extends StatelessWidget {
|
||||
children: [
|
||||
// Category
|
||||
Text(
|
||||
AppLocalizations.of(context).category,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
_exercise.name,
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
|
||||
Pill(
|
||||
title: _exercise.category.name,
|
||||
),
|
||||
Text(_exercise.category.name),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Equipment
|
||||
Text(
|
||||
AppLocalizations.of(context).equipment,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
if (_exercise.equipment.isNotEmpty)
|
||||
Text(_exercise.equipment.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.equipment.isEmpty) const Text('-/-'),
|
||||
const MutedText('Also known as: Burpees, Basic burpees'),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Muscles
|
||||
Text(
|
||||
AppLocalizations.of(context).muscles,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
ExerciseImageWidget(
|
||||
image: _exercise.getMainImage,
|
||||
),
|
||||
if (_exercise.muscles.isNotEmpty)
|
||||
Text(_exercise.muscles.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.muscles.isEmpty) const Text('-/-'),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Muscles secondary
|
||||
Text(
|
||||
AppLocalizations.of(context).musclesSecondary,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
if (_exercise.musclesSecondary.isNotEmpty)
|
||||
Text(_exercise.musclesSecondary.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.musclesSecondary.isEmpty) const Text('-/-'),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Description
|
||||
@@ -78,6 +63,60 @@ class ExerciseDetail extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Html(data: _exercise.description),
|
||||
|
||||
// Notes
|
||||
Text(
|
||||
AppLocalizations.of(context).notes,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
..._exercise.tips.map((e) => Text(e.comment)).toList(),
|
||||
|
||||
// Muscles
|
||||
Text(
|
||||
AppLocalizations.of(context).muscles,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
const Placeholder(
|
||||
color: Colors.grey,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).muscles,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
..._exercise.muscles.map((e) => Text(e.name)).toList(),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).musclesSecondary,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
..._exercise.musclesSecondary
|
||||
.map((e) => Text(e.name))
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Variants
|
||||
Text(
|
||||
'Variants',
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
|
||||
ExerciseListTile(exercise: _exercise),
|
||||
ExerciseListTile(exercise: _exercise),
|
||||
ExerciseListTile(exercise: _exercise),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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/providers/exercises.dart';
|
||||
@@ -8,7 +26,8 @@ class ExerciseFilterModalBody extends StatefulWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ExerciseFilterModalBodyState createState() => _ExerciseFilterModalBodyState();
|
||||
_ExerciseFilterModalBodyState createState() =>
|
||||
_ExerciseFilterModalBodyState();
|
||||
}
|
||||
|
||||
class _ExerciseFilterModalBodyState extends State<ExerciseFilterModalBody> {
|
||||
@@ -55,7 +74,8 @@ class _ExerciseFilterModalBodyState extends State<ExerciseFilterModalBody> {
|
||||
value: currentEntry.value,
|
||||
onChanged: (_) {
|
||||
setState(() {
|
||||
filterCategory.items.update(currentEntry.key, (value) => !value);
|
||||
filterCategory.items
|
||||
.update(currentEntry.key, (value) => !value);
|
||||
Provider.of<ExercisesProvider>(context, listen: false)
|
||||
.setFilters(filters);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
|
||||
@@ -23,10 +41,11 @@ class _FilterRowState extends State<FilterRow> {
|
||||
_exerciseNameController = TextEditingController()
|
||||
..addListener(
|
||||
() {
|
||||
final provider = Provider.of<ExercisesProvider>(context, listen: false);
|
||||
final provider =
|
||||
Provider.of<ExercisesProvider>(context, listen: false);
|
||||
if (provider.filters!.searchTerm != _exerciseNameController.text) {
|
||||
provider
|
||||
.setFilters(provider.filters!.copyWith(searchTerm: _exerciseNameController.text));
|
||||
provider.setFilters(provider.filters!
|
||||
.copyWith(searchTerm: _exerciseNameController.text));
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -88,7 +107,8 @@ class _FilterRowState extends State<FilterRow> {
|
||||
onSelected: (ExerciseMoreOption selectedOption) {
|
||||
switch (selectedOption) {
|
||||
case ExerciseMoreOption.ADD_EXERCISE:
|
||||
Navigator.of(context).pushNamed(AddExerciseScreen.routeName);
|
||||
Navigator.of(context)
|
||||
.pushNamed(AddExerciseScreen.routeName);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/screens/exercise_screen.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
|
||||
class ExerciseListTile extends StatelessWidget {
|
||||
@@ -9,12 +28,11 @@ class ExerciseListTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final theme = Theme.of(context);
|
||||
//final size = MediaQuery.of(context).size;
|
||||
//final theme = Theme.of(context);
|
||||
|
||||
return ListTile(
|
||||
leading:
|
||||
CircleAvatar(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: const Color(0x00ffffff),
|
||||
child: ClipOval(
|
||||
child: SizedBox(
|
||||
@@ -26,7 +44,6 @@ class ExerciseListTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
title: Text(
|
||||
exercise.name,
|
||||
//style: theme.textTheme.headline6,
|
||||
@@ -36,6 +53,9 @@ class ExerciseListTile extends StatelessWidget {
|
||||
subtitle: Text(
|
||||
exercise.category.name,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, ExerciseDetailScreen.routeName, arguments: exercise);
|
||||
},
|
||||
/*
|
||||
trailing: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
|
||||
|
||||
Reference in New Issue
Block a user