Files
fcs/lib/pages/customer_list.dart
2020-09-04 15:30:10 +06:30

144 lines
5.3 KiB
Dart

import 'package:fcs/model/customer_model.dart';
import 'package:fcs/pages/search_page.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/widget/progress.dart';
import '../fcs/common/helpers/theme.dart';
import '../vo/user.dart';
import '../widget/local_text.dart';
import 'customer_editor.dart';
import 'invitation_page.dart';
import '../fcs/common/pages/util.dart';
class CustomerList extends StatefulWidget {
@override
_CustomerListState createState() => _CustomerListState();
}
class _CustomerListState extends State<CustomerList> {
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 customerModel = Provider.of<CustomerModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
),
iconSize: 30,
onPressed: () => showPlacesSearch(context),
),
],
backgroundColor: primaryColor,
title: LocalText(
context,
'customer.list.title',
color: Colors.white,
fontSize: 20,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(BottomUpPageRoute(InvitationPage()));
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("customer.invite")),
backgroundColor: primaryColor,
),
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(left: 15, right: 15, top: 15),
shrinkWrap: true,
itemCount: customerModel.customers.length,
itemBuilder: (BuildContext context, int index) {
User user = customerModel.customers[index];
return Stack(
children: <Widget>[
InkWell(
onTap: () {
Navigator.of(context).push(
BottomUpPageRoute(CustomerEditor(customer: 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(
Feather.user,
color: primaryColor,
size: 40,
),
),
new Expanded(
child: new Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
new Text(
user.name,
style: new TextStyle(
fontSize: 15.0,
color: primaryColor),
),
Padding(
padding:
const EdgeInsets.only(top: 8.0),
child: new Text(
user.phoneNumber,
style: new TextStyle(
fontSize: 15.0,
color: Colors.grey),
),
),
],
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 10),
child: getStatus(user.status),
),
],
),
),
],
);
}),
),
);
}
}