update carton filter
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user