From defc45f2de9b13cac9805477f87557ffde1000d2 Mon Sep 17 00:00:00 2001 From: Ahmad Taufiq Date: Thu, 4 Apr 2024 15:12:15 +0700 Subject: [PATCH] revamp halaman home --- .../bases/widgets/layout/bottom_navbar.dart | 2 +- .../main/presentation/pages/v2/_pages.dart | 15 +- .../main/presentation/pages/v2/home_page.dart | 299 ++++++++++-------- app/lib/services/router_service.dart | 4 +- 4 files changed, 175 insertions(+), 145 deletions(-) diff --git a/app/lib/core/bases/widgets/layout/bottom_navbar.dart b/app/lib/core/bases/widgets/layout/bottom_navbar.dart index b11e1bb..12df4bd 100644 --- a/app/lib/core/bases/widgets/layout/bottom_navbar.dart +++ b/app/lib/core/bases/widgets/layout/bottom_navbar.dart @@ -18,7 +18,7 @@ class _BottomNavBarState extends State { void _onTap(int index, BuildContext context) { switch (index) { case 0: - context.go('/main'); + context.go('/material'); break; case 1: context.go('/setting'); diff --git a/app/lib/features/main/presentation/pages/v2/_pages.dart b/app/lib/features/main/presentation/pages/v2/_pages.dart index d7253c7..6b0606f 100644 --- a/app/lib/features/main/presentation/pages/v2/_pages.dart +++ b/app/lib/features/main/presentation/pages/v2/_pages.dart @@ -1,21 +1,22 @@ // import 'package:carousel_slider/carousel_slider.dart'; // import 'package:firebase_auth/firebase_auth.dart'; -// import 'package:flutter/material.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: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/bases/widgets/layout/bottom_navbar.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 '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 index 5c1a873..f5b87a6 100644 --- a/app/lib/features/main/presentation/pages/v2/home_page.dart +++ b/app/lib/features/main/presentation/pages/v2/home_page.dart @@ -1,141 +1,170 @@ -// part of '_pages.dart'; +part of '_pages.dart'; -// class HomePage extends StatefulWidget { -// const HomePage({super.key}); +class HomePageV2 extends StatefulWidget { + const HomePageV2({super.key}); -// @override -// State createState() => _HomePageState(); -// } + @override + State createState() => _HomePageV2State(); +} -// final List imgList = [ -// 'https://pandai.bebras.or.id/img/carousel5.ad104915.png', -// 'https://pandai.bebras.or.id/img/banner2023.95952847.jpeg', -// 'https://pandai.bebras.or.id/img/bebrasBanner.96a43a30.jpg', -// 'https://pandai.bebras.or.id/img/grow-with-google-bebras-id.8d80a623.jpg', -// ]; +class _HomePageV2State extends State { + String version = ''; -// class Course { -// String title; -// String description; + @override + void initState() { + super.initState(); + } -// Course(this.title, this.description); -// } + 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); + } -// class _HomePageState extends State { -// @override -// void initState() { -// context.read().fetchUser(); -// super.initState(); -// } - -// @override -// Widget build(BuildContext context) { -// return BebrasScaffold( -// body: Stack( -// children: [ -// ClipPath( -// clipper: ClipPathClass(), -// child: Container( -// height: 250, -// color: const Color(0xFF1BB8E1), -// ), -// ), -// Column( -// children: [ -// Padding( -// padding: const EdgeInsets.only( -// left: 32, right: 32, top: 32, bottom: 16), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// BlocBuilder( -// builder: (context, state) { -// if (state is HomeSuccess) { -// return RichText( -// text: TextSpan( -// text: 'Selamat Datang\n', -// style: const TextStyle( -// color: Colors.white, -// fontSize: 20, -// fontWeight: FontWeight.w400, -// ), -// children: [ -// TextSpan( -// text: toBeginningOfSentenceCase( -// '${state.user.name}!', -// ), -// style: const TextStyle( -// color: Colors.white, -// fontSize: 20, -// fontWeight: FontWeight.w600, -// ), -// ), -// ], -// ), -// ); -// } -// return Container(); -// }), -// const SizedBox( -// height: 30, -// ), -// CarouselSlider( -// items: imgList -// .map( -// (item) => InkWell( -// onTap: () async { -// final Uri url = Uri.parse( -// 'https://bebras.or.id/v3/bebras-indonesia-challenge-2023/'); -// if (!await launchUrl(url)) { -// throw Exception('Could not launch $url'); -// } -// }, // Handle your callback -// child: Container( -// margin: const EdgeInsets.only( -// left: 10, -// right: 10, -// ), -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(10), -// color: Colors.transparent, -// ), -// child: ClipRRect( -// borderRadius: BorderRadius.circular(10), -// child: Image.network( -// item, -// fit: BoxFit.cover, -// width: double.infinity, -// ), -// ), -// ), -// ), -// ) -// .toList(), -// options: CarouselOptions( -// height: 150, -// viewportFraction: 1, -// autoPlay: true, -// autoPlayInterval: const Duration(seconds: 3), -// ), -// ), -// ], -// ), -// ), -// const MaterialMenu(), -// ], -// ), -// ], -// ), -// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, -// floatingActionButton: FloatingActionButton( -// onPressed: () { -// context.go('/quiz_registration'); -// }, -// child: const FaIcon(FontAwesomeIcons.graduationCap), -// ), -// bottomNavigationBar: const BottomNavBar( -// currentIndex: 0, -// ), -// ); -// } -// } + @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/services/router_service.dart b/app/lib/services/router_service.dart index ecc15c8..28fa1fa 100644 --- a/app/lib/services/router_service.dart +++ b/app/lib/services/router_service.dart @@ -17,7 +17,7 @@ import '../features/quiz_result/presentation/pages/_pages.dart'; import '../features/quiz_start/presentation/pages/_pages.dart'; import '../features/task_detail/presentation/pages/_pages.dart'; import '../features/task_list/presentation/pages/_pages.dart'; -// import '../features/main/presentation/pages/v2/_pages.dart'; +import '../features/main/presentation/pages/v2/_pages.dart'; GoRouter router = GoRouter( routes: [ @@ -68,7 +68,7 @@ GoRouter router = GoRouter( if (dotenv.env['APP_VERSION'] == 'V1') { return const HomePage(); } else if (dotenv.env['APP_VERSION'] == 'V2') { - // return const V2HomePage(); + return const HomePageV2(); } return const HomePage(); },