diff --git a/lib/main.dart b/lib/main.dart index 3dd38674..c349b330 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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, diff --git a/lib/screens/exercise_screen.dart b/lib/screens/exercise_screen.dart new file mode 100644 index 00000000..aee480c7 --- /dev/null +++ b/lib/screens/exercise_screen.dart @@ -0,0 +1,41 @@ +/* + * This file is part of wger Workout Manager . + * 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 . + */ + +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)), + ); + } +} diff --git a/lib/widgets/core/core.dart b/lib/widgets/core/core.dart index c8ba0f5c..b5d5ea83 100644 --- a/lib/widgets/core/core.dart +++ b/lib/widgets/core/core.dart @@ -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, + ), + ); + } +} diff --git a/lib/widgets/exercises/exercises.dart b/lib/widgets/exercises/exercises.dart index 56582e01..60704ed2 100644 --- a/lib/widgets/exercises/exercises.dart +++ b/lib/widgets/exercises/exercises.dart @@ -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), ], ), diff --git a/lib/widgets/exercises/filter_modal.dart b/lib/widgets/exercises/filter_modal.dart index aaf7cc63..79252c19 100644 --- a/lib/widgets/exercises/filter_modal.dart +++ b/lib/widgets/exercises/filter_modal.dart @@ -1,3 +1,21 @@ +/* + * This file is part of wger Workout Manager . + * 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 . + */ + 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 { @@ -55,7 +74,8 @@ class _ExerciseFilterModalBodyState extends State { value: currentEntry.value, onChanged: (_) { setState(() { - filterCategory.items.update(currentEntry.key, (value) => !value); + filterCategory.items + .update(currentEntry.key, (value) => !value); Provider.of(context, listen: false) .setFilters(filters); }); diff --git a/lib/widgets/exercises/filter_row.dart b/lib/widgets/exercises/filter_row.dart index 585337c6..a64ce98b 100644 --- a/lib/widgets/exercises/filter_row.dart +++ b/lib/widgets/exercises/filter_row.dart @@ -1,6 +1,24 @@ +/* + * This file is part of wger Workout Manager . + * 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 . + */ + 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 { _exerciseNameController = TextEditingController() ..addListener( () { - final provider = Provider.of(context, listen: false); + final provider = + Provider.of(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 { onSelected: (ExerciseMoreOption selectedOption) { switch (selectedOption) { case ExerciseMoreOption.ADD_EXERCISE: - Navigator.of(context).pushNamed(AddExerciseScreen.routeName); + Navigator.of(context) + .pushNamed(AddExerciseScreen.routeName); break; } }, diff --git a/lib/widgets/exercises/list_tile.dart b/lib/widgets/exercises/list_tile.dart index e46598b2..59e3030b 100644 --- a/lib/widgets/exercises/list_tile.dart +++ b/lib/widgets/exercises/list_tile.dart @@ -1,5 +1,24 @@ +/* + * This file is part of wger Workout Manager . + * 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 . + */ + 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),