preparing filterbutton in shipmentlist and UI of carton Info

This commit is contained in:
sma
2024-02-02 17:51:46 +06:30
parent 24f2dc110c
commit ea68085c44
6 changed files with 206 additions and 73 deletions

View File

@@ -8,6 +8,7 @@ import 'package:fcs/pages/widgets/progress.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';
import 'package:provider/provider.dart';
import '../../domain/entities/fcs_shipment.dart';
import 'fcs_shipment_editor.dart';
@@ -20,7 +21,7 @@ class FcsShipmentList extends StatefulWidget {
class _FcsShipmentListState extends State<FcsShipmentList> {
bool _isLoading = false;
int _selectedIndex = 1;
int _selectedIndex = 0;
@override
void initState() {
@@ -41,40 +42,14 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
Widget build(BuildContext context) {
var shipmentModel = Provider.of<FcsShipmentModel>(context);
final popupMenu = LocalPopupMenuButton(
popmenus: [
LocalPopupMenu(
id: 0, text: "All", selected: shipmentModel.selectedIndex == 0),
LocalPopupMenu(
id: 1, text: "Pending", selected: shipmentModel.selectedIndex == 1),
LocalPopupMenu(
id: 2,
text: "Processing",
selected: shipmentModel.selectedIndex == 2),
LocalPopupMenu(
id: 3, text: "Shipped", selected: shipmentModel.selectedIndex == 3),
LocalPopupMenu(
id: 4, text: "Arrived", selected: shipmentModel.selectedIndex == 4),
LocalPopupMenu(
id: 5,
text: "Invoiced",
selected: shipmentModel.selectedIndex == 5),
LocalPopupMenu(
id: 6, text: "Canceled", selected: shipmentModel.selectedIndex == 6)
],
popupMenuCallback: (p) {
setState(() {
_selectedIndex = p.id;
});
context.read<FcsShipmentModel>().onChanged(_selectedIndex);
},
);
return LocalProgress(
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: LocalAppBar(
labelKey: "FCSshipment.list.title", actions: [popupMenu]),
labelKey: "FCSshipment.list.title", actions: [
//popupMenu,
_menuFilteringWidget(context),
]),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
_newShipment();
@@ -93,4 +68,62 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => FcsShipmentEditor()));
}
Widget _menuFilteringWidget(BuildContext context) {
return PopupMenuButton<LocalPopupMenu>(
splashRadius: 25,
padding: const EdgeInsets.only(right: 15),
elevation: 3.2,
tooltip: 'This is tooltip',
onSelected: (choice) async {
setState(() {
_selectedIndex = choice.id;
});
await context.read<FcsShipmentModel>().onChanged(choice.id);
},
icon: Stack(
alignment: Alignment.center,
children: <Widget>[
const Icon(
Ionicons.filter,
color: Colors.white,
),
_selectedIndex != 0
? Positioned(
bottom: 15,
right: 0,
child: Container(
width: 10,
height: 10,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
),
)
: Container()
],
),
itemBuilder: (BuildContext context) {
return shipFiteringMenu.map((LocalPopupMenu choice) {
return PopupMenuItem<LocalPopupMenu>(
value: choice,
child: Row(
children: <Widget>[
Flexible(child: Text("${choice.text}")),
const SizedBox(
width: 10,
),
_selectedIndex == choice.id
? const Icon(
Icons.check,
color: Colors.grey,
)
: const SizedBox(),
],
),
);
}).toList();
});
}
}