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,
|
||||
|
||||
Reference in New Issue
Block a user