add cartion filter and search

This commit is contained in:
tzw
2024-02-07 17:26:29 +06:30
parent 2d4cdb9620
commit caf20f4e67
39 changed files with 1274 additions and 1181 deletions

View File

@@ -9,7 +9,6 @@ class CartonListRow extends StatelessWidget {
final CallbackCartonSelect? callbackCartonSelect;
final Carton carton;
// const CartonListRow({this.carton, this.callbackCartonSelect});
CartonListRow({Key? key, required this.carton, this.callbackCartonSelect})
: super(key: key);
@@ -28,63 +27,83 @@ class CartonListRow extends StatelessWidget {
Navigator.pop(context);
if (callbackCartonSelect != null) callbackCartonSelect!(carton);
},
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new Padding(
padding: new EdgeInsets.symmetric(
horizontal: 25.0 - dotSize / 2),
child: Icon(
MaterialCommunityIcons.package,
color: primaryColor,
size: 30,
child: Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 7.0),
child: new Row(
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 5),
child: Icon(
MaterialCommunityIcons.package,
color: primaryColor,
size: 30,
),
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
carton.cartonNumber ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
new Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Row(
children: [
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
carton.cartonNumber ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
Padding(
padding: const EdgeInsets.only(top: 5),
child: new Text(
carton.userName ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
),
],
),
const SizedBox(width: 15),
IconButton(
onPressed: () {},
icon: Icon(AntDesign.qrcode,
color: Colors.black))
],
),
Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10),
child: new Text(
carton.userName ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8.0, bottom: 5, right: 10),
child: Row(
children: <Widget>[
new Text(
"${carton.cartonWeight.toStringAsFixed(2)} lb",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
],
),
),
],
],
),
),
),
),
],
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(carton.status ?? "",
style: TextStyle(
color: primaryColor,
fontSize: 15,
fontWeight: FontWeight.bold)),
Padding(
padding: const EdgeInsets.only(top: 5),
child: Row(
children: <Widget>[
new Text(
"${carton.cartonWeight.toStringAsFixed(2)} lb",
style:
new TextStyle(fontSize: 15.0, color: Colors.grey),
),
],
),
),
],
)
],
),
),
),
);

View File

@@ -2,9 +2,6 @@ import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton/model/carton_model.dart';
import 'package:fcs/pages/widgets/barcode_scanner.dart';
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
import 'package:fcs/pages/widgets/local_popupmenu.dart';
import 'package:fcs/pagination/paginator_listview.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
@@ -50,32 +47,12 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
@override
List<Widget> buildActions(BuildContext context) {
var boxModel = Provider.of<CartonModel>(context);
final popupMenu =
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return LocalPopupMenuButton(
popmenus: [
LocalPopupMenu(
id: 1,
textKey: "box.weight",
selected: boxModel.selectedIndexFilter == 1),
LocalPopupMenu(
id: 2,
textKey: "box.name",
selected: boxModel.selectedIndexFilter == 2)
],
popupMenuCallback: (p) => setState(() {
boxModel.selectedIndexFilter = p.id;
}));
});
return [
IconButton(
icon: Icon(MaterialCommunityIcons.barcode_scan,
size: 30, color: Colors.white),
onPressed: () => _scan(context),
),
popupMenu,
IconButton(
icon: Icon(Icons.clear),
onPressed: () => query = '',
@@ -113,7 +90,6 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
child: ListView(
children: snapshot.data!
.map((u) => CartonListRow(
key: ValueKey(u.id),
carton: u,
callbackCartonSelect: callbackCartonSelect,
))
@@ -143,18 +119,12 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
@override
Widget buildSuggestions(BuildContext context) {
final cartonModel = Provider.of<CartonModel>(context);
return Container(
padding: EdgeInsets.only(top: 5),
child: PaginatorListView<Carton>(
paginatorListener: cartonModel.cartonsByFilter!,
rowBuilder: (c) => CartonListRow(
key: ValueKey(c.id),
carton: c,
callbackCartonSelect: callbackCartonSelect,
),
color: primaryColor,
child: Center(
child: Opacity(
opacity: 0.2,
child: Icon(MaterialCommunityIcons.package,
size: 200, color: primaryColor)),
),
);
}