Merge branch 'exercise-bug' into 'master'
Refactor ExerciseProvider and update LevelCard and DownResultWidget UI See merge request profile-image/kedaireka/polinema-adapative-learning/mobile-adaptive-learning!10
This commit is contained in:
commit
cf967619e7
|
|
@ -253,10 +253,16 @@ class ExerciseProvider extends ChangeNotifier {
|
||||||
return _answers[index].isNotEmpty;
|
return _answers[index].isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _resetReviewState() {
|
||||||
|
_reviewData = null;
|
||||||
|
_reviewExercises = [];
|
||||||
|
}
|
||||||
|
|
||||||
// API methods
|
// API methods
|
||||||
Future<void> fetchExercises(String levelId) async {
|
Future<void> fetchExercises(String levelId) async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
_currentExerciseIndex = 0;
|
_currentExerciseIndex = 0;
|
||||||
|
_resetReviewState();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -460,17 +466,31 @@ class ExerciseProvider extends ChangeNotifier {
|
||||||
|
|
||||||
void updateFrom(ExerciseProvider? previous) {
|
void updateFrom(ExerciseProvider? previous) {
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
_exercises = previous._exercises;
|
// Only copy non-review related state
|
||||||
_matchingAnswers = previous._matchingAnswers;
|
if (!previous._reviewExercises.isNotEmpty) {
|
||||||
_answers = previous._answers;
|
// If we're not coming from a review state
|
||||||
_leftColors = previous._leftColors;
|
_exercises = previous._exercises;
|
||||||
_rightColors = previous._rightColors;
|
_matchingAnswers = previous._matchingAnswers;
|
||||||
_currentExerciseIndex = previous._currentExerciseIndex;
|
_answers = previous._answers;
|
||||||
_isLoading = previous._isLoading;
|
_leftColors = previous._leftColors;
|
||||||
_nameTopic = previous._nameTopic;
|
_rightColors = previous._rightColors;
|
||||||
_nameLevel = previous._nameLevel;
|
_currentExerciseIndex = previous._currentExerciseIndex;
|
||||||
_studentLearningId = previous._studentLearningId;
|
_nameTopic = previous._nameTopic;
|
||||||
_reviewData = previous._reviewData;
|
_nameLevel = previous._nameLevel;
|
||||||
|
_studentLearningId = previous._studentLearningId;
|
||||||
|
} else {
|
||||||
|
// If we are coming from a review state, reset everything
|
||||||
|
_exercises = [];
|
||||||
|
_matchingAnswers = {};
|
||||||
|
_answers = [];
|
||||||
|
_leftColors = [];
|
||||||
|
_rightColors = [];
|
||||||
|
_currentExerciseIndex = 0;
|
||||||
|
_nameTopic = '';
|
||||||
|
_nameLevel = '';
|
||||||
|
_studentLearningId = previous._studentLearningId;
|
||||||
|
}
|
||||||
|
_isLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class LevelCard extends StatelessWidget {
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (isCompleted)
|
if (isAllowed && score > 0)
|
||||||
Positioned(
|
Positioned(
|
||||||
right: -23,
|
right: -23,
|
||||||
bottom: 4,
|
bottom: 4,
|
||||||
|
|
@ -122,18 +122,14 @@ class LevelCard extends StatelessWidget {
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: CustomButton(
|
child: CustomButton(
|
||||||
text: isCompleted
|
text: isAllowed ? 'Learn Now' : 'Locked',
|
||||||
? 'Finished'
|
|
||||||
: (isAllowed ? 'Learn Now' : 'Locked'),
|
|
||||||
textStyle:
|
textStyle:
|
||||||
isAllowed ? null : AppTextStyles.disableTextStyle,
|
isAllowed ? null : AppTextStyles.disableTextStyle,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 36,
|
height: 36,
|
||||||
color: isCompleted
|
color: isAllowed
|
||||||
? Colors.green
|
? AppColors.yellowButtonColor
|
||||||
: (isAllowed
|
: AppColors.cardButtonColor,
|
||||||
? AppColors.yellowButtonColor
|
|
||||||
: AppColors.cardButtonColor),
|
|
||||||
onPressed: isAllowed
|
onPressed: isAllowed
|
||||||
? () {
|
? () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class DownResultWidget extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Level $nextLevel',
|
'$nextLevel',
|
||||||
style: AppTextStyles.redTextStyle
|
style: AppTextStyles.redTextStyle
|
||||||
.copyWith(fontSize: 20, fontWeight: FontWeight.w900),
|
.copyWith(fontSize: 20, fontWeight: FontWeight.w900),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user