update carton filter

This commit is contained in:
tzw
2024-03-04 09:23:05 +06:30
parent 9088adf6f4
commit c66734d386
3 changed files with 49 additions and 32 deletions

View File

@@ -118,6 +118,7 @@ const carton_invoiced_status = "invoiced";
const carton_canceled_status = "canceled";
const all_status = "All stauts";
const all = "All";
const see_all ="See All";
// shipment status
const shipment_pending_status = "pending";

View File

@@ -486,11 +486,9 @@ class _CartonFilterState extends State<CartonFilter> {
}
_clearFilter() async {
await context.read<CartonModel>().filterCarton(
FcsShipment(shipmentNumber: "All shipments", id: all),
User(id: all, name: "All"),
User(id: all, name: "All"),
all_status);
var model = context.read<CartonModel>();
await model.filterCarton(model.defaultShipment, User(id: all, name: "All"),
User(id: all, name: "All"), all_status);
Navigator.pop(context, true);
}

View File

@@ -8,6 +8,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:provider/provider.dart';
import '../../domain/constants.dart';
import '../../domain/entities/carton.dart';
import '../../pagination/paginator_listview.dart';
import '../carton_search/carton_search.dart';
@@ -38,6 +39,11 @@ class _CartonListState extends State<CartonList> {
var model = context.read<CartonModel>();
_shipments = await context.read<FcsShipmentModel>().getShipments();
_shipments.insert(0, model.defaultShipment);
if (_shipments.length > shipmentCountForCartonFilter) {
_shipments.insert(_shipments.length,
FcsShipment(shipmentNumber: "See All", id: see_all));
}
_selectedShipment = model.shipment ?? model.defaultShipment;
model.loadPaginationCartons();
@@ -66,18 +72,22 @@ class _CartonListState extends State<CartonList> {
child: ActionChip(
shape: StadiumBorder(
side: BorderSide(
color: _selectedShipment?.id == g.id
? primaryColor
: Colors.grey.shade300)),
color: g.id == see_all
? Colors.transparent
: _selectedShipment?.id == g.id
? primaryColor
: Colors.grey.shade300)),
padding: const EdgeInsets.all(8),
onPressed: () {
_filterShipment(g);
},
label: Text(g.shipmentNumber ?? "",
style: TextStyle(
color: _selectedShipment?.id == g.id
color: g.id == see_all
? primaryColor
: labelColor,
: _selectedShipment?.id == g.id
? primaryColor
: labelColor,
fontWeight: FontWeight.normal,
fontSize: 14,
fontFamily: "Poppins")),
@@ -289,7 +299,8 @@ class _CartonListState extends State<CartonList> {
),
model.filterByStatus != null ||
model.filterBySender != null ||
model.filterByConsingee != null
model.filterByConsingee != null ||
model.shipment != null
? Positioned(
bottom: 15,
right: 0,
@@ -305,31 +316,38 @@ class _CartonListState extends State<CartonList> {
: Container()
],
),
onPressed: () async {
bool? updated = await showModalBottomSheet(
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(top: Radius.circular(10))),
builder: (ctx) => DraggableScrollableSheet(
initialChildSize: 0.6,
minChildSize: 0.6,
expand: false,
builder: (_, controller) =>
CartonFilter(controller: controller)));
var model = context.read<CartonModel>();
if (updated ?? false) {
setState(() {
_selectedShipment = model.shipment ?? model.defaultShipment;
});
}
onPressed: () {
_showFilter();
});
}
_showFilter() async {
bool? updated = await showModalBottomSheet(
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(10))),
builder: (ctx) => DraggableScrollableSheet(
initialChildSize: 0.6,
minChildSize: 0.6,
expand: false,
builder: (_, controller) => CartonFilter(controller: controller)));
var model = context.read<CartonModel>();
if (updated ?? false) {
setState(() {
_selectedShipment = model.shipment ?? model.defaultShipment;
});
}
}
_filterShipment(FcsShipment shipment) async {
if (shipment.id == see_all) {
_showFilter();
return;
}
setState(() {
_selectedShipment = shipment;
});