Files
fcs/lib/pages/buyer_list_row.dart

107 lines
3.3 KiB
Dart
Raw Normal View History

2020-05-29 07:45:27 +06:30
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:fcs/model/buyer_model.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/theme/theme.dart';
import 'package:fcs/vo/buyer.dart';
import 'buyer_info.dart';
class BuyerListRow extends StatefulWidget {
final Buyer buyer;
const BuyerListRow({this.buyer});
@override
_BuyerListRowState createState() => _BuyerListRowState();
}
class _BuyerListRowState extends State<BuyerListRow> {
final double dotSize = 15.0;
Buyer _buyer = new Buyer();
@override
void initState() {
super.initState();
BuyerModel buyerModel = Provider.of<BuyerModel>(context, listen: false);
if (widget.buyer != null) {
buyerModel.buyers.forEach((b) {
if (widget.buyer.id == b.id) {
_buyer = b;
}
});
}
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: Card(
elevation: 10,
color: Colors.white,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BuyerInfo(buyer: _buyer)),
);
},
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row(
children: <Widget>[
new Padding(
padding: new EdgeInsets.symmetric(
horizontal: 32.0 - dotSize / 2),
child: Image.asset(
"assets/buyer.png",
width: 40,
height: 40,
color: primaryColor,
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
_buyer.userName == null ? '' : _buyer.userName,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
new Text(
_buyer.bizName == null ? "" : _buyer.bizName,
style: new TextStyle(
fontSize: 13.0, color: Colors.grey),
),
new Text(
_buyer.phone == null ? "" : _buyer.phone,
style: new TextStyle(
fontSize: 13.0, color: Colors.grey),
),
],
),
),
],
),
),
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: getStatus(_buyer.status),
),
],
)
],
),
),
),
);
}
}