feat: adjust the quiz preview
This commit is contained in:
parent
128afe9ad6
commit
7d3f94dee1
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lucide_icons/lucide_icons.dart';
|
||||||
import 'package:quiz_app/app/const/colors/app_colors.dart';
|
import 'package:quiz_app/app/const/colors/app_colors.dart';
|
||||||
import 'package:quiz_app/data/models/quiz/quiz_listing_model.dart';
|
import 'package:quiz_app/data/models/quiz/quiz_listing_model.dart';
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ class QuizContainerComponent extends StatelessWidget {
|
||||||
onTap: () => onTap(data.quizId),
|
onTap: () => onTap(data.quizId),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(14),
|
padding: const EdgeInsets.all(14),
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.background,
|
color: AppColors.background,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
@ -50,7 +52,7 @@ class QuizContainerComponent extends StatelessWidget {
|
||||||
color: const Color(0xFF0052CC),
|
color: const Color(0xFF0052CC),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.school, color: Colors.white, size: 28),
|
child: const Icon(LucideIcons.box, color: Colors.white, size: 28),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,14 @@ class QuizItemWAComponent extends StatelessWidget {
|
||||||
Widget _buildAnswerIndicator(BuildContext context) {
|
Widget _buildAnswerIndicator(BuildContext context) {
|
||||||
final icon = isCorrect ? LucideIcons.checkCircle2 : LucideIcons.xCircle;
|
final icon = isCorrect ? LucideIcons.checkCircle2 : LucideIcons.xCircle;
|
||||||
final color = isCorrect ? AppColors.primaryBlue : Colors.red;
|
final color = isCorrect ? AppColors.primaryBlue : Colors.red;
|
||||||
|
final String userAnswerText;
|
||||||
|
|
||||||
|
if (userAnswer == null || userAnswer == -1) {
|
||||||
|
userAnswerText = "Tidak Menjawab";
|
||||||
|
} else {
|
||||||
|
userAnswerText = isOptionType ? options![userAnswer] : userAnswer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
final String userAnswerText = isOptionType ? options![userAnswer] : userAnswer.toString();
|
|
||||||
final String correctAnswerText = targetAnswer.toString();
|
final String correctAnswerText = targetAnswer.toString();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
|
|
@ -122,7 +122,7 @@ class QuizPreviewController extends GetxController {
|
||||||
logC.e(e);
|
logC.e(e);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
// CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class QuizPreviewController extends GetxController {
|
||||||
final q = entry.value;
|
final q = entry.value;
|
||||||
|
|
||||||
String typeString;
|
String typeString;
|
||||||
String answer = "";
|
dynamic answer;
|
||||||
List<String>? option;
|
List<String>? option;
|
||||||
|
|
||||||
switch (q.type) {
|
switch (q.type) {
|
||||||
|
@ -142,12 +142,12 @@ class QuizPreviewController extends GetxController {
|
||||||
break;
|
break;
|
||||||
case QuestionType.option:
|
case QuestionType.option:
|
||||||
typeString = 'option';
|
typeString = 'option';
|
||||||
answer = q.correctAnswerIndex.toString();
|
answer = q.correctAnswerIndex;
|
||||||
option = q.options?.map((o) => o.text).toList();
|
option = q.options?.map((o) => o.text).toList();
|
||||||
break;
|
break;
|
||||||
case QuestionType.trueOrFalse:
|
case QuestionType.trueOrFalse:
|
||||||
typeString = 'true_false';
|
typeString = 'true_false';
|
||||||
answer = q.answer ?? "";
|
answer = q.answer!.contains("true");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
typeString = 'fill_the_blank';
|
typeString = 'fill_the_blank';
|
||||||
|
|
Loading…
Reference in New Issue