149 lines
5.2 KiB
Dart
149 lines
5.2 KiB
Dart
|
|
import 'package:fcs/domain/entities/user.dart';
|
||
|
|
import 'package:fcs/helpers/theme.dart';
|
||
|
|
import 'package:fcs/pages/customer/customer_editor.dart';
|
||
|
|
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||
|
|
import 'package:fcs/pages/invoice/invoice_editor.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:intl/intl.dart';
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
|
||
|
|
class InvoiceCustomerList extends StatefulWidget {
|
||
|
|
@override
|
||
|
|
_InvoiceCustomerListState createState() => _InvoiceCustomerListState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _InvoiceCustomerListState extends State<InvoiceCustomerList> {
|
||
|
|
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(CupertinoIcons.back),
|
||
|
|
onPressed: () => Navigator.of(context).pop(),
|
||
|
|
),
|
||
|
|
backgroundColor: primaryColor,
|
||
|
|
title: LocalText(
|
||
|
|
context,
|
||
|
|
"customer.list.title",
|
||
|
|
fontSize: 20,
|
||
|
|
color: Colors.white,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
body: Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
|
children: [
|
||
|
|
Expanded(
|
||
|
|
child: ListView.separated(
|
||
|
|
separatorBuilder: (context, index) => Divider(
|
||
|
|
color: Colors.grey,
|
||
|
|
),
|
||
|
|
scrollDirection: Axis.vertical,
|
||
|
|
shrinkWrap: true,
|
||
|
|
itemCount: customerModel.customers.length,
|
||
|
|
itemBuilder: (BuildContext context, int index) {
|
||
|
|
User customer = customerModel.customers[index];
|
||
|
|
return _item(customer);
|
||
|
|
}),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Widget _item(User customer) {
|
||
|
|
return InkWell(
|
||
|
|
onTap: () {
|
||
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
||
|
|
builder: (context) => InvoiceEditor(customer: customer)));
|
||
|
|
},
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
||
|
|
child: Row(
|
||
|
|
children: <Widget>[
|
||
|
|
Expanded(
|
||
|
|
child: new Padding(
|
||
|
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||
|
|
child: new Row(
|
||
|
|
children: <Widget>[
|
||
|
|
InkWell(
|
||
|
|
onTap: () => _select(customer),
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.all(5.0),
|
||
|
|
child: Container(
|
||
|
|
padding: const EdgeInsets.only(
|
||
|
|
left: 10.0, right: 10, top: 6, bottom: 6),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: primaryColor,
|
||
|
|
borderRadius:
|
||
|
|
BorderRadius.all(Radius.circular(35.0))),
|
||
|
|
child: Text(
|
||
|
|
customer.initial,
|
||
|
|
style: TextStyle(fontSize: 30, color: Colors.white),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
new Expanded(
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.only(left: 8.0),
|
||
|
|
child: new Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
|
children: <Widget>[
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.only(top: 2.0),
|
||
|
|
child: new Text(
|
||
|
|
customer.name,
|
||
|
|
style: new TextStyle(
|
||
|
|
fontSize: 20.0, color: primaryColor),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.only(top: 2.0),
|
||
|
|
child: new Text(
|
||
|
|
customer.getLastMessage,
|
||
|
|
style: new TextStyle(
|
||
|
|
fontSize: 15.0, color: Colors.grey),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
|
children: [
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.only(right: 5),
|
||
|
|
child: Text(customer.getLastMessageTime),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
_select(User customer) {
|
||
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
||
|
|
builder: (context) => CustomerEditor(customer: customer)));
|
||
|
|
}
|
||
|
|
}
|