2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
2020-10-18 02:38:46 +06:30
|
|
|
import 'package:fcs/pages/carton/model/carton_model.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_popupmenu.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-06-04 01:36:49 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'box_editor.dart';
|
|
|
|
|
import 'box_list_row.dart';
|
2020-06-04 01:36:49 +06:30
|
|
|
|
|
|
|
|
class BoxList extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_BoxListState createState() => _BoxListState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BoxListState extends State<BoxList> {
|
|
|
|
|
bool _isLoading = false;
|
2020-10-16 17:57:58 +06:30
|
|
|
var _controller = ScrollController();
|
2020-06-04 01:36:49 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2020-10-16 17:57:58 +06:30
|
|
|
_controller.addListener(() async {
|
|
|
|
|
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
2020-10-18 02:38:46 +06:30
|
|
|
Provider.of<CartonModel>(context, listen: false).loadMore();
|
2020-10-16 17:57:58 +06:30
|
|
|
}
|
|
|
|
|
});
|
2020-10-18 02:38:46 +06:30
|
|
|
Provider.of<CartonModel>(context, listen: false).initData();
|
2020-06-04 01:36:49 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-18 02:38:46 +06:30
|
|
|
var boxModel = Provider.of<CartonModel>(context);
|
2020-10-15 17:33:43 +06:30
|
|
|
final popupMenu = LocalPopupMenuButton(
|
|
|
|
|
popmenus: [
|
2020-10-16 17:57:58 +06:30
|
|
|
LocalPopupMenu(
|
|
|
|
|
id: 1,
|
|
|
|
|
textKey: "box.popupmenu.active",
|
|
|
|
|
selected: boxModel.selectedIndex == 1),
|
|
|
|
|
LocalPopupMenu(
|
|
|
|
|
id: 2,
|
|
|
|
|
textKey: "box.popupmenu.delivered",
|
|
|
|
|
selected: boxModel.selectedIndex == 2)
|
2020-10-15 17:33:43 +06:30
|
|
|
],
|
|
|
|
|
popupMenuCallback: (p) => this.setState(() {
|
2020-10-16 17:57:58 +06:30
|
|
|
boxModel.selectedIndex = p.id;
|
2020-10-15 17:33:43 +06:30
|
|
|
}),
|
|
|
|
|
);
|
2020-06-04 01:36:49 +06:30
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: DefaultTabController(
|
|
|
|
|
length: 2,
|
|
|
|
|
child: Scaffold(
|
2020-10-15 17:33:43 +06:30
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(CupertinoIcons.back),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: LocalText(context, "boxes.name",
|
|
|
|
|
color: Colors.white, fontSize: 20),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
color: Colors.white,
|
2020-06-04 01:36:49 +06:30
|
|
|
),
|
2020-10-15 17:33:43 +06:30
|
|
|
iconSize: 30, onPressed: () {},
|
|
|
|
|
// onPressed: () => showPlacesSearch(context),
|
2020-06-04 01:36:49 +06:30
|
|
|
),
|
2020-10-15 17:33:43 +06:30
|
|
|
popupMenu
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
_newBox();
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(Icons.add),
|
|
|
|
|
label: LocalText(context, "boxes.new", color: Colors.white),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
),
|
2020-10-16 17:57:58 +06:30
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: RefreshIndicator(
|
|
|
|
|
child: new ListView.separated(
|
|
|
|
|
physics: AlwaysScrollableScrollPhysics(),
|
|
|
|
|
controller: _controller,
|
|
|
|
|
separatorBuilder: (context, index) => Divider(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
),
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
padding: EdgeInsets.only(top: 15),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: boxModel.boxes.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return BoxListRow(box: boxModel.boxes[index]);
|
|
|
|
|
}),
|
|
|
|
|
onRefresh: () => boxModel.refresh(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
boxModel.isLoading
|
|
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text("Loading...",
|
|
|
|
|
style: TextStyle(color: Colors.white)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
),
|
2020-10-15 17:33:43 +06:30
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 17:33:43 +06:30
|
|
|
_newBox() {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
CupertinoPageRoute(builder: (context) => BoxEditor()),
|
2020-06-04 01:36:49 +06:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|