Customer Point
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../application/auth/auth_bloc.dart';
|
||||
import '../../../../../application/customer/customer_point_loader/customer_point_loader_bloc.dart';
|
||||
import '../../../../../common/theme/theme.dart';
|
||||
import '../../../../components/image/image.dart';
|
||||
import '../../../../router/app_router.gr.dart';
|
||||
@@ -30,6 +33,16 @@ class _HomePageState extends State<HomePage> {
|
||||
'https://images.unsplash.com/photo-1574848794584-c740d6a5595f?w=800&h=400&fit=crop',
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (context.read<AuthBloc>().state.isAuthenticated) {
|
||||
context.read<CustomerPointLoaderBloc>().add(
|
||||
CustomerPointLoaderEvent.fetched(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -61,7 +74,19 @@ class _HomePageState extends State<HomePage> {
|
||||
top: 225,
|
||||
child: _buildCarouselIndicators(),
|
||||
),
|
||||
Positioned(left: 16, right: 16, top: 240, child: HomePointCard()),
|
||||
Positioned(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 240,
|
||||
child: HomePointCard(
|
||||
point: context
|
||||
.read<CustomerPointLoaderBloc>()
|
||||
.state
|
||||
.customerPoint
|
||||
.totalPoints
|
||||
.toString(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../router/app_router.gr.dart';
|
||||
|
||||
class HomePointCard extends StatelessWidget {
|
||||
const HomePointCard({super.key});
|
||||
final String point;
|
||||
const HomePointCard({super.key, required this.point});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -75,7 +76,7 @@ class HomePointCard extends StatelessWidget {
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'148 Poin',
|
||||
'$point Poin',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -86,7 +87,7 @@ class HomePointCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Kamu punya 148 poin',
|
||||
'Kamu punya $point poin',
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontSize: 11,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/customer/customer_point_loader/customer_point_loader_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../router/app_router.gr.dart';
|
||||
|
||||
@@ -201,6 +203,9 @@ class _PoinPageState extends State<PoinPage> {
|
||||
super.initState();
|
||||
activeCategoryId = categories.first.id; // Set first category as active
|
||||
_initializeCategoryKeys();
|
||||
context.read<CustomerPointLoaderBloc>().add(
|
||||
CustomerPointLoaderEvent.fetched(),
|
||||
);
|
||||
}
|
||||
|
||||
void _initializeCategoryKeys() {
|
||||
@@ -304,110 +309,115 @@ class _PoinPageState extends State<PoinPage> {
|
||||
}
|
||||
|
||||
Widget _buildPointCard() {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(16),
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [AppColor.primary, AppColor.primaryDark],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 12,
|
||||
offset: Offset(0, 6),
|
||||
return BlocBuilder<CustomerPointLoaderBloc, CustomerPointLoaderState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(16),
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [AppColor.primary, AppColor.primaryDark],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 12,
|
||||
offset: Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
pointCard.membershipLevel,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.9),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Text(
|
||||
// "",
|
||||
// style: AppStyle.sm.copyWith(
|
||||
// color: AppColor.textWhite.withOpacity(0.9),
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 4),
|
||||
Text(
|
||||
"${state.customerPoint.totalPoints}",
|
||||
style: AppStyle.h2.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Poin Tersedia",
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.9),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
"${pointCard.availablePoints}",
|
||||
style: AppStyle.h2.copyWith(
|
||||
Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.stars_rounded,
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Poin Tersedia",
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.9),
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.stars_rounded,
|
||||
color: AppColor.textWhite,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
|
||||
// SizedBox(height: 16),
|
||||
// Container(
|
||||
// height: 8,
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.white.withOpacity(0.3),
|
||||
// borderRadius: BorderRadius.circular(4),
|
||||
// ),
|
||||
// child: FractionallySizedBox(
|
||||
// widthFactor:
|
||||
// (pointCard.totalPoints - pointCard.usedPoints) /
|
||||
// pointCard.totalPoints,
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.textWhite,
|
||||
// borderRadius: BorderRadius.circular(4),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 8),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Terpakai: ${pointCard.usedPoints}",
|
||||
// style: AppStyle.xs.copyWith(
|
||||
// color: AppColor.textWhite.withOpacity(0.8),
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// "Total: ${pointCard.totalPoints}",
|
||||
// style: AppStyle.xs.copyWith(
|
||||
// color: AppColor.textWhite.withOpacity(0.8),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Container(
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: FractionallySizedBox(
|
||||
widthFactor:
|
||||
(pointCard.totalPoints - pointCard.usedPoints) /
|
||||
pointCard.totalPoints,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.textWhite,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Terpakai: ${pointCard.usedPoints}",
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Total: ${pointCard.totalPoints}",
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user