This page highlights the important widgets and the steps you need to take to prepare for a workout set play. It also outlines the screen flows of the GOFA workout set experience.
final workoutItem = WorkoutItem(
poseName: "Squats"
);
BlocProvider.of<WorkoutSetBloc>(context).add(
WorkoutSetSetup(
workoutItem: <a data-footnote-ref href="#user-content-fn-1">workoutItem</a>,
totalSecondsAllowed: 30, // 30 seconds challenge
targetRepsToStart: null,
autoStopSetWhenRepsFulfilled: false,
),
);
Future<void> navigateToWorkoutSetScreen({
required BuildContext context,
}) async {
if (context.mounted) {
// navigate to WorkoutSetScreen
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WorkoutSetScreen(),
),
);
}
}
WorkoutSetBloc contains all the data
.1aojdhw1gqyq8.png&w=3840&q=75)
The following is the function navigateToPreviousDuringWorkout responsible for navigation to next screen after workout. The default behavior is to pop twice to get the the entry screen.
/// navigateToPreviousDuringWorkout , navigate to the previous screen during workout
Function(BuildContext)? navigateToPreviousDuringWorkout = (BuildContext context) {
Navigator.pop(context);
};You can use WorkoutSetSetup event to override the Back button navigation behavior.
BlocProvider.of<WorkoutSetBloc>(context).add(
WorkoutSetSetup(
...
navigateToPreviousDuringWorkout: (context) {
your navigation logic to previous screen...
},
),
);.0ci6gx02sr9bm.png&w=3840&q=75)
The following is the function navigateToNextAfterWorkout responsible for navigation to next screen after workout. The default behavior is to pop twice to get the the entry screen.
/// navigateToNextAfterWorkout, navigate to the next screen after workout
Function(BuildContext) navigateToNextAfterWorkout = (BuildContext context) {
// assuming this is called in WorkoutSetResultScreen, so pop twice to get to SelectPoseScreen
Navigator.pop(context);
Navigator.pop(context);
// if the SelectPoseScreen route name is known, can instead use this
// Navigator.popUntil(context, ModalRoute.withName('/select_pose'));
};You can use WorkoutSetSetup event to override the Next button navigation behavior.
BlocProvider.of<WorkoutSetBloc>(context).add(
WorkoutSetSetup(
...
navigateToNextAfterWorkout: (context) {
// for example, navigate to WorkoutAfterScreen
Navigator.pushNamedAndRemoveUntil(
context,
WorkoutAfterScreen.routeName,
ModalRoute.withName(SelectPoseScreen.routeName),
);
},
),
);The following is the function navigateToHomeAfterWorkout responsible for navigation to home screen after workout.
Since v1.0.5. The default behavior is (context) => false, that is, not showing "Back to Home" button.
You can use WorkoutSetSetup event to override the Next button navigation behavior.
BlocProvider.of<WorkoutSetBloc>(context).add(
WorkoutSetSetup(
...
navigateToHomeAfterWorkout: (context) {
// for example, pop until /home screen
Navigator.popUntil(context, ModalRoute.withName('/home'));
// or
// popUntil is used to pop all the screens until the `HomeScreen` is reached.
// Navigator.popUntil(context, (route) => route.isFirst);
},
// navigateToHomeAfterWorkout: (context) => false // to disable the button
),
);After exiting GOFA Widgets/Screen,
Widgets in "gofa_pose" to compose in your app