order load more
This commit is contained in:
parent
8bd61eb58e
commit
34555dd789
@ -8,64 +8,96 @@ import '../../../components/error/order_loader_error_state_widget.dart';
|
|||||||
import '../../../components/loader/loader_with_text.dart';
|
import '../../../components/loader/loader_with_text.dart';
|
||||||
import 'order_title.dart';
|
import 'order_title.dart';
|
||||||
|
|
||||||
class OrderLeftPanel extends StatelessWidget {
|
class OrderLeftPanel extends StatefulWidget {
|
||||||
final String status;
|
final String status;
|
||||||
final OrderLoaderState state;
|
final OrderLoaderState state;
|
||||||
const OrderLeftPanel({super.key, required this.state, required this.status});
|
const OrderLeftPanel({super.key, required this.state, required this.status});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<OrderLeftPanel> createState() => _OrderLeftPanelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OrderLeftPanelState extends State<OrderLeftPanel> {
|
||||||
|
ScrollController scrollController = ScrollController();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return NotificationListener<ScrollNotification>(
|
||||||
children: [
|
onNotification: (notification) {
|
||||||
OrderTitle(
|
if (notification is ScrollEndNotification &&
|
||||||
startDate: state.startDate,
|
scrollController.position.extentAfter == 0) {
|
||||||
endDate: state.endDate,
|
context.read<OrderLoaderBloc>().add(
|
||||||
title: status == 'pending' ? "Pending Pesanan" : "Daftar Pesanan",
|
OrderLoaderEvent.fetched(status: widget.status),
|
||||||
onChanged: (value) {
|
);
|
||||||
Future.delayed(const Duration(milliseconds: 800), () {
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
OrderTitle(
|
||||||
|
startDate: widget.state.startDate,
|
||||||
|
endDate: widget.state.endDate,
|
||||||
|
title: widget.status == 'pending'
|
||||||
|
? "Pending Pesanan"
|
||||||
|
: "Daftar Pesanan",
|
||||||
|
onChanged: (value) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 800), () {
|
||||||
|
context.read<OrderLoaderBloc>().add(
|
||||||
|
OrderLoaderEvent.searchChange(value),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onDateRangeChanged: (start, end) {
|
||||||
context.read<OrderLoaderBloc>().add(
|
context.read<OrderLoaderBloc>().add(
|
||||||
OrderLoaderEvent.searchChange(value),
|
OrderLoaderEvent.dateTimeRangeChange(start!, end!),
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
},
|
),
|
||||||
onDateRangeChanged: (start, end) {
|
Expanded(
|
||||||
context.read<OrderLoaderBloc>().add(
|
child: widget.state.failureOption.fold(
|
||||||
OrderLoaderEvent.dateTimeRangeChange(start!, end!),
|
() {
|
||||||
);
|
if (widget.state.isFetching) {
|
||||||
},
|
return Center(child: LoaderWithText());
|
||||||
),
|
}
|
||||||
Expanded(
|
|
||||||
child: state.failureOption.fold(() {
|
|
||||||
if (state.isFetching) {
|
|
||||||
return Center(child: LoaderWithText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.orders.isEmpty) {
|
if (widget.state.orders.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Belum ada transaksi saat ini. ",
|
"Belum ada transaksi saat ini. ",
|
||||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: state.orders.length,
|
|
||||||
itemBuilder: (context, index) => GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
context.read<OrderLoaderBloc>().add(
|
|
||||||
OrderLoaderEvent.setSelectedOrder(state.orders[index]),
|
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
child: OrderCard(
|
|
||||||
order: state.orders[index],
|
return ListView.builder(
|
||||||
isActive: state.orders[index] == state.selectedOrder,
|
itemCount: widget.state.orders.length,
|
||||||
),
|
controller: scrollController,
|
||||||
|
itemBuilder: (context, index) => GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
context.read<OrderLoaderBloc>().add(
|
||||||
|
OrderLoaderEvent.setSelectedOrder(
|
||||||
|
widget.state.orders[index],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: OrderCard(
|
||||||
|
order: widget.state.orders[index],
|
||||||
|
isActive:
|
||||||
|
widget.state.orders[index] ==
|
||||||
|
widget.state.selectedOrder,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(f) => OrderLoaderErrorStateWidget(
|
||||||
|
failure: f,
|
||||||
|
status: widget.status,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}, (f) => OrderLoaderErrorStateWidget(failure: f, status: status)),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user