2025-08-18 17:27:36 +07:00

80 lines
2.1 KiB
Dart

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,
this.startDate,
this.endDate,
this.onDateRangeChanged,
});
@override
double get minExtent => 120; // Increased height to accommodate date picker
@override
double get maxExtent => 120;
@override
Widget build(
BuildContext context,
double shrinkOffset,
bool overlapsContent,
) {
return Container(
decoration: BoxDecoration(
color: AppColor.surface,
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(0.05),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
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,
),
],
),
);
}
@override
bool shouldRebuild(InventorySliverTabBarDelegate oldDelegate) {
return oldDelegate.startDate != startDate ||
oldDelegate.endDate != endDate ||
oldDelegate.tabBar != tabBar;
}
}