Fix some widgets, polishing, renaming

This commit is contained in:
Roland Geider
2024-11-20 14:39:17 +01:00
parent 7794948f28
commit 04e112d810
7 changed files with 36 additions and 23 deletions

View File

@@ -207,7 +207,7 @@
},
"restDay": "Rest day",
"isRestDay": "Is rest day",
"isRestDayHelp": "Please consider that all sets are removed from rest days when saved",
"isRestDayHelp": "Please consider that all sets are removed from rest days when the form is saved",
"routineDays": "Days in routine",
"resultingRoutine": "Resulting routine",
"newDay": "New day",
@@ -710,7 +710,7 @@
"fitInWeekHelp": "Select if you want to fit the workout days into a week, you can add e.g. three days and mark this checkbox.",
"addSuperset": "Add superset",
"setHasProgression": "Set has progression",
"setHasProgressionWarning": "Please note that at the moment it is not possible to edit all settings for a set on the mobile application or configure the progression. ",
"setHasProgressionWarning": "Please note that at the moment it is not possible to edit all settings for a set on the mobile application or configure automatic progression. For now, please use the web application.",
"setHasNoExercises": "This set has no exercises yet!",
"contributeExercise": "Contribute an exercise",
"translation": "Translation",

View File

@@ -299,7 +299,8 @@ class RoutinesProvider with ChangeNotifier {
// ... and done
final routineIndex = _routines.indexWhere((r) => r.id == routineId);
_routines.replaceRange(routineIndex, routineIndex + 1, [routine]);
_routines[routineIndex] = routine;
// _routines.replaceRange(routineIndex, routineIndex + 1, [routine]);
notifyListeners();
return routine;
@@ -321,6 +322,8 @@ class RoutinesProvider with ChangeNotifier {
routine.toJson(),
baseProvider.makeUrl(_routinesUrlPath, id: routine.id),
);
await fetchAndSetRoutineFull(routine.id!);
notifyListeners();
}

View File

@@ -29,25 +29,31 @@ class RoutineScreen extends StatelessWidget {
static const routeName = '/routine-detail';
Future<Routine> _loadFullWorkout(BuildContext context, int routineId) {
return Provider.of<RoutinesProvider>(context, listen: false).fetchAndSetRoutineFull(routineId);
}
@override
Widget build(BuildContext context) {
final routine = ModalRoute.of(context)!.settings.arguments as Routine;
final routineArgs = ModalRoute.of(context)!.settings.arguments as Routine;
final provider = context.read<RoutinesProvider>();
return Scaffold(
appBar: RoutineDetailAppBar(routine),
appBar: RoutineDetailAppBar(routineArgs),
body: SingleChildScrollView(
child: Consumer<RoutinesProvider>(
builder: (context, value, child) => RoutineDetail(routineArgs),
),
),
);
return Scaffold(
appBar: RoutineDetailAppBar(routineArgs),
body: FutureBuilder(
future: _loadFullWorkout(context, routine.id!),
future: provider.fetchAndSetRoutineFull(routineArgs.id!),
builder: (context, snapshot) => ListView(
children: [
if (snapshot.connectionState == ConnectionState.waiting)
const BoxedProgressIndicator()
else
Consumer<RoutinesProvider>(
builder: (context, value, child) => RoutineDetail(routine),
builder: (context, value, child) => RoutineDetail(snapshot.data!),
),
],
),

View File

@@ -96,7 +96,7 @@ class RoutineDayWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DayHeader(day: _dayData),
..._dayData.slots.map((e) => getSlotDataRow(e)).toList(),
..._dayData.slots.map((e) => getSlotDataRow(e)),
],
),
),

View File

@@ -36,7 +36,9 @@ class RoutineDetail extends StatelessWidget {
padding: const EdgeInsets.all(15),
child: Text(_routine.description),
),
..._routine.dayDataCurrentIteration.map((dayData) => RoutineDayWidget(dayData)),
..._routine.dayDataCurrentIteration
.where((dayData) => dayData.day != null)
.map((dayData) => RoutineDayWidget(dayData)),
],
);
}

View File

@@ -25,31 +25,33 @@ import 'package:wger/screens/routine_screen.dart';
import 'package:wger/widgets/core/text_prompt.dart';
class WorkoutPlansList extends StatelessWidget {
final RoutinesProvider _workoutProvider;
final RoutinesProvider _routineProvider;
const WorkoutPlansList(this._workoutProvider);
const WorkoutPlansList(this._routineProvider);
@override
Widget build(BuildContext context) {
return RefreshIndicator(
onRefresh: () => _workoutProvider.fetchAndSetAllRoutinesFull(),
onRefresh: () => _routineProvider.fetchAndSetAllRoutinesFull(),
// onRefresh: () => _workoutProvider.fetchAndSetAllPlansSparse(),
child: _workoutProvider.items.isEmpty
child: _routineProvider.items.isEmpty
? const TextPrompt()
: ListView.builder(
padding: const EdgeInsets.all(10.0),
itemCount: _workoutProvider.items.length,
itemCount: _routineProvider.items.length,
itemBuilder: (context, index) {
final currentWorkout = _workoutProvider.items[index];
final currentWorkout = _routineProvider.items[index];
return Card(
child: ListTile(
onTap: () {
_workoutProvider.setCurrentPlan(currentWorkout.id!);
onTap: () async {
_routineProvider.setCurrentPlan(currentWorkout.id!);
final routine =
await _routineProvider.fetchAndSetRoutineFull(currentWorkout.id!);
Navigator.of(context).pushNamed(
RoutineScreen.routeName,
arguments: currentWorkout,
arguments: routine,
);
},
title: Text(currentWorkout.name),

View File

@@ -121,7 +121,7 @@
"license_author": null
}
],
"exercises": [
"translations": [
{
"id": 345,
"uuid": "c788d643-150a-4ac7-97ef-84643c6419bf",