Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign material menu #168

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/lib/features/material/menu/presentation/pages/_pages.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
140 changes: 111 additions & 29 deletions app/lib/features/material/menu/presentation/pages/material_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ class MaterialMenu extends StatefulWidget {
State<MaterialMenu> createState() => _MaterialMenuState();
}

final List<String> 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<MaterialMenu> {
String basePath =
'/storage/emulated/0/Android/data/com.toki.bebras_pandai/files/PDF_Download/';
Expand All @@ -18,6 +25,7 @@ class _MaterialMenuState extends State<MaterialMenu> {

@override
void initState() {
context.read<HomeCubit>().fetchUser();
super.initState();
_initializeStream();
}
Expand Down Expand Up @@ -103,10 +111,10 @@ class _MaterialMenuState extends State<MaterialMenu> {
),
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),
),
],
),
Expand Down Expand Up @@ -144,14 +152,101 @@ class _MaterialMenuState extends State<MaterialMenu> {
@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<HomeCubit, HomeState>(
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>[
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(
Expand All @@ -169,20 +264,20 @@ class _MaterialMenuState extends State<MaterialMenu> {
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(
Expand All @@ -204,19 +299,6 @@ class _MaterialMenuState extends State<MaterialMenu> {
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,
),
Expand All @@ -237,7 +319,7 @@ class _MaterialMenuState extends State<MaterialMenu> {
}

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,
Expand Down
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading