131 lines
4.7 KiB
Dart
131 lines
4.7 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:intl/intl.dart';
|
||
|
|
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
import 'package:fcs/model/employee_model.dart';
|
||
|
|
import 'package:fcs/theme/theme.dart';
|
||
|
|
import 'package:fcs/widget/progress.dart';
|
||
|
|
|
||
|
|
import '../theme/theme.dart';
|
||
|
|
import '../vo/user.dart';
|
||
|
|
import '../widget/local_text.dart';
|
||
|
|
import 'staff_editor.dart';
|
||
|
|
import 'util.dart';
|
||
|
|
|
||
|
|
class StaffList extends StatefulWidget {
|
||
|
|
@override
|
||
|
|
_StaffListState createState() => _StaffListState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _StaffListState extends State<StaffList> {
|
||
|
|
var dateFormatter = new DateFormat('dd MMM yyyy - hh:mm:ss a');
|
||
|
|
final double dotSize = 15.0;
|
||
|
|
bool _isLoading = false;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
var employeeModel = Provider.of<EmployeeModel>(context);
|
||
|
|
|
||
|
|
return LocalProgress(
|
||
|
|
inAsyncCall: _isLoading,
|
||
|
|
child: Scaffold(
|
||
|
|
appBar: AppBar(
|
||
|
|
backgroundColor: primaryColor,
|
||
|
|
title: LocalText(
|
||
|
|
context,
|
||
|
|
'staff.title',
|
||
|
|
color: Colors.white,
|
||
|
|
fontSize: 18,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
// floatingActionButton: FloatingActionButton(
|
||
|
|
// backgroundColor: primaryColor,
|
||
|
|
// child: Icon(Icons.add),
|
||
|
|
// onPressed: () {
|
||
|
|
// Navigator.push(
|
||
|
|
// context,
|
||
|
|
// MaterialPageRoute(builder: (context) => EmployeeEditor()),
|
||
|
|
// );
|
||
|
|
// },
|
||
|
|
// ),
|
||
|
|
body: new ListView.builder(
|
||
|
|
padding: EdgeInsets.only(left: 10, right: 10, top: 15),
|
||
|
|
shrinkWrap: true,
|
||
|
|
itemCount: employeeModel.employees.length,
|
||
|
|
itemBuilder: (BuildContext context, int index) {
|
||
|
|
User _user = employeeModel.employees[index];
|
||
|
|
return Container(
|
||
|
|
child: Card(
|
||
|
|
elevation: 10,
|
||
|
|
color: Colors.white,
|
||
|
|
child: InkWell(
|
||
|
|
onTap: () {
|
||
|
|
Navigator.push(
|
||
|
|
context,
|
||
|
|
MaterialPageRoute(
|
||
|
|
builder: (context) =>
|
||
|
|
StaffEditor(staff: _user)),
|
||
|
|
);
|
||
|
|
},
|
||
|
|
child: Row(
|
||
|
|
children: <Widget>[
|
||
|
|
Expanded(
|
||
|
|
child: new Padding(
|
||
|
|
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||
|
|
child: new Row(
|
||
|
|
children: <Widget>[
|
||
|
|
new Padding(
|
||
|
|
padding: new EdgeInsets.symmetric(
|
||
|
|
horizontal: 32.0 - dotSize / 2),
|
||
|
|
child: Image.asset(
|
||
|
|
"assets/employee.png",
|
||
|
|
width: 40,
|
||
|
|
height: 40,
|
||
|
|
color: primaryColor,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
new Expanded(
|
||
|
|
child: new Column(
|
||
|
|
crossAxisAlignment:
|
||
|
|
CrossAxisAlignment.start,
|
||
|
|
children: <Widget>[
|
||
|
|
new Text(
|
||
|
|
_user.name,
|
||
|
|
style: new TextStyle(
|
||
|
|
fontSize: 15.0,
|
||
|
|
color: secondaryColor),
|
||
|
|
),
|
||
|
|
new Text(
|
||
|
|
_user.phoneNumber,
|
||
|
|
style: new TextStyle(
|
||
|
|
fontSize: 13.0,
|
||
|
|
color: secondaryColor),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
_user.status == null
|
||
|
|
? Container()
|
||
|
|
: Row(
|
||
|
|
children: <Widget>[
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.all(8.0),
|
||
|
|
child: getStatus(_user.status),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|