Files
fcs/lib/pages/invoice/payment_page.dart

222 lines
6.8 KiB
Dart
Raw Normal View History

2020-10-16 21:38:39 +06:30
import 'dart:io';
2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/invoice.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
2020-10-16 21:38:39 +06:30
import 'package:fcs/pages/invoice/payment_page_edit.dart';
import 'package:fcs/pages/widgets/image_file_picker.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/pages/widgets/input_text.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/local_text.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/pages/widgets/local_title.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/progress.dart';
2020-10-16 21:38:39 +06:30
import 'package:fcs/pages/widgets/show_img.dart';
2020-10-14 13:54:42 +06:30
import 'package:flutter/cupertino.dart';
2020-06-24 16:06:15 +06:30
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
class PaymentPage extends StatefulWidget {
final Invoice invoice;
PaymentPage({this.invoice});
@override
_PaymentPageState createState() => _PaymentPageState();
}
class _PaymentPageState extends State<PaymentPage> {
2020-10-14 20:56:46 +06:30
TextEditingController _amountController = new TextEditingController();
2020-06-24 16:06:15 +06:30
var dateFormatter = new DateFormat('dd MMM yyyy');
Invoice _invoice = new Invoice();
bool _isLoading = false;
2020-10-14 20:56:46 +06:30
2020-06-24 16:06:15 +06:30
bool isNew;
2020-10-16 21:38:39 +06:30
File _file;
2020-06-24 16:06:15 +06:30
@override
void initState() {
if (widget.invoice != null) {
_invoice = widget.invoice;
}
super.initState();
}
@override
void dispose() {
super.dispose();
}
final DateFormat dateFormat = DateFormat("d MMM yyyy");
@override
Widget build(BuildContext context) {
2020-10-14 20:56:46 +06:30
final amountBox = InputText(
labelTextKey: 'pm.amount',
controller: _amountController,
iconData: FontAwesomeIcons.moneyBill);
final receiptFileBox = Row(children: [
LocalText(context, 'pm.attachment', fontSize: 16, color: Colors.grey),
IconButton(
2020-10-16 21:38:39 +06:30
icon: Icon(Icons.attachment, color: primaryColor),
onPressed: () {
modelBottomSheet(context, onFile: (file) {
setState(() {
_file = file;
});
});
})
]);
final payBox = Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
height: 50,
width: 100,
alignment: Alignment.center,
child: Text(AppTranslations.of(context).text("pm.pay"),
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 14)),
color: primaryColor)
2020-10-14 20:56:46 +06:30
]);
2020-10-09 19:00:39 +06:30
2020-06-24 16:06:15 +06:30
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
2020-10-14 13:54:42 +06:30
icon: new Icon(CupertinoIcons.back),
2020-06-24 16:06:15 +06:30
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
2020-10-07 18:49:28 +06:30
title: Text(AppTranslations.of(context).text("pm_.title")),
2020-06-24 16:06:15 +06:30
),
2020-10-13 11:49:35 +06:30
body: ListView(
2020-10-14 20:56:46 +06:30
padding: const EdgeInsets.all(10.0),
2020-10-13 11:49:35 +06:30
children: <Widget>[
2020-10-14 20:56:46 +06:30
amountBox,
2020-10-13 11:49:35 +06:30
SizedBox(height: 10),
2020-10-14 20:56:46 +06:30
receiptFileBox,
2020-10-13 11:49:35 +06:30
SizedBox(height: 10),
2020-10-16 21:38:39 +06:30
payBox,
2020-10-13 11:49:35 +06:30
Divider(),
SizedBox(height: 10),
2020-10-14 20:56:46 +06:30
LocalTitle(textKey: "pm.receipt"),
Column(
children: getCustomFeeRows(context),
2020-10-13 11:49:35 +06:30
),
SizedBox(height: 25),
],
2020-06-24 16:06:15 +06:30
),
),
);
}
2020-10-14 20:56:46 +06:30
getCustomFeeRows(BuildContext context) {
List<Widget> dataRow = [];
dataRow = _invoice.receipts.asMap().entries.map((receipt) {
var r = receipt.value;
var k = receipt.key + 1;
return Container(
height: 50,
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding:
const EdgeInsets.only(left: 5.0, right: 5.0, top: 5.0, bottom: 5.0),
2020-10-16 21:38:39 +06:30
child: InkWell(
onTap: () {
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => PaymentPageEdit(receipt: r)));
},
child: Row(
children: [
Expanded(flex: 2, child: Text('${r.date}')),
Expanded(
flex: 2,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShowImage(
localImage: 'assets/logo.jpg',
url: null,
fileName: 'image')));
},
child: Icon(Icons.attachment, color: primaryColor))),
Expanded(flex: 1, child: Center(child: Text('pending'))),
Expanded(flex: 1, child: Center(child: Text('\$ ${r.amount}'))),
],
),
2020-10-14 20:56:46 +06:30
),
2020-06-24 16:06:15 +06:30
);
}).toList();
2020-10-14 20:56:46 +06:30
dataRow.insert(
0,
Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 10.0, bottom: 15.0),
child: Row(
children: [
Expanded(
flex: 2,
2020-10-16 21:38:39 +06:30
child: Text('Date', style: TextStyle(color: Colors.grey))),
2020-10-14 20:56:46 +06:30
Expanded(
flex: 2,
child: Text('File',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey))),
Expanded(
flex: 1,
child: Text('Status',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey))),
Expanded(
flex: 1,
child: Text('Fee',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey))),
],
),
));
dataRow.insert(
dataRow.length,
Container(
padding: const EdgeInsets.only(
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
child: Row(
children: [
Expanded(
flex: 2,
child: Center(
child: LocalText(
context,
'pm.remaining_balance',
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
Expanded(
flex: 2,
child: Container(),
),
Expanded(
flex: 1,
child: Center(
child: Text('\$ 300',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0)))),
],
),
));
return dataRow;
2020-06-24 16:06:15 +06:30
}
}