feat: pull to refresh on home

This commit is contained in:
efrilm 2025-08-20 13:57:00 +07:00
parent 5a83bc4049
commit 3f75bffd09
2 changed files with 117 additions and 106 deletions

View File

@ -67,7 +67,12 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColor.background, backgroundColor: AppColor.background,
body: BlocBuilder<HomeBloc, HomeState>( body: RefreshIndicator(
onRefresh: () {
context.read<HomeBloc>().add(HomeEvent.fetchedDashboard());
return Future.value();
},
child: BlocBuilder<HomeBloc, HomeState>(
builder: (context, state) { builder: (context, state) {
return CustomScrollView( return CustomScrollView(
physics: const BouncingScrollPhysics( physics: const BouncingScrollPhysics(
@ -100,7 +105,8 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
return FlexibleSpaceBar( return FlexibleSpaceBar(
title: Opacity( title: Opacity(
opacity: collapseProgress, // Title muncul saat collapse opacity:
collapseProgress, // Title muncul saat collapse
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@ -181,6 +187,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
); );
}, },
), ),
),
); );
} }
} }

View File

@ -13,6 +13,10 @@ class HomeTopProduct extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (products.isEmpty) {
return const SizedBox.shrink();
}
return Padding( return Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 24, vertical: 24,