104 lines
3.1 KiB
Dart
104 lines
3.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:fcs/model/chart_model.dart';
|
|
import 'package:fcs/model/language_model.dart';
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
|
import 'package:fcs/vo/po.dart';
|
|
import 'package:fcs/widget/local_text.dart';
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
import 'package:fcs/widget/my_data_table.dart';
|
|
import 'package:fcs/widget/number_cell.dart';
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
class QtyByCustomerTable extends StatefulWidget {
|
|
final POChartData poChartData;
|
|
const QtyByCustomerTable({Key key, this.poChartData}) : super(key: key);
|
|
@override
|
|
_QtyByCustomerTableState createState() => _QtyByCustomerTableState();
|
|
}
|
|
|
|
class _QtyByCustomerTableState extends State<QtyByCustomerTable> {
|
|
final numberFormatter = new NumberFormat("#,###");
|
|
List<POChartData> chartUser = new List();
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
var chartModel = Provider.of<ChartModel>(context, listen: false);
|
|
if (mounted) {
|
|
load(chartModel);
|
|
}
|
|
}
|
|
|
|
Future<void> load(ChartModel chartModel) async {
|
|
var _u = await chartModel.loadUsers();
|
|
setState(() {
|
|
this.chartUser = _u;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<POChartData> data = this
|
|
.chartUser
|
|
.where((u) => u.productName == widget.poChartData.productName)
|
|
.toList();
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: primaryColor,
|
|
title: Text(
|
|
AppTranslations.of(context).text("product.qtys"),
|
|
style: Provider.of<LanguageModel>(context).isEng
|
|
? TextStyle(fontSize: 18)
|
|
: TextStyle(fontSize: 18, fontFamily: 'MyanmarUnicode'),
|
|
),
|
|
),
|
|
body: Container(
|
|
padding: EdgeInsets.only(top: 10),
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: MyDataTable(
|
|
headingRowHeight: 40,
|
|
columnSpacing: 40,
|
|
columns: [
|
|
MyDataColumn(label: LocalText(context, "buyer.name")),
|
|
MyDataColumn(label: LocalText(context, "buyer.product")),
|
|
MyDataColumn(
|
|
label: LocalText(context, "buyer.balQty"), numeric: true),
|
|
],
|
|
rows: getProductRow(data),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
List<MyDataRow> getProductRow(List<POChartData> poLines) {
|
|
return poLines.map((p) {
|
|
return MyDataRow(
|
|
cells: [
|
|
MyDataCell(
|
|
new Text(p.userName, style: textStyle),
|
|
),
|
|
MyDataCell(
|
|
new Text(
|
|
p.productName,
|
|
style: textStyle,
|
|
),
|
|
),
|
|
MyDataCell(NumberCell(p.balanceQty)),
|
|
],
|
|
);
|
|
}).toList();
|
|
}
|
|
}
|