111 lines
3.7 KiB
Dart
111 lines
3.7 KiB
Dart
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/local_app_bar.dart';
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../pagination/paginator_listview.dart';
|
|
import 'staff_editor.dart';
|
|
import 'staff_info.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
|
|
void initState() {
|
|
context.read<StaffModel>().loadPaginationStaffs();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
StaffModel staffModel = Provider.of<StaffModel>(context);
|
|
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: LocalAppBar(labelKey: "staff.list.title"),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: () {
|
|
Navigator.of(context).push(
|
|
CupertinoPageRoute(builder: (context) => StaffEditor()));
|
|
},
|
|
icon: Icon(Icons.add),
|
|
label: LocalText(context, "staff.new", color: Colors.white),
|
|
backgroundColor: primaryColor,
|
|
),
|
|
body: PaginatorListView<User>(
|
|
paginatorListener: staffModel.getStaffs!,
|
|
rowBuilder: (p) => _item(p),
|
|
color: primaryColor)),
|
|
);
|
|
}
|
|
|
|
Widget _item(User user) {
|
|
return InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).push(
|
|
CupertinoPageRoute(builder: (context) => StaffInfo(staff: user)));
|
|
},
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: new Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: new Row(
|
|
children: <Widget>[
|
|
new Padding(
|
|
padding: new EdgeInsets.symmetric(horizontal: 15),
|
|
child: Icon(MaterialCommunityIcons.account_hard_hat,
|
|
color: primaryColor, size: 30),
|
|
),
|
|
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: 2),
|
|
child: new Text(
|
|
user.fcsID ?? "",
|
|
style: new TextStyle(
|
|
fontSize: 15.0, color: Colors.grey),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 2),
|
|
child: new Text(
|
|
user.phoneNumber ?? "",
|
|
style: new TextStyle(
|
|
fontSize: 15.0, color: Colors.grey),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|