develop #1

Merged
akhdanre merged 104 commits from develop into main 2025-07-10 12:38:53 +07:00
2 changed files with 53 additions and 19 deletions
Showing only changes of commit b575f75f6d - Show all commits

View File

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class CustomFloatingLoading {
static void showLoadingDialog(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false,
barrierColor: Colors.black.withValues(alpha: 0.3),
builder: (BuildContext context) {
return PopScope(
canPop: false,
child: const Center(
child: CircularProgressIndicator(),
),
);
},
);
}
static void hideLoadingDialog(BuildContext context) {
Navigator.of(context).pop();
}
}

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:quiz_app/app/const/enums/question_type.dart';
import 'package:quiz_app/app/routes/app_pages.dart';
import 'package:quiz_app/core/utils/custom_floating_loading.dart';
import 'package:quiz_app/core/utils/custom_notification.dart';
import 'package:quiz_app/core/utils/logger.dart';
import 'package:quiz_app/data/controllers/user_controller.dart';
@ -29,6 +30,8 @@ class QuizPreviewController extends GetxController {
RxBool isPublic = false.obs;
RxBool isLoading = false.obs;
late final List<QuestionData> data;
RxList<SubjectModel> subjects = <SubjectModel>[].obs;
@ -62,26 +65,31 @@ class QuizPreviewController extends GetxController {
}
Future<void> onSaveQuiz() async {
final title = titleController.text.trim();
final description = descriptionController.text.trim();
if (title.isEmpty || description.isEmpty) {
CustomNotification.error(
title: 'Error',
message: 'Judul dan deskripsi tidak boleh kosong!',
);
return;
}
if (data.length < 10) {
CustomNotification.error(
title: 'Error',
message: 'Jumlah soal harus 10 atau lebih',
);
return;
}
try {
if (isLoading.value) return;
final title = titleController.text.trim();
final description = descriptionController.text.trim();
if (title.isEmpty || description.isEmpty) {
CustomNotification.error(
title: 'Error',
message: 'Judul dan deskripsi tidak boleh kosong!',
);
return;
}
if (data.length < 10) {
CustomNotification.error(
title: 'Error',
message: 'Jumlah soal harus 10 atau lebih',
);
return;
}
isLoading.value = true;
CustomFloatingLoading.showLoadingDialog(Get.context!);
final now = DateTime.now();
final String formattedDate = "${now.day.toString().padLeft(2, '0')}-${now.month.toString().padLeft(2, '0')}-${now.year}";
@ -108,6 +116,9 @@ class QuizPreviewController extends GetxController {
}
} catch (e) {
logC.e(e);
} finally {
isLoading.value = false;
CustomFloatingLoading.hideLoadingDialog(Get.context!);
}
}