diff --git a/app/lib/features/main/presentation/pages/_pages.dart b/app/lib/features/main/presentation/pages/_pages.dart index f2c0d12a..eb67dc38 100644 --- a/app/lib/features/main/presentation/pages/_pages.dart +++ b/app/lib/features/main/presentation/pages/_pages.dart @@ -1,25 +1,16 @@ -import 'dart:io'; - import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:go_router/go_router.dart'; import 'package:google_sign_in/google_sign_in.dart'; -import 'package:intl/intl.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:yaml/yaml.dart'; -import '../../../../core/bases/enum/button_type.dart'; import '../../../../core/bases/widgets/atoms/button.dart'; import '../../../../core/bases/widgets/layout/bebras_scaffold.dart'; import '../../../../core/bases/widgets/layout/bottom_navbar.dart'; -import '../../../../core/constants/assets.dart'; import '../../../../core/theme/font_theme.dart'; import '../../../../services/firebase_service.dart'; -import '../bloc/home_cubit.dart'; -part 'home_page.dart'; +part 'policy_page.dart'; part 'setting_page.dart'; diff --git a/app/lib/features/main/presentation/pages/v2/clip_path.dart b/app/lib/features/main/presentation/pages/clip_path.dart similarity index 100% rename from app/lib/features/main/presentation/pages/v2/clip_path.dart rename to app/lib/features/main/presentation/pages/clip_path.dart diff --git a/app/lib/features/main/presentation/pages/v2/delete_page.dart b/app/lib/features/main/presentation/pages/delete_page.dart similarity index 98% rename from app/lib/features/main/presentation/pages/v2/delete_page.dart rename to app/lib/features/main/presentation/pages/delete_page.dart index fd1825fb..67f18c7a 100644 --- a/app/lib/features/main/presentation/pages/v2/delete_page.dart +++ b/app/lib/features/main/presentation/pages/delete_page.dart @@ -1,10 +1,9 @@ // part of '_pages.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; +import '../../../../core/bases/widgets/layout/bebras_scaffold.dart'; class DeleteAccountPage extends StatefulWidget { const DeleteAccountPage({super.key}); diff --git a/app/lib/features/main/presentation/pages/home_page.dart b/app/lib/features/main/presentation/pages/home_page.dart deleted file mode 100644 index fc7926e0..00000000 --- a/app/lib/features/main/presentation/pages/home_page.dart +++ /dev/null @@ -1,158 +0,0 @@ -part of '_pages.dart'; - -class HomePage extends StatefulWidget { - const HomePage({super.key}); - - @override - State createState() => _HomePageState(); -} - -class Course { - String title; - String description; - - Course(this.title, this.description); -} - -class _HomePageState extends State { - String version = ''; - - @override - void initState() { - context.read().fetchUser(); - _loadVersion(); - super.initState(); - } - - Future _loadVersion() async { - try { - final yamlMap = - loadYaml(await rootBundle.loadString('pubspec.yaml')); - final versionWithBuildNumber = - yamlMap['version'] as String; - final parts = versionWithBuildNumber.split('+'); - setState(() { - version = parts[0]; - }); - } catch (e) { - print('Error loading version: $e'); - } - } - - @override - Widget build(BuildContext context) { - return BebrasScaffold( - body: SingleChildScrollView( - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.all(32), - child: Column( - children: [ - Image.asset( - Assets.bebrasPandaiText, - ), - const SizedBox( - height: 40, - ), - BlocBuilder(builder: (context, state) { - if (state is HomeSuccess) { - return RichText( - text: TextSpan( - text: 'Selamat Datang\n', - style: FontTheme.blackTitle(), - children: [ - TextSpan( - text: toBeginningOfSentenceCase( - '${state.user.name}!', - ), - style: FontTheme.blackTitleBold()), - ], - ), - ); - } - return Container(); - }), - const SizedBox( - height: 30, - ), - Button( - onTap: () async { - final url = Uri.parse( - 'https://bebras.or.id/v3/bebras-indonesia-challenge-2023/', - ); - if (!await launchUrl(url)) { - throw Exception('Could not launch $url'); - } - }, - customButtonColor: Colors.blue, - customTextColor: Colors.white, - text: 'ℹ️ Tentang Tantangan Bebras ℹ️', - ), - const SizedBox( - height: 25, - ), - Button( - buttonType: ButtonType.primary, - onTap: () async { - await context.push('/material'); - }, - text: 'Lihat / Cetak Materi', - ), - const SizedBox( - height: 25, - ), - Button( - buttonType: ButtonType.primary, - onTap: () async { - await context.push('/quiz_registration'); - }, - text: 'Ikut Latihan Mingguan', - ), - const SizedBox( - height: 25, - ), - Button( - onTap: () async { - await context.push('/setting'); - }, - customButtonColor: Colors.grey, - customTextColor: Colors.white, - text: 'Pengaturan', - ), - SizedBox( - height: MediaQuery.of(context).size.height - 640, - ), - InkWell( - onTap: () async { - final url = Uri.parse( - 'https://tlx.toki.id/', - ); - if (!await launchUrl(url)) { - throw Exception('Could not launch $url'); - } - }, - child: Center( - child: Text( - 'From Ikatan Alumni TOKI with ❤️', - textAlign: TextAlign.center, - style: FontTheme.greyNormal14(), - ), - ), - ), - Center( - child: Text( - 'V $version', - textAlign: TextAlign.center, - style: FontTheme.greyNormal14(), - ), - ), - ], - ), - ), - ], - ), - ), - ); - } -} diff --git a/app/lib/features/main/presentation/pages/v2/policy_page.dart b/app/lib/features/main/presentation/pages/policy_page.dart similarity index 58% rename from app/lib/features/main/presentation/pages/v2/policy_page.dart rename to app/lib/features/main/presentation/pages/policy_page.dart index 78ddee2d..b7fe2a76 100644 --- a/app/lib/features/main/presentation/pages/v2/policy_page.dart +++ b/app/lib/features/main/presentation/pages/policy_page.dart @@ -1,9 +1,4 @@ -// part of '_pages.dart'; - -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; - -import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; +part of '_pages.dart'; class PrivacyPolicyPage extends StatefulWidget { const PrivacyPolicyPage({super.key}); @@ -59,8 +54,9 @@ class _PrivacyPolicyPageState extends State { 'Sebagai pengguna Bebras Pandai, Anda memiliki hak untuk mengetahui bagaimana data Anda diambil, digunakan, dan dijaga.' 'Mohon luangkan waktu sejenak untuk membaca kebijakan privasi kami:', textAlign: TextAlign.justify, - style: - TextStyle(fontSize: 12,)), + style: TextStyle( + fontSize: 12, + )), ) ], ), @@ -111,38 +107,34 @@ class _PrivacyPolicyPageState extends State { const SizedBox( height: 5, ), - Column( - children: [ + Column(children: [ + Container( + child: Row(children: [ Container( - child: Row( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 5), - height: 30, - width: 30, - child: Center( - child: const Text( - '2', - style: TextStyle( - fontWeight: FontWeight.w600, color: Colors.white), - ), + margin: const EdgeInsets.symmetric(horizontal: 5), + height: 30, + width: 30, + child: Center( + child: const Text( + '2', + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.white), ), - decoration: BoxDecoration( - color: Colors.blue[300], - shape: BoxShape.circle, - )), - Flexible( - child: Text('Penggunaan Informasi', - style: TextStyle( - fontWeight: FontWeight.w600, - ))) - ] - ) - ), - const SizedBox( - height: 5, - ), - Column(children: [ + ), + decoration: BoxDecoration( + color: Colors.blue[300], + shape: BoxShape.circle, + )), + Flexible( + child: Text('Penggunaan Informasi', + style: TextStyle( + fontWeight: FontWeight.w600, + ))) + ])), + const SizedBox( + height: 5, + ), + Column(children: [ Container( child: const Text( 'Informasi yang kami kumpulkan digunakan untuk menyajikan konten yang sesuai dengan minat Anda, memantau kinerja aplikasi, dan memastikan keamanan akun Anda. ' @@ -153,43 +145,38 @@ class _PrivacyPolicyPageState extends State { fontWeight: FontWeight.w400, ))) ]) - ] - ), + ]), const SizedBox( height: 5, ), - Column( - children: [ + Column(children: [ + Container( + child: Row(children: [ Container( - child: Row( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 5), - height: 30, - width: 30, - child: Center( - child: const Text( - '3', - style: TextStyle( - fontWeight: FontWeight.w600, color: Colors.white), - ), + margin: const EdgeInsets.symmetric(horizontal: 5), + height: 30, + width: 30, + child: Center( + child: const Text( + '3', + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.white), ), - decoration: BoxDecoration( - color: Colors.blue[300], - shape: BoxShape.circle, - )), - Flexible( - child: Text('Keamanan Data', - style: TextStyle( - fontWeight: FontWeight.w600, - ))) - ] - ) - ), - const SizedBox( - height: 5, - ), - Column(children: [ + ), + decoration: BoxDecoration( + color: Colors.blue[300], + shape: BoxShape.circle, + )), + Flexible( + child: Text('Keamanan Data', + style: TextStyle( + fontWeight: FontWeight.w600, + ))) + ])), + const SizedBox( + height: 5, + ), + Column(children: [ Container( child: const Text( 'Keamanan data Anda adalah prioritas kami.' @@ -200,43 +187,38 @@ class _PrivacyPolicyPageState extends State { fontWeight: FontWeight.w400, ))) ]) - ] - ), + ]), const SizedBox( height: 5, ), - Column( - children: [ + Column(children: [ + Container( + child: Row(children: [ Container( - child: Row( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 5), - height: 30, - width: 30, - child: Center( - child: const Text( - '4', - style: TextStyle( - fontWeight: FontWeight.w600, color: Colors.white), - ), + margin: const EdgeInsets.symmetric(horizontal: 5), + height: 30, + width: 30, + child: Center( + child: const Text( + '4', + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.white), ), - decoration: BoxDecoration( - color: Colors.blue[300], - shape: BoxShape.circle, - )), - Flexible( - child: Text('Perubahan Kebijakan Privasi', - style: TextStyle( - fontWeight: FontWeight.w600, - ))) - ] - ) - ), - const SizedBox( - height: 5, - ), - Column(children: [ + ), + decoration: BoxDecoration( + color: Colors.blue[300], + shape: BoxShape.circle, + )), + Flexible( + child: Text('Perubahan Kebijakan Privasi', + style: TextStyle( + fontWeight: FontWeight.w600, + ))) + ])), + const SizedBox( + height: 5, + ), + Column(children: [ Container( child: const Text( 'Kebijakan Privasi kami dapat diperbarui dari waktu ke waktu.' @@ -247,43 +229,38 @@ class _PrivacyPolicyPageState extends State { fontWeight: FontWeight.w400, ))) ]) - ] - ), + ]), const SizedBox( height: 5, ), - Column( - children: [ + Column(children: [ + Container( + child: Row(children: [ Container( - child: Row( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 5), - height: 30, - width: 30, - child: Center( - child: const Text( - '5', - style: TextStyle( - fontWeight: FontWeight.w600, color: Colors.white), - ), + margin: const EdgeInsets.symmetric(horizontal: 5), + height: 30, + width: 30, + child: Center( + child: const Text( + '5', + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.white), ), - decoration: BoxDecoration( - color: Colors.blue[300], - shape: BoxShape.circle, - )), - Flexible( - child: Text('Kontak Kami', - style: TextStyle( - fontWeight: FontWeight.w600, - ))) - ] - ) - ), - const SizedBox( - height: 5, - ), - Column(children: [ + ), + decoration: BoxDecoration( + color: Colors.blue[300], + shape: BoxShape.circle, + )), + Flexible( + child: Text('Kontak Kami', + style: TextStyle( + fontWeight: FontWeight.w600, + ))) + ])), + const SizedBox( + height: 5, + ), + Column(children: [ Container( child: const Text( 'Jika Anda memiliki pertanyaan atau kekhawatiran tentang kebijakan privasi kami, jangan ragu untuk menghubungi tim dukungan kami di support@bebraspandai.com.' @@ -294,8 +271,7 @@ class _PrivacyPolicyPageState extends State { fontWeight: FontWeight.w400, ))) ]) - ] - ), + ]), ], ), ), diff --git a/app/lib/features/main/presentation/pages/setting_page.dart b/app/lib/features/main/presentation/pages/setting_page.dart index 249dcb99..5ba5c7c7 100644 --- a/app/lib/features/main/presentation/pages/setting_page.dart +++ b/app/lib/features/main/presentation/pages/setting_page.dart @@ -103,26 +103,25 @@ class _SettingPageState extends State { DateTime? backButtonPressTime; String exitWarning = 'Tekan sekali lagi untuk keluar'; - Future onDidPop() { - final now = DateTime.now(); - final backButtonHasNotBeenPressedOrSnackBarHasBeenClosed = - backButtonPressTime == null || - now.difference(backButtonPressTime!) > const Duration(seconds: 2); + Future onDidPop() { + final now = DateTime.now(); + final backButtonHasNotBeenPressedOrSnackBarHasBeenClosed = + backButtonPressTime == null || + now.difference(backButtonPressTime!) > const Duration(seconds: 2); - if (backButtonHasNotBeenPressedOrSnackBarHasBeenClosed) { - backButtonPressTime = now; - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(exitWarning), - )); - return Future.value(false); - } - - return Future.value(true); + if (backButtonHasNotBeenPressedOrSnackBarHasBeenClosed) { + backButtonPressTime = now; + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text(exitWarning), + )); + return Future.value(false); } + return Future.value(true); + } + @override Widget build(BuildContext context) { - return BebrasScaffold( body: PopScope( canPop: false, @@ -227,55 +226,64 @@ class _SettingPageState extends State { ), ), ), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, vertical: 10), - margin: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - color: const Color(0x0A1BB8E1), - borderRadius: BorderRadius.circular(12), - ), - child: Row( - children: [ - Container( - margin: - const EdgeInsets.symmetric(horizontal: 12), - height: 50, - width: 50, - decoration: const BoxDecoration( - color: Color(0x1F1BB8E1), - shape: BoxShape.circle, - // borderRadius: BorderRadius.circular(20), - ), - child: Container( - alignment: Alignment.center, - child: SvgPicture.asset( - 'assets/icon/privacy.svg', - height: 24, - width: 24, + InkWell( + onTap: () async { + await context.push( + Uri( + path: '/policy', + ).toString(), + ); + }, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, vertical: 10), + margin: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + color: const Color(0x0A1BB8E1), + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + Container( + margin: const EdgeInsets.symmetric( + horizontal: 12), + height: 50, + width: 50, + decoration: const BoxDecoration( + color: Color(0x1F1BB8E1), + shape: BoxShape.circle, + // borderRadius: BorderRadius.circular(20), + ), + child: Container( + alignment: Alignment.center, + child: SvgPicture.asset( + 'assets/icon/privacy.svg', + height: 24, + width: 24, + ), ), ), - ), - Flexible( - child: Container( - width: double.infinity, - child: const Text( - 'Kebijakan Privasi', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w500, - color: Colors.black, + Flexible( + child: Container( + width: double.infinity, + child: const Text( + 'Kebijakan Privasi', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + color: Colors.black, + ), ), ), ), - ), - const Icon( - Icons.chevron_right, - size: 28, - color: Colors.black, - ), - ], + const Icon( + Icons.chevron_right, + size: 28, + color: Colors.black, + ), + ], + ), ), ), InkWell( diff --git a/app/lib/features/main/presentation/pages/v2/_pages.dart b/app/lib/features/main/presentation/pages/v2/_pages.dart deleted file mode 100644 index 6b0606fb..00000000 --- a/app/lib/features/main/presentation/pages/v2/_pages.dart +++ /dev/null @@ -1,22 +0,0 @@ -// import 'package:carousel_slider/carousel_slider.dart'; -// import 'package:firebase_auth/firebase_auth.dart'; -import 'package:flutter/material.dart'; -// import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:go_router/go_router.dart'; -// import 'package:google_sign_in/google_sign_in.dart'; -// import 'package:intl/intl.dart'; -// import 'package:url_launcher/url_launcher.dart'; - -import '../../../../../core/bases/widgets/atoms/button.dart'; -import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; -import '../../../../../core/constants/assets.dart'; -import '../../../../../core/bases/widgets/layout/bottom_navbar.dart'; -// import '../../../../../core/theme/font_theme.dart'; -// import '../../../../../services/firebase_service.dart'; -// import '../../../../material/menu/presentation/pages/_pages.dart'; -// import '../../bloc/home_cubit.dart'; -// import 'clip_path.dart'; - -part 'home_page.dart'; -// part 'setting_page.dart'; diff --git a/app/lib/features/main/presentation/pages/v2/home_page.dart b/app/lib/features/main/presentation/pages/v2/home_page.dart deleted file mode 100644 index f5b87a67..00000000 --- a/app/lib/features/main/presentation/pages/v2/home_page.dart +++ /dev/null @@ -1,170 +0,0 @@ -part of '_pages.dart'; - -class HomePageV2 extends StatefulWidget { - const HomePageV2({super.key}); - - @override - State createState() => _HomePageV2State(); -} - -class _HomePageV2State extends State { - String version = ''; - - @override - void initState() { - super.initState(); - } - - Future showModal() async { - return showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return Container( - height: 260, - width: double.infinity, - color: Colors.white, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox( - height: 40, - ), - Container( - margin: const EdgeInsets.only(left: 20), - child: const Text( - 'Ayo pilih latihanmu!', - textAlign: TextAlign.left, - style: - TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - ), - const SizedBox( - height: 25, - ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 40), - width: double.infinity, - child: const Button( - customButtonColor: const Color(0xFF1BB8E1), - customTextColor: Colors.white, - text: 'Unduh Latihan Minggu Ini', - ), - ), - const SizedBox( - height: 20, - ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 40), - width: double.infinity, - child: const Button( - customTextColor: const Color(0xFF1BB8E1), - customButtonColor: const Color(0x1F1BB8E1), - text: 'Latihan Minggu Depan', - ), - ), - ], - ), - ); - }, - ); - }, - ).whenComplete(() => null); - } - - @override - Widget build(BuildContext context) { - return BebrasScaffold( - body: Container( - color: const Color(0xFF1BB8E1), - child: Stack( - children: [ - Column( - children: [ - const SizedBox( - height: 60, - ), - Container( - alignment: Alignment.center, - child: ClipRRect( - borderRadius: BorderRadius.circular(24), - child: Image.asset( - Assets.bLogo, - height: 150, - ), - ), - ), - ], - ), - Align( - alignment: Alignment.bottomCenter, - child: Container( - height: 300, - width: double.infinity, - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(42), - topRight: Radius.circular(42), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'Ayo mulai latihanmu!', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 18, - ), - ), - const SizedBox( - height: 30, - ), - SizedBox( - width: 230, - child: Button( - customTextColor: Colors.white, - customButtonColor: Color(0xFF1BB8E1), - fontSize: 14, - innerVerticalPadding: 14, - onTap: () async { - await showModal(); - }, - text: 'Daftar Latihan', - ), - ), - const SizedBox( - height: 10, - ), - const SizedBox( - width: 230, - child: Button( - customTextColor: const Color(0xFF1BB8E1), - customButtonColor: const Color(0x1F1BB8E1), - fontSize: 14, - innerVerticalPadding: 14, - text: 'Riwayat Latihan', - ), - ), - ], - ), - ), - ), - ], - ), - ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - floatingActionButton: FloatingActionButton( - onPressed: () { - context.go('/quiz_registration'); - }, - child: const FaIcon(FontAwesomeIcons.graduationCap), - ), - bottomNavigationBar: const BottomNavBar( - currentIndex: 2, - ), - ); - } -} diff --git a/app/lib/features/main/presentation/pages/v2/setting_page.dart b/app/lib/features/main/presentation/pages/v2/setting_page.dart deleted file mode 100644 index 2fc853b7..00000000 --- a/app/lib/features/main/presentation/pages/v2/setting_page.dart +++ /dev/null @@ -1,495 +0,0 @@ -// part of '_pages.dart'; - -// class SettingPage extends StatefulWidget { -// const SettingPage({super.key}); - -// @override -// State createState() => _SettingPageState(); -// } - -// // Displayed as a profile image if the user doesn't have one. -// const placeholderImage = -// 'https://upload.wikimedia.org/wikipedia/commons/c/cd/Portrait_Placeholder_Square.png'; - -// class _SettingPageState extends State { -// late User user; -// late FirebaseAuth auth; - -// @override -// void initState() { -// auth = FirebaseService.auth(); -// user = auth.currentUser!; - -// auth.userChanges().listen((event) { -// if (event != null && mounted) { -// setState(() { -// user = event; -// }); -// } -// }); - -// super.initState(); -// } - -// Future showModal() async { -// return showModalBottomSheet( -// context: context, -// builder: (BuildContext context) { -// return StatefulBuilder( -// builder: (BuildContext context, StateSetter setState) { -// return Container( -// height: 206, -// width: double.infinity, -// color: Colors.white, -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.center, -// mainAxisSize: MainAxisSize.min, -// children: [ -// const SizedBox( -// height: 40, -// ), -// Container( -// margin: const EdgeInsets.only(left: 20), -// child: const Text( -// 'Anda yakin ingin keluar?', -// textAlign: TextAlign.left, -// style: -// TextStyle(fontSize: 16, fontWeight: FontWeight.bold), -// ), -// ), -// const SizedBox( -// height: 25, -// ), -// Container( -// padding: const EdgeInsets.symmetric(horizontal: 40), -// width: double.infinity, -// child: Button( -// onTap: () { -// // setState(() => selectedWeek = 'running_weekly_quiz'); -// // context.read() -// // .registerParticipant('siaga', selectedWeek); -// // checkNextWeeklyQuiz(); -// // checkRunningWeeklyQuiz(); -// // selectWeek(''); -// // Navigator.pop(context); -// // context.push('/quiz_download'); -// }, -// // isDisabled: isRunningWeekSelected, -// customButtonColor: Color(0xFF1BB8E1), -// customTextColor: Colors.white, -// text: 'Keluar', -// ),), -// const SizedBox( -// height: 10, -// ), -// Container( -// height: 59, -// padding: const EdgeInsets.symmetric(horizontal: 40), -// width: double.infinity, -// child: Button( -// onTap: () { -// // setState(() => selectedWeek = 'next_weekly_quiz'); -// // context.read() -// // .registerParticipant('siaga', selectedWeek); -// // checkNextWeeklyQuiz(); -// // checkRunningWeeklyQuiz(); -// // selectWeek(''); -// // Navigator.pop(context); -// // context.push('/quiz_download'); -// }, -// // isDisabled: isNextWeekSelected, -// customTextColor: Color(0xFF1BB8E1), -// customButtonColor: Color(0x1F1BB8E1), -// fontSize: 14, -// text: 'Batal', -// ),), -// ], -// ), -// ); -// }, -// ); -// }, -// ).whenComplete(() => null); -// } - -// @override -// Widget build(BuildContext context) { -// showModal(); - -// return BebrasScaffold( -// body: SingleChildScrollView( -// child: Stack( -// children: [ -// Padding( -// padding: const EdgeInsets.all(32), -// child: Column( -// children: [ -// CircleAvatar( -// maxRadius: 60, -// backgroundImage: NetworkImage( -// user.photoURL ?? placeholderImage, -// ), -// ), -// const SizedBox( -// height: 25, -// ), -// Text( -// 'Farida Nabila', -// textAlign: TextAlign.center, -// style: TextStyle( -// fontSize: 16, -// fontWeight: FontWeight.w600, -// ), -// ), -// const SizedBox( -// height: 40, -// ), -// Column( -// children: [ -// Container( -// padding: -// const EdgeInsets.symmetric(horizontal: 8, vertical: 10), -// margin: const EdgeInsets.only(bottom: 12), -// decoration: BoxDecoration( -// color: Color(0x0A1BB8E1), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Row( -// children: [ -// Container( -// margin: const EdgeInsets.symmetric(horizontal: 12), -// height: 50, -// width: 50, -// decoration: BoxDecoration( -// color: Color(0x1F1BB8E1), -// shape: BoxShape.circle, -// // borderRadius: BorderRadius.circular(20), -// ), -// ), -// Flexible( -// child: Container( -// width: double.infinity, -// child: const Text( -// 'Edit Profile', -// textAlign: TextAlign.start, -// style: TextStyle( -// fontSize: 12, -// fontWeight: FontWeight.w500, -// color: Colors.black, -// ), -// ), -// ), -// ), -// const Icon( -// Icons.chevron_right, -// size: 28, -// color: Colors.black, -// ), -// ], -// ), -// ), -// Container( -// padding: -// const EdgeInsets.symmetric(horizontal: 8, vertical: 10), -// margin: const EdgeInsets.only(bottom: 12), -// decoration: BoxDecoration( -// color: Color(0x0A1BB8E1), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Row( -// children: [ -// Container( -// margin: const EdgeInsets.symmetric(horizontal: 12), -// height: 50, -// width: 50, -// decoration: BoxDecoration( -// color: Color(0x1F1BB8E1), -// shape: BoxShape.circle, -// // borderRadius: BorderRadius.circular(20), -// ), -// ), -// Flexible( -// child: Container( -// width: double.infinity, -// child: const Text( -// 'Kebijakan Privasi', -// textAlign: TextAlign.start, -// style: TextStyle( -// fontSize: 12, -// fontWeight: FontWeight.w500, -// color: Colors.black, -// ), -// ), -// ), -// ), -// const Icon( -// Icons.chevron_right, -// size: 28, -// color: Colors.black, -// ), -// ], -// ), -// ), -// Container( -// padding: -// const EdgeInsets.symmetric(horizontal: 8, vertical: 10), -// margin: const EdgeInsets.only(bottom: 12), -// decoration: BoxDecoration( -// color: Color(0x0A1BB8E1), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Row( -// children: [ -// Container( -// margin: const EdgeInsets.symmetric(horizontal: 12), -// height: 50, -// width: 50, -// decoration: BoxDecoration( -// color: Color(0x1F1BB8E1), -// shape: BoxShape.circle, -// // borderRadius: BorderRadius.circular(20), -// ), -// ), -// Flexible( -// child: Container( -// width: double.infinity, -// child: const Text( -// 'Bantu Donasi', -// textAlign: TextAlign.start, -// style: TextStyle( -// fontSize: 12, -// fontWeight: FontWeight.w500, -// color: Colors.black, -// ), -// ), -// ), -// ), -// const Icon( -// Icons.chevron_right, -// size: 28, -// color: Colors.black, -// ), -// ], -// ), -// ), -// InkWell( -// onTap: () async { -// await FirebaseAuth.instance.signOut(); -// await GoogleSignIn().signOut(); -// context.go('/login'); -// }, -// child: Container( -// padding: -// const EdgeInsets.symmetric(horizontal: 8, vertical: 10), -// margin: const EdgeInsets.only(bottom: 12), -// decoration: BoxDecoration( -// color: Color(0x0AF50000), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Row( -// children: [ -// Container( -// margin: const EdgeInsets.symmetric(horizontal: 12), -// height: 50, -// width: 50, -// decoration: BoxDecoration( -// color: Color(0x1FF50000), -// shape: BoxShape.circle, -// // borderRadius: BorderRadius.circular(20), -// ), -// ), -// Flexible( -// child: Container( -// width: double.infinity, -// child: const Text( -// 'Keluar', -// textAlign: TextAlign.start, -// style: TextStyle( -// fontSize: 12, -// fontWeight: FontWeight.w500, -// color: Color(0xFFF50000), -// ), -// ), -// ), -// ), -// const Icon( -// Icons.chevron_right, -// size: 28, -// color: Color(0xFFF50000), -// ), -// ], -// ), -// ), -// ), -// Container( -// padding: -// const EdgeInsets.symmetric(horizontal: 8, vertical: 10), -// margin: const EdgeInsets.only(bottom: 12), -// decoration: BoxDecoration( -// color: Color(0xFFF5F5F5), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Row( -// children: [ -// Container( -// margin: const EdgeInsets.symmetric(horizontal: 12), -// height: 50, -// width: 50, -// decoration: BoxDecoration( -// color: Color(0xFFE6E6E6), -// shape: BoxShape.circle, -// // borderRadius: BorderRadius.circular(20), -// ), -// ), -// Flexible( -// child: Container( -// width: double.infinity, -// child: const Text( -// 'Hapus Akun', -// textAlign: TextAlign.start, -// style: TextStyle( -// fontSize: 12, -// fontWeight: FontWeight.w500, -// color: Colors.black, -// ), -// ), -// ), -// ), -// const Icon( -// Icons.chevron_right, -// size: 28, -// color: Color(0xFF636363), -// ), -// ], -// ), -// ), -// ], -// ), -// // Button( -// // buttonType: ButtonType.primary, -// // onTap: () async { -// // await context.push( -// // Uri( -// // path: '/register', -// // queryParameters: { -// // 'isUpdateProfile': 'true', -// // }, -// // ).toString(), -// // ); -// // }, -// // text: 'Edit Profil', -// // ), -// // const SizedBox( -// // height: 25, -// // ), -// // Button( -// // onTap: () async { -// // final url = Uri.parse( -// // 'https://docs.google.com/forms/d/1mUpZXTLvNU93C_bD-HeUTSTBVK1tRDE69t117dkE7ks/edit', -// // ); -// // if (!await launchUrl(url)) { -// // throw Exception('Could not launch $url'); -// // } -// // }, -// // customButtonColor: Colors.grey, -// // customTextColor: Colors.white, -// // text: 'Hapus Akun', -// // ), -// // const SizedBox( -// // height: 50, -// // ), -// // Button( -// // buttonType: ButtonType.primary, -// // onTap: () async { -// // final url = Uri.parse( -// // 'https://docs.google.com/document/d/1aj1cWrPak3f9On8Bj3KJO68p4MDtZPpWZCBquJZ9Nx0/edit', -// // ); -// // if (!await launchUrl(url)) { -// // throw Exception('Could not launch $url'); -// // } -// // }, -// // text: 'Kebijakan Privasi', -// // ), -// // const SizedBox( -// // height: 25, -// // ), -// // Button( -// // onTap: () async { -// // final url = Uri.parse( -// // 'https://tip.fintix.id/iatoki', -// // ); -// // if (!await launchUrl(url)) { -// // throw Exception('Could not launch $url'); -// // } -// // }, -// // customButtonColor: Colors.amber, -// // customTextColor: Colors.white, -// // text: 'Bantu Donasi 💌', -// // ), -// // BlocBuilder( -// // builder: (context, state) { -// // if (state is HomeSuccess && state.user.isAdmin) { -// // return Column( -// // children: [ -// // SizedBox( -// // height: -// // 225, // MediaQuery.of(context).size.height - 625, -// // ), -// // Button( -// // onTap: () { -// // context.push('/task_list'); -// // }, -// // buttonType: ButtonType.primary, -// // text: 'Lihat Bebras Task', -// // ), -// // const SizedBox( -// // height: 25, -// // ), -// // ], -// // ); -// // } -// // return SizedBox( -// // height: -// // 225, // MediaQuery.of(context).size.height - 695, -// // ); -// // }, -// // ), -// // Button( -// // onTap: () async { -// // await FirebaseAuth.instance.signOut(); -// // await GoogleSignIn().signOut(); -// // context.go('/onboarding'); -// // }, -// // customButtonColor: Colors.red.shade900, -// // customTextColor: Colors.white, -// // text: 'Keluar', -// // ), -// // const SizedBox( -// // height: 50, -// // ), -// InkWell( -// onTap: () async { -// final url = Uri.parse( -// 'https://tlx.toki.id/', -// ); -// if (!await launchUrl(url)) { -// throw Exception('Could not launch $url'); -// } -// }, -// child: Center( -// child: Text( -// 'From Ikatan Alumni TOKI with ❤️', -// textAlign: TextAlign.center, -// style: FontTheme.greyNormal14(), -// ), -// ), -// ), -// ], -// ), -// ), -// ], -// ), -// ), -// ); -// } -// } diff --git a/app/lib/features/material/menu/presentation/pages/_pages.dart b/app/lib/features/material/menu/presentation/pages/_pages.dart index 6b49b60e..568eb2d4 100644 --- a/app/lib/features/material/menu/presentation/pages/_pages.dart +++ b/app/lib/features/material/menu/presentation/pages/_pages.dart @@ -2,12 +2,12 @@ import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:go_router/go_router.dart'; import 'package:printing/printing.dart'; -import '../../../../../core/bases/enum/button_type.dart'; -import '../../../../../core/bases/widgets/atoms/button.dart'; import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; +import '../../../../../core/bases/widgets/layout/bottom_navbar.dart'; import '../../../../../core/constants/assets.dart'; import '../../data/repositories/material.dart'; import '../model/bebras_group_category.dart'; diff --git a/app/lib/features/material/menu/presentation/pages/material_menu.dart b/app/lib/features/material/menu/presentation/pages/material_menu.dart index f0e16bbf..e8807a45 100644 --- a/app/lib/features/material/menu/presentation/pages/material_menu.dart +++ b/app/lib/features/material/menu/presentation/pages/material_menu.dart @@ -42,10 +42,9 @@ class _MaterialMenuState extends State { child: OutlinedButton( style: OutlinedButton.styleFrom( backgroundColor: - filterIndex == index ? const Color(0xFF1BB8E1) : Colors.white, + filterIndex == index ? const Color(0xFF1BB8E1) : Colors.white, side: BorderSide( - color: - filterIndex == index ? const Color(0xFF1BB8E1) : Colors.grey, + color: filterIndex == index ? const Color(0xFF1BB8E1) : Colors.grey, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18), @@ -54,8 +53,8 @@ class _MaterialMenuState extends State { child: Text(text, style: TextStyle( fontSize: 14, - color: filterIndex == index - ? Colors.white : const Color(0xFF9E9E9E), + color: + filterIndex == index ? Colors.white : const Color(0xFF9E9E9E), )), onPressed: () { setState(() { @@ -66,11 +65,13 @@ class _MaterialMenuState extends State { ); } - Widget materialItem(String docId, - String title, - String url, - // ignore: avoid_positional_boolean_parameters - bool isPrintable,) { + Widget materialItem( + String docId, + String title, + String url, + // ignore: avoid_positional_boolean_parameters + bool isPrintable, + ) { return InkWell( onTap: () { context.push( @@ -142,128 +143,150 @@ class _MaterialMenuState extends State { @override Widget build(BuildContext context) { - return Stack( + return BebrasScaffold( + body: Container( + padding: const EdgeInsets.only(left: 25, right: 25), + child: Column( + children: [ + buildMaterialCategory(context), + buildMaterialList(), + ], + ), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButton: FloatingActionButton( + onPressed: () { + context.go('/quiz_registration'); + }, + child: const FaIcon(FontAwesomeIcons.graduationCap), + ), + bottomNavigationBar: const BottomNavBar( + currentIndex: 0, + ), + ); + } + + Column buildMaterialCategory(BuildContext context) { + return Column( children: [ - Container( - padding: const EdgeInsets.only( - left: 25, + SizedBox( + height: 20, + ), + const SizedBox( + width: double.infinity, + child: Text( + 'Kategori Materi', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), ), - child: Column( - children: [ - SizedBox( - height: 40, - width: MediaQuery - .of(context) - .size - .width - 10, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - ...bebrasGroupList.map( - (e) => materialTab(e.label, e.index), - ), - ], - ), + ), + SizedBox( + height: 10, + ), + SizedBox( + height: 40, + width: MediaQuery.of(context).size.width - 10, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + ...bebrasGroupList.map( + (e) => materialTab(e.label, e.index), ), - Container( - padding: const EdgeInsets.only( - right: 25, - ), - child: Column( - children: [ - const SizedBox( - height: 10, - ), - const SizedBox( - width: double.infinity, - child: Text( - 'Daftar Materi', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - ), - const SizedBox( - height: 10, - ), - StreamBuilder( - stream: materialsStream, - builder: (BuildContext context, - AsyncSnapshot snapshot,) { - if (snapshot.hasError) { - return const Text('Something went wrong'); - } + ], + ), + ), + ], + ); + } + + Column buildMaterialList() { + return Column( + children: [ + const SizedBox( + height: 20, + ), + const SizedBox( + width: double.infinity, + child: Text( + 'Daftar Materi', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + const SizedBox( + height: 10, + ), + StreamBuilder( + stream: materialsStream, + builder: ( + BuildContext context, + AsyncSnapshot snapshot, + ) { + if (snapshot.hasError) { + return const Text('Something went wrong'); + } - if (snapshot.connectionState == - ConnectionState.waiting) { - return const Center( - child: CircularProgressIndicator(), - ); - } + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator(), + ); + } - var displayEmpty = true; - final boxHeight = - MediaQuery - .of(context) - .size - .height - 440; - return SingleChildScrollView( - child: SizedBox( - height: boxHeight, - width: double.infinity, - child: ListView( - children: [ - ...snapshot.data!.docs.map((d) { - final materialDoc = - d.data()! as Map; - if (materialDoc['challenge_group'] == - bebrasGroupList[filterIndex].key) { - displayEmpty = false; - return materialItem( - d.id, - materialDoc['title'] as String, - materialDoc['url'] as String, - File('$basePath${d.id}.pdf').existsSync(), - ); - } - return Container(); - }), - if (displayEmpty) - Transform.translate( - offset: const Offset( - 0, - -10, - ), - child: Container( - height: boxHeight, - padding: const EdgeInsets.all(10), - margin: const EdgeInsets.only( - bottom: 12, - top: 12, - ), - decoration: BoxDecoration( - color: Colors.blue[50], - borderRadius: BorderRadius.circular(8), - ), - child: const Center( - child: Text( - 'Materi belum ada', - ), - ), - ), - ), - ], + var displayEmpty = true; + final boxHeight = MediaQuery.of(context).size.height - 440; + return SingleChildScrollView( + child: SizedBox( + height: boxHeight, + width: double.infinity, + child: ListView( + children: [ + ...snapshot.data!.docs.map((d) { + final materialDoc = d.data()! as Map; + if (materialDoc['challenge_group'] == + bebrasGroupList[filterIndex].key) { + displayEmpty = false; + return materialItem( + d.id, + materialDoc['title'] as String, + materialDoc['url'] as String, + File('$basePath${d.id}.pdf').existsSync(), + ); + } + return Container(); + }), + if (displayEmpty) + Transform.translate( + offset: const Offset( + 0, + -10, + ), + child: Container( + height: boxHeight, + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.only( + bottom: 12, + top: 12, + ), + decoration: BoxDecoration( + color: Colors.blue[50], + borderRadius: BorderRadius.circular(8), + ), + child: const Center( + child: Text( + 'Materi belum ada', ), ), - ); - }, - ), + ), + ), ], ), ), - ], - ), + ); + }, ), ], ); diff --git a/app/lib/features/quiz_download/presentation/bloc/quiz_registration_cubit.dart b/app/lib/features/quiz_download/presentation/bloc/quiz_registration_cubit.dart index 778bfa5a..978b4f7f 100644 --- a/app/lib/features/quiz_download/presentation/bloc/quiz_registration_cubit.dart +++ b/app/lib/features/quiz_download/presentation/bloc/quiz_registration_cubit.dart @@ -2,7 +2,6 @@ import 'package:equatable/equatable.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../models/quiz_participation.dart'; -import '../../../../models/weekly_quiz.dart'; import '../../../../services/firebase_service.dart'; import '../../../../services/quiz_service.dart'; @@ -10,6 +9,7 @@ part 'quiz_registration_state.dart'; class QuizRegistrationCubit extends Cubit { QuizRegistrationCubit() : super(QuizRegistrationInitialState()); + QuizService quizService = QuizService(); Future registerParticipant( String selectedLevel, @@ -17,38 +17,27 @@ class QuizRegistrationCubit extends Cubit { ) async { try { emit(QuizRegistrationLoading()); - await QuizService().registerParticipant(selectedWeek, selectedLevel); + await quizService.registerParticipant(selectedWeek, selectedLevel); + final participantWeeklyQuizzes = + await quizService.getRunningWeeklyQuizByParticipantUid( + FirebaseService.auth().currentUser!.uid); - emit(const QuizRegistrationSuccess('success')); + emit(QuizRegistrationSuccess(participantWeeklyQuizzes)); } catch (e) { - emit(RunningWeeklyQuizFailed(e.toString())); + emit(QuizRegistrationFailed(e.toString())); } } Future fetchParticipantWeeklyQuiz() async { try { - final participantUid = FirebaseService.auth().currentUser!.uid; - final participantWeeklyQuizzes = await QuizService() - .getRunningWeeklyQuizByParticipantUid(participantUid); + emit(QuizRegistrationLoading()); + final participantWeeklyQuizzes = + await quizService.getRunningWeeklyQuizByParticipantUid( + FirebaseService.auth().currentUser!.uid); - emit(GetParticipantWeeklyQuizSuccess(participantWeeklyQuizzes)); + emit(QuizRegistrationSuccess(participantWeeklyQuizzes)); } catch (e) { - emit(GetParticipantWeeklyQuizFailed(e.toString())); + emit(QuizRegistrationFailed(e.toString())); } } - - // Future fetchRunningQuizTasks(String level) async { - // try { - // final participantWeeklyQuizzes = - // await QuizService().getWeeklyQuizByWeek('running_weekly_quiz'); - - // final tasks = await QuizService().fetchWeeklyQuizTaskSet( - // participantWeeklyQuizzes.problems[level][0].toString(), - // ); - - // emit(GetRunningQuizTasksSuccess(tasks)); - // } catch (e) { - // emit(GetParticipantWeeklyQuizFailed(e.toString())); - // } - // } } diff --git a/app/lib/features/quiz_download/presentation/bloc/quiz_registration_state.dart b/app/lib/features/quiz_download/presentation/bloc/quiz_registration_state.dart index 7328dd34..37c61ba1 100644 --- a/app/lib/features/quiz_download/presentation/bloc/quiz_registration_state.dart +++ b/app/lib/features/quiz_download/presentation/bloc/quiz_registration_state.dart @@ -11,46 +11,10 @@ class QuizRegistrationInitialState extends QuizRegistrationState {} class QuizRegistrationLoading extends QuizRegistrationState {} -class QuizRegistrationWeekSelected extends QuizRegistrationState { - final String selectedWeek; - - const QuizRegistrationWeekSelected(this.selectedWeek); - - @override - List get props => [selectedWeek]; -} - -class QuizRegistrationLevelSelected extends QuizRegistrationState { - final String selectedLevel; - - const QuizRegistrationLevelSelected(this.selectedLevel); - - @override - List get props => [selectedLevel]; -} - -class RunningWeeklyQuizSuccess extends QuizRegistrationState { - final WeeklyQuiz runningWeeklyQuiz; - - const RunningWeeklyQuizSuccess(this.runningWeeklyQuiz); - - @override - List get props => [runningWeeklyQuiz]; -} - class QuizRegistrationSuccess extends QuizRegistrationState { - final String quizRegistration; - - const QuizRegistrationSuccess(this.quizRegistration); - - @override - List get props => [quizRegistration]; -} - -class GetParticipantWeeklyQuizSuccess extends QuizRegistrationState { final List weeklyQuizzes; - const GetParticipantWeeklyQuizSuccess( + const QuizRegistrationSuccess( this.weeklyQuizzes, ); @@ -58,37 +22,10 @@ class GetParticipantWeeklyQuizSuccess extends QuizRegistrationState { List get props => [weeklyQuizzes]; } -class GetRunningQuizTasksSuccess extends QuizRegistrationState { - final String tasks; - - const GetRunningQuizTasksSuccess( - this.tasks, - ); - - @override - List get props => [tasks]; -} - -class GetParticipantWeeklyQuizFailed extends QuizRegistrationState { - final String error; - - const GetParticipantWeeklyQuizFailed(this.error); - @override - List get props => [error]; -} - -class QuizRegistrationSFailed extends QuizRegistrationState { - final String error; - - const QuizRegistrationSFailed(this.error); - @override - List get props => [error]; -} - -class RunningWeeklyQuizFailed extends QuizRegistrationState { +class QuizRegistrationFailed extends QuizRegistrationState { final String error; - const RunningWeeklyQuizFailed(this.error); + const QuizRegistrationFailed(this.error); @override List get props => [error]; } diff --git a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart index 764096c9..3de6f95c 100644 --- a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart +++ b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart @@ -124,110 +124,77 @@ class _QuizDownloadPageState extends State { child: CircularProgressIndicator(), ); } + if (state is QuizRegistrationFailed) { + return buildQuizRegistrationHeader(Text(state.error)); + } if (state is QuizRegistrationSuccess) { - return PermissionToDownloadQuiz(onClickDownload: _downloadQuiz()); // onClickDownload: _downloadQuiz); + return buildQuizRegistrationHeader( + state.weeklyQuizzes.isEmpty + ? buildQuizRegistrationEmpty() + : buildQuizRegistrationList(state)); } - print(state); - return Column( - children: [ - const SizedBox( - height: 40, - ), - Align( - alignment: Alignment.centerLeft, - child: Text( - 'Latihan yang pernah diikuti', - style: FontTheme.blackSubtitleBold(), - ), - ), - const SizedBox( - height: 20, - ), - SizedBox( - height: MediaQuery.of(context).size.height - 211, - width: double.infinity, - child: BlocConsumer( - listener: (context, state) { - // TODO(someone): implement listener - }, - builder: (context, state) { - if (state is GetParticipantWeeklyQuizSuccess) { - if (state.weeklyQuizzes.isEmpty) { - return Container( - padding: const EdgeInsets.all(10), - margin: const EdgeInsets.only( - bottom: 12, top: 12), - decoration: BoxDecoration( - color: Colors.blue[50], - borderRadius: BorderRadius.circular(8), - ), - child: const Center( - child: Text( - 'Silahkan klik Tombol `Daftar Latihan Bebras` dibawah untuk memulai', - ), - ), - ); - } - return ListView(children: [ - const SizedBox( - height: 20, - ), - for (final quiz in state.weeklyQuizzes) - QuizCard( - quiz, - quiz.attempts.isNotEmpty - ? quiz - .attempts[ - quiz.attempts.length - 1] - .startAt - .toString() - : '-', - quiz.attempts.isNotEmpty - ? quiz - .attempts[ - quiz.attempts.length - 1] - .score - .toString() - : '??', - quiz.challenge_group, - ), - ]); - } - - if (state is GetParticipantWeeklyQuizFailed) { - return Text(state.error); - } - return const Center( - child: CircularProgressIndicator(), - ); - }, - ), - ), - ], - ); + return Container(); }, ), ), ), - // Container( - // alignment: Alignment.bottomCenter, - // padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), - // child: Button( - // borderRadius: 4, - // customTextColor: Colors.white, - // customButtonColor: const Color(0xFF1BB8E1), - // fontSize: 14, - // innerVerticalPadding: 10, - // onTap: () async { - // // await showModal(); - // }, - // text: 'Batalkan', - // ), - // ), ], ), ), ); } + + Widget buildQuizRegistrationHeader(Widget widget) { + return Column( + children: [ + const SizedBox( + height: 40, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + 'Latihan yang pernah diikuti', + style: FontTheme.blackSubtitleBold(), + ), + ), + const SizedBox( + height: 20, + ), + widget + ], + ); + } + + Widget buildQuizRegistrationList(QuizRegistrationSuccess state) { + return Column( + children: state.weeklyQuizzes + .map((quiz) => QuizCard( + quiz, + quiz.attempts.isNotEmpty + ? quiz.attempts[quiz.attempts.length - 1].startAt.toString() + : '-', + quiz.attempts.isNotEmpty + ? quiz.attempts[quiz.attempts.length - 1].score.toString() + : '??', + quiz.challenge_group, + )) + .toList(), + ); + } + + Container buildQuizRegistrationEmpty() { + return Container( + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.only(bottom: 12, top: 12), + decoration: BoxDecoration( + color: Colors.blue[50], + borderRadius: BorderRadius.circular(8), + ), + child: const Center( + child: Text( + 'Silahkan klik Tombol `Daftar Latihan Bebras` dibawah untuk memulai', + ), + ), + ); + } } diff --git a/app/lib/features/quiz_registration/presentation/pages/quiz_registration_page.dart b/app/lib/features/quiz_registration/presentation/pages/quiz_registration_page.dart index 1afd2ba0..c199a63f 100644 --- a/app/lib/features/quiz_registration/presentation/pages/quiz_registration_page.dart +++ b/app/lib/features/quiz_registration/presentation/pages/quiz_registration_page.dart @@ -52,11 +52,11 @@ class _QuizRegistrationPageState extends State { updateIsNextWeekSelected(newValue: check); } - Widget quizCard(WeeklyQuizParticipation weeklyQuizParticipant, String date, String score, String level, BuildContext context) { - - final formattedDate = (date.isNotEmpty && date != '-') ? DateFormat('dd MMMM yyyy HH:mm', 'id_ID').format(DateTime.parse(date)) : '-'; + final formattedDate = (date.isNotEmpty && date != '-') + ? DateFormat('dd MMMM yyyy HH:mm', 'id_ID').format(DateTime.parse(date)) + : '-'; return InkWell( onTap: () async { await context.push( @@ -414,7 +414,7 @@ class _QuizRegistrationPageState extends State { fontSize: 14, innerVerticalPadding: 14, onTap: () async { - // await showModal(); + context.push('/quiz_download'); }, text: 'Riwayat Latihan', ), diff --git a/app/lib/services/quiz_service.dart b/app/lib/services/quiz_service.dart index 1539b62e..1f737c0a 100644 --- a/app/lib/services/quiz_service.dart +++ b/app/lib/services/quiz_service.dart @@ -45,9 +45,19 @@ class QuizService { // background task untuk fetch task untuk sesuai minggu dan level // yang akan didaftarkan agar bisa dipakai offline - for (final taskId in snapshot['tasks'][level] as List) { - await fetchWeeklyQuizTaskSet(taskId.toString()); - } + // for (final taskId in snapshot['tasks'][level] as List) { + // await fetchWeeklyQuizTaskSet(taskId.toString()); + // } + + // check apakah user sudah registered minggu ini + // final participation = await db + // .collection('weekly_quiz_participation') + // .where('quiz_title', isEqualTo: snapshot['title']) + // .where('user_uid', isEqualTo: currentUserUID) + // .get(); + // if (participation.size > 0) { + // return; + // } try { await db.collection('weekly_quiz_participation').doc().set({ diff --git a/app/lib/services/router_service.dart b/app/lib/services/router_service.dart index c58a41bf..38fcde5b 100644 --- a/app/lib/services/router_service.dart +++ b/app/lib/services/router_service.dart @@ -6,9 +6,7 @@ import '../features/authentication/signin/presentation/pages/_pages.dart'; import '../features/authentication/signin/presentation/pages/v2/_pages.dart'; import '../features/error/presentation/pages/_pages.dart'; import '../features/main/presentation/pages/_pages.dart'; -import '../features/main/presentation/pages/v2/_pages.dart'; -import '../features/main/presentation/pages/v2/delete_page.dart'; -import '../features/main/presentation/pages/v2/policy_page.dart'; +import '../features/main/presentation/pages/delete_page.dart'; import '../features/material/menu/presentation/pages/_pages.dart'; import '../features/material/viewer/presentation/pages/_pages.dart'; import '../features/onboarding/presentation/pages/_pages.dart'; @@ -67,22 +65,12 @@ GoRouter router = GoRouter( GoRoute( path: '/main', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return const HomePage(); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - return const HomePageV2(); - } - return const HomePage(); + return const QuizRegistrationPage(); }, ), GoRoute( path: '/setting', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return const SettingPage(); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2SettingPage(); - } return const SettingPage(); }, ), @@ -154,11 +142,6 @@ GoRouter router = GoRouter( GoRoute( path: '/quiz_registration', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return const QuizRegistrationPage(); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2QuizRegistrationPage(); - } return const QuizRegistrationPage(); }, ), @@ -197,26 +180,12 @@ GoRouter router = GoRouter( GoRoute( path: '/material', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return const MaterialMenu(); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2MaterialMenu(); - } return const MaterialMenu(); }, ), GoRoute( path: '/material/:id', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return PdfViewerPage( - pdfUrl: state.queryParameters['pdfUrl'], - title: state.queryParameters['title'], - id: state.queryParameters['id'], - ); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2PdfViewerPage(); - } return PdfViewerPage( pdfUrl: state.queryParameters['pdfUrl'], title: state.queryParameters['title'], @@ -226,11 +195,6 @@ GoRouter router = GoRouter( GoRoute( path: '/policy', builder: (context, state) { - if (dotenv.env['APP_VERSION'] == 'V1') { - return const PrivacyPolicyPage(); - } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2SettingPage(); - } return const PrivacyPolicyPage(); }, ),