Files
fcs/lib/pages/fcs_shipment/fcs_shipment_list.dart

136 lines
4.2 KiB
Dart
Raw Permalink Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
2024-01-25 17:40:35 +06:30
import 'package:fcs/pages/widgets/local_app_bar.dart';
2024-02-07 17:26:29 +06:30
import 'package:fcs/domain/vo/local_popupmenu.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
2024-01-24 16:54:08 +06:30
import 'package:fcs/pagination/paginator_listview.dart';
2020-10-08 03:32:52 +06:30
import 'package:flutter/cupertino.dart';
2020-06-01 14:24:45 +06:30
import 'package:flutter/material.dart';
2020-10-15 19:40:03 +06:30
import 'package:provider/provider.dart';
2024-01-24 16:54:08 +06:30
import '../../domain/entities/fcs_shipment.dart';
2020-10-07 02:33:06 +06:30
import 'fcs_shipment_editor.dart';
import 'fcs_shipment_list_row.dart';
2020-06-01 14:24:45 +06:30
2020-10-07 02:33:06 +06:30
class FcsShipmentList extends StatefulWidget {
2025-03-12 17:49:27 +06:30
const FcsShipmentList({super.key});
2020-06-01 14:24:45 +06:30
@override
2020-10-07 02:33:06 +06:30
_FcsShipmentListState createState() => _FcsShipmentListState();
2020-06-01 14:24:45 +06:30
}
2020-10-07 02:33:06 +06:30
class _FcsShipmentListState extends State<FcsShipmentList> {
2025-03-12 17:49:27 +06:30
bool isLoading = false;
int _selectedIndex = 0;
2020-06-01 14:24:45 +06:30
@override
void initState() {
super.initState();
2024-01-24 16:54:08 +06:30
_init();
}
2020-06-01 14:24:45 +06:30
2024-01-24 16:54:08 +06:30
_init() {
var model = context.read<FcsShipmentModel>();
_selectedIndex = model.selectedIndex;
model.loadFcsShipments(_selectedIndex);
if (mounted) {
setState(() {});
}
2020-06-01 14:24:45 +06:30
}
@override
Widget build(BuildContext context) {
2020-10-07 18:19:12 +06:30
var shipmentModel = Provider.of<FcsShipmentModel>(context);
2024-02-07 17:26:29 +06:30
return LocalProgress(
2025-03-12 17:49:27 +06:30
inAsyncCall: isLoading,
2020-06-01 14:24:45 +06:30
child: Scaffold(
appBar: LocalAppBar(labelKey: "FCSshipment.list.title", actions: [
_menuFilteringWidget(context),
]),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
_newShipment();
},
icon: Icon(Icons.add),
label: LocalText(context, "FCSshipment.add", color: Colors.white),
backgroundColor: primaryColor),
body: PaginatorListView<FcsShipment>(
paginatorListener: shipmentModel.fcsShipments!,
rowBuilder: (p) => FcsShipmentListRow(shipment: p),
color: primaryColor),
));
2020-06-01 14:24:45 +06:30
}
_newShipment() {
2020-10-14 13:54:42 +06:30
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => FcsShipmentEditor()));
2020-06-01 14:24:45 +06:30
}
2024-02-07 17:26:29 +06:30
Widget _menuFilteringWidget(BuildContext context) {
2025-03-12 17:49:27 +06:30
return Padding(
padding: const EdgeInsets.only(right: 5),
child: PopupMenuButton<LocalPopupMenu>(
elevation: 3.2,
tooltip: '',
onSelected: (choice) async {
setState(() {
_selectedIndex = choice.id;
});
2025-03-12 17:49:27 +06:30
await context.read<FcsShipmentModel>().onChanged(choice.id);
},
icon: SizedBox(
width: 30,
height: 30,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
const Icon(
Icons.filter_list,
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()
],
),
2025-03-12 17:49:27 +06:30
),
itemBuilder: (BuildContext context) {
return shipFiteringMenu.map((LocalPopupMenu choice) {
return PopupMenuItem<LocalPopupMenu>(
value: choice,
child: Row(
children: <Widget>[
Flexible(
child: Text("${choice.text}",
style: TextStyle(color: Colors.black))),
const SizedBox(
width: 10,
),
2025-03-12 17:49:27 +06:30
_selectedIndex == choice.id
? const Icon(
Icons.check,
color: Colors.grey,
)
: const SizedBox(),
],
),
);
}).toList();
}),
);
}
2020-06-01 14:24:45 +06:30
}