From b8d79741efc553ac2e40dca7763bb67d8275c0a2 Mon Sep 17 00:00:00 2001 From: "@henoch.hernanda" Date: Tue, 9 Apr 2024 11:41:28 +0700 Subject: [PATCH] redesign material menu --- .../menu/presentation/pages/_pages.dart | 7 + .../presentation/pages/material_menu.dart | 140 ++++++++++++++---- app/pubspec.lock | 4 +- 3 files changed, 120 insertions(+), 31 deletions(-) diff --git a/app/lib/features/material/menu/presentation/pages/_pages.dart b/app/lib/features/material/menu/presentation/pages/_pages.dart index 568eb2d..2ca9e3b 100644 --- a/app/lib/features/material/menu/presentation/pages/_pages.dart +++ b/app/lib/features/material/menu/presentation/pages/_pages.dart @@ -1,14 +1,21 @@ import 'dart:io'; +import 'package:carousel_slider/carousel_options.dart'; +import 'package:carousel_slider/carousel_slider.dart'; import 'package:cloud_firestore/cloud_firestore.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:intl/intl.dart'; import 'package:printing/printing.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; import '../../../../../core/bases/widgets/layout/bottom_navbar.dart'; import '../../../../../core/constants/assets.dart'; +import '../../../../main/presentation/bloc/home_cubit.dart'; +import '../../../../main/presentation/pages/clip_path.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 e8807a4..6cd217c 100644 --- a/app/lib/features/material/menu/presentation/pages/material_menu.dart +++ b/app/lib/features/material/menu/presentation/pages/material_menu.dart @@ -7,6 +7,13 @@ class MaterialMenu extends StatefulWidget { State createState() => _MaterialMenuState(); } +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 _MaterialMenuState extends State { String basePath = '/storage/emulated/0/Android/data/com.toki.bebras_pandai/files/PDF_Download/'; @@ -18,6 +25,7 @@ class _MaterialMenuState extends State { @override void initState() { + context.read().fetchUser(); super.initState(); _initializeStream(); } @@ -103,10 +111,10 @@ class _MaterialMenuState extends State { ), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 4, - offset: const Offset(0, 3), // changes position of shadow + color: Colors.grey.withOpacity(0.1), + spreadRadius: 1.5, + blurRadius: 1, + offset: const Offset(1, 3), ), ], ), @@ -144,14 +152,101 @@ class _MaterialMenuState extends State { @override Widget build(BuildContext context) { return BebrasScaffold( - body: Container( - padding: const EdgeInsets.only(left: 25, right: 25), - child: Column( - children: [ - buildMaterialCategory(context), - buildMaterialList(), - ], - ), + body: Stack( + children: [ + ClipPath( + clipper: ClipPathClass(), + child: Container( + height: 250, + color: const Color(0xFF1BB8E1), + ), + ), + Container( + padding: const EdgeInsets.only(left: 25, right: 25), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + top: 32), + 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( + width: double.infinity, + 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), + ), + ), + ], + ), + ), + buildMaterialCategory(context), + buildMaterialList(), + ], + ), + ), + ], ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( @@ -169,20 +264,20 @@ class _MaterialMenuState extends State { Column buildMaterialCategory(BuildContext context) { return Column( children: [ - SizedBox( + const SizedBox( height: 20, ), const SizedBox( width: double.infinity, child: Text( - 'Kategori Materi', + 'Daftar Materi', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), ), - SizedBox( + const SizedBox( height: 10, ), SizedBox( @@ -204,19 +299,6 @@ class _MaterialMenuState extends State { 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, ), @@ -237,7 +319,7 @@ class _MaterialMenuState extends State { } var displayEmpty = true; - final boxHeight = MediaQuery.of(context).size.height - 440; + final boxHeight = MediaQuery.of(context).size.height - 444; return SingleChildScrollView( child: SizedBox( height: boxHeight, diff --git a/app/pubspec.lock b/app/pubspec.lock index c4e90c4..bdc7d82 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -604,10 +604,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "24f77b50776d4285cc4b3a1665bb79852714c09b878363efbe64788c179c4284" + sha256: "91bce569d4805ea5bad6619a3e8690df8ad062a235165af4c0c5d928dda15eaf" url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.5.1" freezed_annotation: dependency: "direct main" description: