Files
fcs/lib/pages/staff/staff_list.dart

119 lines
3.7 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/user.dart';
2020-10-11 02:17:23 +06:30
import 'package:fcs/helpers/theme.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/staff/model/staff_model.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
2020-09-18 04:04:21 +06:30
import 'package:flutter/cupertino.dart';
2020-09-13 21:49:39 +06:30
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
2020-10-11 02:17:23 +06:30
2020-09-13 21:49:39 +06:30
import 'staff_editor.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) {
StaffModel staffModel = Provider.of<StaffModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
2020-09-18 04:04:21 +06:30
icon: new Icon(CupertinoIcons.back),
2020-09-13 21:49:39 +06:30
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: LocalText(
context,
'staff.list.title',
color: Colors.white,
fontSize: 20,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
2020-10-14 13:54:42 +06:30
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => StaffEditor()));
2020-09-13 21:49:39 +06:30
},
icon: Icon(Icons.add),
2020-09-15 07:13:41 +06:30
label: LocalText(context, "staff.new", color: Colors.white),
2020-09-13 21:49:39 +06:30
backgroundColor: primaryColor,
),
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
2020-10-19 05:13:49 +06:30
height: 1,
2020-09-13 21:49:39 +06:30
),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: staffModel.employees.length,
itemBuilder: (BuildContext context, int index) {
User user = staffModel.employees[index];
return _item(user);
}),
),
);
}
Widget _item(User user) {
2020-10-19 05:13:49 +06:30
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(
2021-09-10 14:29:55 +06:30
Icons.person,
2020-10-19 05:13:49 +06:30
color: primaryColor,
size: 40,
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
2021-09-10 15:23:13 +06:30
user.name ?? "",
2020-10-19 05:13:49 +06:30
style: new TextStyle(fontSize: 15.0),
2020-09-13 21:49:39 +06:30
),
2020-10-19 05:13:49 +06:30
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new Text(
2021-09-10 15:23:13 +06:30
user.phoneNumber ?? "",
2020-10-19 05:13:49 +06:30
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
2020-09-13 21:49:39 +06:30
),
2020-10-19 05:13:49 +06:30
],
),
2020-09-13 21:49:39 +06:30
),
2020-10-19 05:13:49 +06:30
],
2020-09-13 21:49:39 +06:30
),
2020-10-19 05:13:49 +06:30
),
2020-09-13 21:49:39 +06:30
),
2020-10-19 05:13:49 +06:30
],
),
2020-09-13 21:49:39 +06:30
);
}
}