fix: logic on the interface greating time for user
This commit is contained in:
parent
c84133a372
commit
661930d2bd
|
@ -1,5 +1,11 @@
|
||||||
{
|
{
|
||||||
"greeting_time": "Good Afternoon",
|
"greeting_time": {
|
||||||
|
"morning": "Good Morning",
|
||||||
|
"afternoon": "Good Afternoon",
|
||||||
|
"evening": "Good Evening",
|
||||||
|
"night": "Good Night"
|
||||||
|
},
|
||||||
|
|
||||||
"greeting_user": "Hello {user}",
|
"greeting_user": "Hello {user}",
|
||||||
"create_room": "Create Room",
|
"create_room": "Create Room",
|
||||||
"join_room": "Join Room",
|
"join_room": "Join Room",
|
||||||
|
@ -106,10 +112,28 @@
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
|
|
||||||
"your_answer": "Your answer: {answer}",
|
"your_answer": "Your answer: {answer}",
|
||||||
|
"correct": "Correct",
|
||||||
"correct_answer": "Correct answer: {answer}",
|
"correct_answer": "Correct answer: {answer}",
|
||||||
"not_answered": "Not Answered",
|
"not_answered": "Not Answered",
|
||||||
"seconds_suffix": "s",
|
"seconds_suffix": "s",
|
||||||
"quiz_type_option": "Multiple Choice",
|
"quiz_type_option": "Multiple Choice",
|
||||||
"quiz_type_true_false": "True or False",
|
"quiz_type_true_false": "True or False",
|
||||||
"quiz_type_fill_the_blank": "Fill in the Blank"
|
"quiz_type_fill_the_blank": "Fill in the Blank",
|
||||||
|
|
||||||
|
"quiz_detail_title": "Quiz Detail",
|
||||||
|
"question_label": "Question",
|
||||||
|
"duration_label": "Duration",
|
||||||
|
"minutes_suffix": "minutes",
|
||||||
|
"start_quiz": "Start Quiz",
|
||||||
|
|
||||||
|
"duration": {
|
||||||
|
"second": "{} second",
|
||||||
|
"minute": "{} minute",
|
||||||
|
"hour": "{} hour"
|
||||||
|
},
|
||||||
|
"duration_suffix": {
|
||||||
|
"second": "{} s",
|
||||||
|
"minute": "{} m",
|
||||||
|
"hour": "{} h"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
{
|
{
|
||||||
"greeting_time": "Selamat Siang",
|
"greeting_time": {
|
||||||
|
"morning": "Selamat Pagi",
|
||||||
|
"afternoon": "Selamat Siang",
|
||||||
|
"evening": "Selamat Sore",
|
||||||
|
"night": "Selamat Malam"
|
||||||
|
},
|
||||||
|
|
||||||
"greeting_user": "Halo {user}",
|
"greeting_user": "Halo {user}",
|
||||||
"create_room": "Buat Ruangan",
|
"create_room": "Buat Ruangan",
|
||||||
"join_room": "Gabung Ruang",
|
"join_room": "Gabung Ruang",
|
||||||
|
|
|
@ -231,6 +231,7 @@ class _AnswerIndicator extends StatelessWidget {
|
||||||
child: Text(
|
child: Text(
|
||||||
// "Jawaban benar: <answer>"
|
// "Jawaban benar: <answer>"
|
||||||
tr('correct_answer', namedArgs: {'answer': correctAnswerText}),
|
tr('correct_answer', namedArgs: {'answer': correctAnswerText}),
|
||||||
|
|
||||||
style: AppTextStyles.caption,
|
style: AppTextStyles.caption,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
),
|
),
|
||||||
|
|
|
@ -17,9 +17,9 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: AppColors.background,
|
backgroundColor: AppColors.background,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
title: const Text(
|
title: Text(
|
||||||
'Detail Quiz',
|
tr('quiz_detail_title'),
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.darkText,
|
color: AppColors.darkText,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
|
@ -32,7 +32,7 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => controller.isLoading.value
|
() => controller.isLoading.value
|
||||||
? Center(child: LoadingWidget())
|
? const Center(child: LoadingWidget())
|
||||||
: SingleChildScrollView(
|
: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
@ -67,19 +67,16 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
const Icon(Icons.timer_rounded, size: 16, color: AppColors.softGrayText),
|
const Icon(Icons.timer_rounded, size: 16, color: AppColors.softGrayText),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Text(
|
Text(
|
||||||
'${controller.data.limitDuration ~/ 60} menit',
|
'${controller.data.limitDuration ~/ 60} ${tr('minutes_suffix')}',
|
||||||
style: const TextStyle(fontSize: 12, color: AppColors.softGrayText),
|
style: const TextStyle(fontSize: 12, color: AppColors.softGrayText),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
GlobalButton(text: tr('start_quiz'), onPressed: controller.goToPlayPage),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
GlobalButton(text: "Kerjakan", onPressed: controller.goToPlayPage),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
// GlobalButton(text: "buat ruangan", onPressed: () {}),
|
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
const Divider(thickness: 1.2, color: AppColors.borderLight),
|
const Divider(thickness: 1.2, color: AppColors.borderLight),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
@ -113,7 +110,7 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
border: Border.all(color: AppColors.borderLight),
|
border: Border.all(color: AppColors.borderLight),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withValues(alpha: 0.05),
|
color: Colors.black.withOpacity(0.05),
|
||||||
blurRadius: 6,
|
blurRadius: 6,
|
||||||
offset: const Offset(2, 2),
|
offset: const Offset(2, 2),
|
||||||
),
|
),
|
||||||
|
@ -123,7 +120,7 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Soal $index',
|
'${tr('question_label')} $index',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
@ -147,17 +144,9 @@ class DetailQuizView extends GetView<DetailQuizController> {
|
||||||
color: AppColors.darkText,
|
color: AppColors.darkText,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// const SizedBox(height: 12),
|
|
||||||
// Text(
|
|
||||||
// 'Jawaban: ${question.targetAnswer}',
|
|
||||||
// style: const TextStyle(
|
|
||||||
// fontSize: 14,
|
|
||||||
// color: AppColors.softGrayText,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Durasi: ${question.duration} detik',
|
'${tr('duration_label')}: ${question.duration} ${tr('seconds_suffix')}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColors.softGrayText,
|
color: AppColors.softGrayText,
|
||||||
|
|
|
@ -107,7 +107,7 @@ class DetailHistoryView extends GetView<DetailHistoryController> {
|
||||||
children: [
|
children: [
|
||||||
_buildStatItem(
|
_buildStatItem(
|
||||||
icon: LucideIcons.checkCircle2,
|
icon: LucideIcons.checkCircle2,
|
||||||
label: context.tr('correct_answer'),
|
label: tr('correct'),
|
||||||
value: "${quiz.totalCorrect}/${quiz.questionListings.length}",
|
value: "${quiz.totalCorrect}/${quiz.questionListings.length}",
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
),
|
),
|
||||||
|
|
|
@ -21,6 +21,8 @@ class HomeController extends GetxController {
|
||||||
this._subjectService,
|
this._subjectService,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RxInt timeStatus = 1.obs;
|
||||||
|
|
||||||
Rx<String> get userName => _userController.userName;
|
Rx<String> get userName => _userController.userName;
|
||||||
Rx<String?> get userImage => _userController.userImage;
|
Rx<String?> get userImage => _userController.userImage;
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ class HomeController extends GetxController {
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
_getRecomendationQuiz();
|
_getRecomendationQuiz();
|
||||||
|
_getGreetingStatusByTime();
|
||||||
loadSubjectData();
|
loadSubjectData();
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
@ -68,4 +71,18 @@ class HomeController extends GetxController {
|
||||||
AppRoutes.listingQuizPage,
|
AppRoutes.listingQuizPage,
|
||||||
arguments: {"page": page, "id": subjectId, "subject_name": subjecName},
|
arguments: {"page": page, "id": subjectId, "subject_name": subjecName},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void _getGreetingStatusByTime() {
|
||||||
|
final hour = DateTime.now().hour;
|
||||||
|
|
||||||
|
if (hour >= 5 && hour < 12) {
|
||||||
|
timeStatus.value = 1;
|
||||||
|
} else if (hour >= 12 && hour < 15) {
|
||||||
|
timeStatus.value = 2;
|
||||||
|
} else if (hour >= 15 && hour < 18) {
|
||||||
|
timeStatus.value = 3;
|
||||||
|
} else {
|
||||||
|
timeStatus.value = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,13 @@ import 'package:flutter/material.dart';
|
||||||
class UserGretingsComponent extends StatelessWidget {
|
class UserGretingsComponent extends StatelessWidget {
|
||||||
final String userName;
|
final String userName;
|
||||||
final String? userImage;
|
final String? userImage;
|
||||||
const UserGretingsComponent({super.key, required this.userName, required this.userImage});
|
final int greatingStatus;
|
||||||
|
const UserGretingsComponent({
|
||||||
|
super.key,
|
||||||
|
required this.userName,
|
||||||
|
required this.userImage,
|
||||||
|
required this.greatingStatus,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -35,11 +41,11 @@ class UserGretingsComponent extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
context.tr("greeting_time"),
|
tr(_getGreetingKey(greatingStatus)),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
context.tr("greeting_user", namedArgs: {"user": userName}),
|
tr("greeting_user", namedArgs: {"user": userName}),
|
||||||
style: TextStyle(fontWeight: FontWeight.w500),
|
style: TextStyle(fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -52,4 +58,19 @@ class UserGretingsComponent extends StatelessWidget {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getGreetingKey(int status) {
|
||||||
|
switch (status) {
|
||||||
|
case 1:
|
||||||
|
return 'greeting_time.morning';
|
||||||
|
case 2:
|
||||||
|
return 'greeting_time.afternoon';
|
||||||
|
case 3:
|
||||||
|
return 'greeting_time.evening';
|
||||||
|
case 4:
|
||||||
|
return 'greeting_time.night';
|
||||||
|
default:
|
||||||
|
return 'greeting_time.morning'; // fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class HomeView extends GetView<HomeController> {
|
||||||
() => UserGretingsComponent(
|
() => UserGretingsComponent(
|
||||||
userName: controller.userName.value,
|
userName: controller.userName.value,
|
||||||
userImage: controller.userImage.value,
|
userImage: controller.userImage.value,
|
||||||
|
greatingStatus: controller.timeStatus.value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
Loading…
Reference in New Issue