feat: adjusting on the quiz option

This commit is contained in:
akhdanre 2025-05-25 13:58:52 +07:00
parent 1e45cc271b
commit 2a93a9a371
2 changed files with 51 additions and 40 deletions

View File

@ -1,5 +1,5 @@
class APIEndpoint {
static const String baseUrl = "http://192.168.110.43:5000";
static const String baseUrl = "http://192.168.1.14:5000";
// static const String baseUrl = "http://103.193.178.121:5000";
static const String api = "$baseUrl/api";

View File

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:quiz_app/app/const/colors/app_colors.dart';
import 'package:quiz_app/component/global_text_field.dart';
import 'package:quiz_app/data/models/quiz/question/option_question_model.dart';
import 'package:quiz_app/data/models/quiz/question/true_false_question_model.dart';
import 'package:quiz_app/feature/quiz_play/controller/quiz_play_controller.dart';
class QuizPlayView extends GetView<QuizPlayController> {
@ -11,31 +12,35 @@ class QuizPlayView extends GetView<QuizPlayController> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF9FAFB),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Obx(() {
if (!controller.isStarting.value) {
return _buildCountdownScreen(context);
}
return PopScope(
canPop: false,
child: Scaffold(
backgroundColor: const Color(0xFFF9FAFB),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Obx(() {
if (!controller.isStarting.value) {
return _buildCountdownScreen(context);
}
return ListView(
children: [
_buildCustomAppBar(context),
const SizedBox(height: 20),
_buildProgressBar(),
const SizedBox(height: 20),
_buildQuestionIndicator(context),
const SizedBox(height: 12),
_buildQuestionText(),
const SizedBox(height: 30),
Expanded(child: _buildAnswerSection(context)),
_buildNextButton(context),
],
);
}),
return ListView(
children: [
_buildCustomAppBar(context),
const SizedBox(height: 20),
_buildProgressBar(),
const SizedBox(height: 20),
_buildQuestionIndicator(context),
const SizedBox(height: 12),
_buildQuestionText(),
const SizedBox(height: 30),
_buildAnswerSection(context),
Spacer(),
_buildNextButton(context),
],
);
}),
),
),
),
);
@ -305,22 +310,28 @@ class QuizPlayView extends GetView<QuizPlayController> {
final question = controller.currentQuestion;
if (question is OptionQuestion) {
return AnimatedList(
initialItemCount: question.options.length,
itemBuilder: (context, index, animation) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: animation,
curve: Interval(index * 0.1, 1.0, curve: Curves.easeOut),
)),
child: _buildOptionButton(question.options[index], index),
);
},
return ConstrainedBox(
constraints: BoxConstraints(
minHeight: 100,
maxHeight: 300,
),
child: AnimatedList(
initialItemCount: question.options.length,
itemBuilder: (context, index, animation) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: animation,
curve: Interval(index * 0.1, 1.0, curve: Curves.easeOut),
)),
child: _buildOptionButton(question.options[index], index),
);
},
),
);
} else if (question.type == 'true_false') {
} else if (question is TrueFalseQuestion) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [