diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index 0da7b79..b5831d8 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -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}", "create_room": "Create Room", "join_room": "Join Room", @@ -106,10 +112,28 @@ "close": "Close", "your_answer": "Your answer: {answer}", + "correct": "Correct", "correct_answer": "Correct answer: {answer}", "not_answered": "Not Answered", "seconds_suffix": "s", "quiz_type_option": "Multiple Choice", "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" + } } diff --git a/assets/translations/id-ID.json b/assets/translations/id-ID.json index da60f76..fdd2833 100644 --- a/assets/translations/id-ID.json +++ b/assets/translations/id-ID.json @@ -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}", "create_room": "Buat Ruangan", "join_room": "Gabung Ruang", diff --git a/lib/component/widget/quiz_item_wa_component.dart b/lib/component/widget/quiz_item_wa_component.dart index d56d070..04caebd 100644 --- a/lib/component/widget/quiz_item_wa_component.dart +++ b/lib/component/widget/quiz_item_wa_component.dart @@ -231,6 +231,7 @@ class _AnswerIndicator extends StatelessWidget { child: Text( // "Jawaban benar: " tr('correct_answer', namedArgs: {'answer': correctAnswerText}), + style: AppTextStyles.caption, softWrap: true, ), diff --git a/lib/feature/detail_quiz/view/detail_quix_view.dart b/lib/feature/detail_quiz/view/detail_quix_view.dart index b597eda..3c467ea 100644 --- a/lib/feature/detail_quiz/view/detail_quix_view.dart +++ b/lib/feature/detail_quiz/view/detail_quix_view.dart @@ -17,9 +17,9 @@ class DetailQuizView extends GetView { appBar: AppBar( backgroundColor: AppColors.background, elevation: 0, - title: const Text( - 'Detail Quiz', - style: TextStyle( + title: Text( + tr('quiz_detail_title'), + style: const TextStyle( color: AppColors.darkText, fontWeight: FontWeight.bold, ), @@ -32,7 +32,7 @@ class DetailQuizView extends GetView { padding: const EdgeInsets.all(20), child: Obx( () => controller.isLoading.value - ? Center(child: LoadingWidget()) + ? const Center(child: LoadingWidget()) : SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -67,19 +67,16 @@ class DetailQuizView extends GetView { const Icon(Icons.timer_rounded, size: 16, color: AppColors.softGrayText), const SizedBox(width: 6), Text( - '${controller.data.limitDuration ~/ 60} menit', + '${controller.data.limitDuration ~/ 60} ${tr('minutes_suffix')}', style: const TextStyle(fontSize: 12, color: AppColors.softGrayText), ), ], ), const SizedBox(height: 20), + + GlobalButton(text: tr('start_quiz'), onPressed: controller.goToPlayPage), 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 SizedBox(height: 20), @@ -113,7 +110,7 @@ class DetailQuizView extends GetView { border: Border.all(color: AppColors.borderLight), boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.05), + color: Colors.black.withOpacity(0.05), blurRadius: 6, offset: const Offset(2, 2), ), @@ -123,7 +120,7 @@ class DetailQuizView extends GetView { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Soal $index', + '${tr('question_label')} $index', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 16, @@ -147,17 +144,9 @@ class DetailQuizView extends GetView { color: AppColors.darkText, ), ), - // const SizedBox(height: 12), - // Text( - // 'Jawaban: ${question.targetAnswer}', - // style: const TextStyle( - // fontSize: 14, - // color: AppColors.softGrayText, - // ), - // ), const SizedBox(height: 8), Text( - 'Durasi: ${question.duration} detik', + '${tr('duration_label')}: ${question.duration} ${tr('seconds_suffix')}', style: const TextStyle( fontSize: 12, color: AppColors.softGrayText, diff --git a/lib/feature/history/view/detail_history_view.dart b/lib/feature/history/view/detail_history_view.dart index 413ca42..9818076 100644 --- a/lib/feature/history/view/detail_history_view.dart +++ b/lib/feature/history/view/detail_history_view.dart @@ -107,7 +107,7 @@ class DetailHistoryView extends GetView { children: [ _buildStatItem( icon: LucideIcons.checkCircle2, - label: context.tr('correct_answer'), + label: tr('correct'), value: "${quiz.totalCorrect}/${quiz.questionListings.length}", color: Colors.green, ), diff --git a/lib/feature/home/controller/home_controller.dart b/lib/feature/home/controller/home_controller.dart index ecdc870..3dec5fc 100644 --- a/lib/feature/home/controller/home_controller.dart +++ b/lib/feature/home/controller/home_controller.dart @@ -21,6 +21,8 @@ class HomeController extends GetxController { this._subjectService, ); + RxInt timeStatus = 1.obs; + Rx get userName => _userController.userName; Rx get userImage => _userController.userImage; @@ -31,6 +33,7 @@ class HomeController extends GetxController { @override void onInit() { _getRecomendationQuiz(); + _getGreetingStatusByTime(); loadSubjectData(); super.onInit(); } @@ -68,4 +71,18 @@ class HomeController extends GetxController { AppRoutes.listingQuizPage, 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; + } + } } diff --git a/lib/feature/home/view/component/user_gretings.dart b/lib/feature/home/view/component/user_gretings.dart index 7b55af5..147e58d 100644 --- a/lib/feature/home/view/component/user_gretings.dart +++ b/lib/feature/home/view/component/user_gretings.dart @@ -4,7 +4,13 @@ import 'package:flutter/material.dart'; class UserGretingsComponent extends StatelessWidget { final String userName; 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 Widget build(BuildContext context) { @@ -35,11 +41,11 @@ class UserGretingsComponent extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - context.tr("greeting_time"), - style: TextStyle(fontWeight: FontWeight.bold), + tr(_getGreetingKey(greatingStatus)), + style: const TextStyle(fontWeight: FontWeight.bold), ), Text( - context.tr("greeting_user", namedArgs: {"user": userName}), + tr("greeting_user", namedArgs: {"user": userName}), 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 + } + } } diff --git a/lib/feature/home/view/home_page.dart b/lib/feature/home/view/home_page.dart index d815de6..ce6a2cb 100644 --- a/lib/feature/home/view/home_page.dart +++ b/lib/feature/home/view/home_page.dart @@ -27,6 +27,7 @@ class HomeView extends GetView { () => UserGretingsComponent( userName: controller.userName.value, userImage: controller.userImage.value, + greatingStatus: controller.timeStatus.value, ), ), const SizedBox(height: 20),