add shipments

This commit is contained in:
Sai Naw Wun
2020-10-19 05:13:49 +06:30
parent 4f8bde40b0
commit c619ae3f22
57 changed files with 1886 additions and 724 deletions

View File

@@ -85,4 +85,29 @@ class StaffModel extends BaseModel {
Future<User> findUser(String phoneNumber) {
return Services.instance.userService.findUser(phoneNumber);
}
Future<List<User>> getPickupEmployees() async {
if (user == null || !user.hasShipment()) return [];
return _getUsers(privilege_shipment);
}
Future<List<User>> _getUsers(String privilege) async {
List<User> users = [];
try {
var snaps = await Firestore.instance
.collection("/$user_collection")
.where("is_employee", isEqualTo: true)
.where("is_sys_admin", isEqualTo: false)
.where("privileges", arrayContains: privilege)
.getDocuments(source: Source.server);
users = snaps.documents.map((documentSnapshot) {
var user =
User.fromMap(documentSnapshot.data, documentSnapshot.documentID);
return user;
}).toList();
} catch (e) {
log.warning("Error!! $e");
}
return users;
}
}

View File

@@ -1,7 +1,6 @@
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/staff/model/staff_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
@@ -55,9 +54,9 @@ class _StaffListState extends State<StaffList> {
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
height: 1,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(left: 5, right: 5, top: 5),
shrinkWrap: true,
itemCount: staffModel.employees.length,
itemBuilder: (BuildContext context, int index) {
@@ -69,56 +68,52 @@ class _StaffListState extends State<StaffList> {
}
Widget _item(User user) {
return Stack(
children: <Widget>[
InkWell(
onTap: () {
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => StaffEditor(staff: user)));
},
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: 32.0 - dotSize / 2),
child: Icon(
MaterialCommunityIcons.worker,
color: primaryColor,
size: 40,
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
user.name,
style: new TextStyle(fontSize: 15.0),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new Text(
user.phoneNumber,
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
),
],
),
),
],
return InkWell(
onTap: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => StaffEditor(staff: user)));
},
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: 32.0 - dotSize / 2),
child: Icon(
MaterialCommunityIcons.worker,
color: primaryColor,
size: 40,
),
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
user.name,
style: new TextStyle(fontSize: 15.0),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new Text(
user.phoneNumber,
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
),
],
),
),
],
),
],
),
),
),
],
],
),
);
}
}