feat: invetory range date
This commit is contained in:
@@ -107,120 +107,143 @@ class _InventoryPageState extends State<InventoryPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body:
|
||||
BlocBuilder<
|
||||
InventoryAnalyticLoaderBloc,
|
||||
InventoryAnalyticLoaderState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
return FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder: (context, innerBoxIsScrolled) {
|
||||
return [
|
||||
_buildSliverAppBar(),
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: InventorySliverTabBarDelegate(
|
||||
tabBar: TabBar(
|
||||
controller: _tabController,
|
||||
indicator: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: AppColor.primaryGradient,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
return BlocListener<
|
||||
InventoryAnalyticLoaderBloc,
|
||||
InventoryAnalyticLoaderState
|
||||
>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.dateFrom != current.dateFrom ||
|
||||
previous.dateTo != current.dateTo,
|
||||
listener: (context, state) {
|
||||
context.read<InventoryAnalyticLoaderBloc>().add(
|
||||
InventoryAnalyticLoaderEvent.fetched(),
|
||||
);
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body:
|
||||
BlocBuilder<
|
||||
InventoryAnalyticLoaderBloc,
|
||||
InventoryAnalyticLoaderState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
return FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder: (context, innerBoxIsScrolled) {
|
||||
return [
|
||||
_buildSliverAppBar(),
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: InventorySliverTabBarDelegate(
|
||||
startDate: state.dateFrom,
|
||||
endDate: state.dateTo,
|
||||
onDateRangeChanged: (startDate, endDate) {
|
||||
context.read<InventoryAnalyticLoaderBloc>().add(
|
||||
InventoryAnalyticLoaderEvent.rangeDateChanged(
|
||||
startDate!,
|
||||
endDate!,
|
||||
),
|
||||
);
|
||||
},
|
||||
tabBar: TabBar(
|
||||
controller: _tabController,
|
||||
indicator: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: AppColor.primaryGradient,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 4),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
indicatorPadding: const EdgeInsets.all(6),
|
||||
labelColor: AppColor.textWhite,
|
||||
unselectedLabelColor: AppColor.textSecondary,
|
||||
labelStyle: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
),
|
||||
unselectedLabelStyle: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13,
|
||||
),
|
||||
dividerColor: Colors.transparent,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
overlayColor: MaterialStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
tabs: [
|
||||
Tab(
|
||||
height: 40,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_rounded,
|
||||
size: 16,
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text('Produk'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Tab(
|
||||
height: 40,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.restaurant_menu_rounded,
|
||||
size: 16,
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text('Bahan'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
indicatorPadding: const EdgeInsets.all(6),
|
||||
labelColor: AppColor.textWhite,
|
||||
unselectedLabelColor: AppColor.textSecondary,
|
||||
labelStyle: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
),
|
||||
unselectedLabelStyle: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13,
|
||||
),
|
||||
dividerColor: Colors.transparent,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
overlayColor: MaterialStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
tabs: [
|
||||
Tab(
|
||||
height: 40,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_rounded,
|
||||
size: 16,
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text('Produk'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Tab(
|
||||
height: 40,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.restaurant_menu_rounded,
|
||||
size: 16,
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text('Bahan'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildProductTab(state.inventoryAnalytic),
|
||||
_buildIngredientTab(state.inventoryAnalytic),
|
||||
],
|
||||
];
|
||||
},
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildProductTab(state.inventoryAnalytic),
|
||||
_buildIngredientTab(state.inventoryAnalytic),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/field/date_range_picker_field.dart';
|
||||
|
||||
class InventorySliverTabBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
final TabBar tabBar;
|
||||
final DateTime? startDate;
|
||||
final DateTime? endDate;
|
||||
final Function(DateTime?, DateTime?)? onDateRangeChanged;
|
||||
|
||||
InventorySliverTabBarDelegate({required this.tabBar});
|
||||
InventorySliverTabBarDelegate({
|
||||
required this.tabBar,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.onDateRangeChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
double get minExtent => 60;
|
||||
double get minExtent => 120; // Increased height to accommodate date picker
|
||||
|
||||
@override
|
||||
double get maxExtent => 60;
|
||||
double get maxExtent => 120;
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
@@ -31,22 +40,40 @@ class InventorySliverTabBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(
|
||||
color: AppColor.primary.withOpacity(0.1),
|
||||
width: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
// Date Range Picker Section
|
||||
if (onDateRangeChanged != null)
|
||||
Expanded(
|
||||
child: DateRangePickerField(
|
||||
maxDate: DateTime.now(),
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
onChanged: onDateRangeChanged!,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Tab Bar Section
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(
|
||||
color: AppColor.primary.withOpacity(0.1),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: tabBar,
|
||||
),
|
||||
),
|
||||
child: tabBar,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRebuild(InventorySliverTabBarDelegate oldDelegate) {
|
||||
return false;
|
||||
return oldDelegate.startDate != startDate ||
|
||||
oldDelegate.endDate != endDate ||
|
||||
oldDelegate.tabBar != tabBar;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user