151 lines
5.1 KiB
Dart
Raw Normal View History

2025-08-02 10:50:48 +07:00
import 'package:enaklo_pos/core/components/components.dart';
2025-08-15 16:09:25 +07:00
import 'package:enaklo_pos/core/components/date_range_picker.dart';
2025-08-02 10:50:48 +07:00
import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
2025-08-03 18:29:30 +07:00
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
2025-08-02 10:50:48 +07:00
import 'package:flutter/material.dart';
2025-08-03 18:29:30 +07:00
import 'package:flutter_bloc/flutter_bloc.dart';
2025-08-02 10:50:48 +07:00
class SalesTitle extends StatelessWidget {
2025-08-03 14:39:15 +07:00
final String title;
2025-08-02 10:50:48 +07:00
final DateTime startDate;
final DateTime endDate;
final Function(String) onChanged;
2025-08-15 16:09:25 +07:00
final void Function(DateTime? start, DateTime? end) onDateRangeChanged;
2025-08-02 10:50:48 +07:00
const SalesTitle(
{super.key,
required this.startDate,
required this.endDate,
required this.onChanged,
2025-08-03 14:39:15 +07:00
required this.onDateRangeChanged,
required this.title});
2025-08-02 10:50:48 +07:00
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: context.deviceHeight * 0.1,
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
decoration: BoxDecoration(
color: AppColors.white,
border: Border(
bottom: BorderSide(
color: AppColors.background,
width: 1.0,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2025-08-03 14:39:15 +07:00
IconButton(
onPressed: () => context.pop(),
icon: Icon(Icons.arrow_back, color: AppColors.black),
2025-08-02 10:50:48 +07:00
),
SpaceWidth(16),
Expanded(
child: Text(
2025-08-03 14:39:15 +07:00
title,
2025-08-02 10:50:48 +07:00
style: TextStyle(
color: AppColors.black,
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 12.0,
),
decoration: BoxDecoration(
color: AppColors.white,
border: Border(
bottom: BorderSide(
color: AppColors.background,
width: 1.0,
),
),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
startDate.toFormattedDate2() == endDate.toFormattedDate2()
? startDate.toFormattedDate2()
: '${startDate.toFormattedDate2()} - ${endDate.toFormattedDate2()}',
style: TextStyle(
color: AppColors.black,
fontWeight: FontWeight.w600,
),
),
2025-08-03 18:29:30 +07:00
BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const SizedBox.shrink(),
2025-08-06 15:46:22 +07:00
loaded: (orders, totalOrder, _, __, ___) => Text(
2025-08-03 18:29:30 +07:00
'$totalOrder Pesanan',
style: TextStyle(
color: AppColors.black,
fontWeight: FontWeight.w600,
),
),
);
},
2025-08-02 10:50:48 +07:00
),
],
),
SpaceHeight(16),
Row(
children: [
Expanded(
child: TextFormField(
onChanged: onChanged,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
),
hintText: 'Cari Pesanan',
),
),
),
SpaceWidth(12),
GestureDetector(
2025-08-15 16:09:25 +07:00
onTap: () => DateRangePickerModal.show(
2025-08-02 10:50:48 +07:00
context: context,
2025-08-15 16:09:25 +07:00
initialStartDate: startDate,
initialEndDate: endDate,
primaryColor: AppColors.primary,
onChanged: onDateRangeChanged,
2025-08-02 10:50:48 +07:00
),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColors.primary,
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.filter_list_outlined,
color: AppColors.white,
size: 24,
),
),
),
],
),
],
),
),
],
);
}
}