fix: index restul quiz, translation lang and clean up
This commit is contained in:
parent
655103247e
commit
a7f5f98cf5
|
@ -135,5 +135,9 @@
|
||||||
"second": "{} s",
|
"second": "{} s",
|
||||||
"minute": "{} m",
|
"minute": "{} m",
|
||||||
"hour": "{} h"
|
"hour": "{} h"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"get_ready": "Get Ready",
|
||||||
|
"quiz_starting_soon" : "Quiz Starting Soon"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,5 +119,8 @@
|
||||||
"second": "{} d",
|
"second": "{} d",
|
||||||
"minute": "{} m",
|
"minute": "{} m",
|
||||||
"hour": "{} j"
|
"hour": "{} j"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"get_ready": "Bersiaplah",
|
||||||
|
"quiz_starting_soon": "Kuis akan segera dimulai"
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,5 +121,8 @@
|
||||||
"second": "{} s",
|
"second": "{} s",
|
||||||
"minute": "{} m",
|
"minute": "{} m",
|
||||||
"hour": "{} j"
|
"hour": "{} j"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"get_ready": "Bersedia",
|
||||||
|
"quiz_starting_soon": "Kuiz akan bermula sebentar lagi"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:quiz_app/core/endpoint/api_endpoint.dart';
|
import 'package:quiz_app/core/endpoint/api_endpoint.dart';
|
||||||
import 'package:quiz_app/core/utils/logger.dart';
|
import 'package:quiz_app/core/utils/logger.dart';
|
||||||
|
@ -82,7 +85,8 @@ class QuizService extends GetxService {
|
||||||
|
|
||||||
Future<BaseResponseModel<List<QuizListingModel>>?> populerQuiz({int page = 1, int amount = 3}) async {
|
Future<BaseResponseModel<List<QuizListingModel>>?> populerQuiz({int page = 1, int amount = 3}) async {
|
||||||
try {
|
try {
|
||||||
final response = await dio.get("${APIEndpoint.quizPopuler}?page=$page&limit=$amount");
|
Locale locale = Localizations.localeOf(Get.context!);
|
||||||
|
final response = await dio.get("${APIEndpoint.quizPopuler}?page=$page&limit=$amount&lang_code=${locale.languageCode}");
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
||||||
|
@ -102,7 +106,8 @@ class QuizService extends GetxService {
|
||||||
|
|
||||||
Future<BaseResponseModel<List<QuizListingModel>>?> recommendationQuiz({int page = 1, int amount = 3, String userId = ""}) async {
|
Future<BaseResponseModel<List<QuizListingModel>>?> recommendationQuiz({int page = 1, int amount = 3, String userId = ""}) async {
|
||||||
try {
|
try {
|
||||||
final response = await dio.get("${APIEndpoint.quizRecommendation}?page=$page&limit=$amount&user_id$userId");
|
Locale locale = Localizations.localeOf(Get.context!);
|
||||||
|
final response = await dio.get("${APIEndpoint.quizRecommendation}?page=$page&limit=$amount&user_id$userId&lang_code=${locale.languageCode}");
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
||||||
|
|
|
@ -16,11 +16,14 @@ class HistoryView extends GetView<HistoryController> {
|
||||||
backgroundColor: AppColors.background,
|
backgroundColor: AppColors.background,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(context.tr("history_title"), style: AppTextStyles.title.copyWith(fontSize: 24)),
|
Text(
|
||||||
|
context.tr("history_title"),
|
||||||
|
style: AppTextStyles.title.copyWith(fontSize: 24),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
context.tr("history_subtitle"),
|
context.tr("history_subtitle"),
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:quiz_app/app/const/text/text_style.dart';
|
||||||
import 'package:quiz_app/component/widget/container_skeleton_widget.dart';
|
import 'package:quiz_app/component/widget/container_skeleton_widget.dart';
|
||||||
import 'package:quiz_app/data/models/quiz/quiz_listing_model.dart';
|
import 'package:quiz_app/data/models/quiz/quiz_listing_model.dart';
|
||||||
import 'package:quiz_app/feature/library/controller/library_controller.dart';
|
import 'package:quiz_app/feature/library/controller/library_controller.dart';
|
||||||
|
import 'package:quiz_app/app/const/colors/app_colors.dart';
|
||||||
|
|
||||||
class LibraryView extends GetView<LibraryController> {
|
class LibraryView extends GetView<LibraryController> {
|
||||||
const LibraryView({super.key});
|
const LibraryView({super.key});
|
||||||
|
@ -11,7 +13,7 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF9FAFB),
|
backgroundColor: AppColors.background2,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||||
|
@ -20,19 +22,12 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
context.tr('library_title'),
|
context.tr('library_title'),
|
||||||
style: const TextStyle(
|
style: AppTextStyles.title.copyWith(fontSize: 24),
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 24,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
context.tr('library_description'),
|
context.tr('library_description'),
|
||||||
style: const TextStyle(
|
style: AppTextStyles.subtitle,
|
||||||
color: Colors.grey,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -50,7 +45,7 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
context.tr('no_quiz_available'),
|
context.tr('no_quiz_available'),
|
||||||
style: const TextStyle(color: Colors.grey, fontSize: 14),
|
style: AppTextStyles.caption,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +74,7 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
margin: const EdgeInsets.only(bottom: 16),
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: AppColors.background,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
|
@ -95,7 +90,7 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
width: 48,
|
width: 48,
|
||||||
height: 48,
|
height: 48,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF2563EB),
|
color: AppColors.primaryBlue,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.menu_book_rounded, color: Colors.white),
|
child: const Icon(Icons.menu_book_rounded, color: Colors.white),
|
||||||
|
@ -107,46 +102,42 @@ class LibraryView extends GetView<LibraryController> {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
quiz.title,
|
quiz.title,
|
||||||
style: const TextStyle(
|
style: AppTextStyles.body.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: Colors.black,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
quiz.description,
|
quiz.description,
|
||||||
style: const TextStyle(
|
style: AppTextStyles.caption,
|
||||||
color: Colors.grey,
|
|
||||||
fontSize: 12,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.calendar_today_rounded, size: 14, color: Colors.grey),
|
const Icon(Icons.calendar_today_rounded, size: 14, color: AppColors.softGrayText),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
controller.formatDate(quiz.date),
|
controller.formatDate(quiz.date),
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
style: AppTextStyles.dateTime,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
const Icon(Icons.list, size: 14, color: Colors.grey),
|
const Icon(Icons.list, size: 14, color: AppColors.softGrayText),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
context.tr('quiz_count_named', namedArgs: {'total': quiz.totalQuiz.toString()}),
|
context.tr('quiz_count_named', namedArgs: {'total': quiz.totalQuiz.toString()}),
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
style: AppTextStyles.dateTime,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
const Icon(Icons.access_time, size: 14, color: Colors.grey),
|
const Icon(Icons.access_time, size: 14, color: AppColors.softGrayText),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
controller.formatDuration(quiz.duration),
|
controller.formatDuration(quiz.duration),
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
style: AppTextStyles.dateTime,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -95,7 +95,7 @@ class QuizResultView extends GetView<QuizResultController> {
|
||||||
final parsed = _parseAnswer(question, answer.selectedAnswer);
|
final parsed = _parseAnswer(question, answer.selectedAnswer);
|
||||||
|
|
||||||
return QuizItemWAComponent(
|
return QuizItemWAComponent(
|
||||||
index: index,
|
index: question.index,
|
||||||
isCorrect: answer.isCorrect,
|
isCorrect: answer.isCorrect,
|
||||||
question: question.question,
|
question: question.question,
|
||||||
targetAnswer: parsed.targetAnswer,
|
targetAnswer: parsed.targetAnswer,
|
||||||
|
|
Loading…
Reference in New Issue