add structure
This commit is contained in:
121
lib/charts/do_line_detail.dart
Normal file
121
lib/charts/do_line_detail.dart
Normal file
@@ -0,0 +1,121 @@
|
||||
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/theme/theme.dart';
|
||||
import 'package:fcs/vo/po_do_count.dart';
|
||||
import 'package:fcs/widget/local_text.dart';
|
||||
import 'package:fcs/widget/my_data_table.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
|
||||
class DOLineDetail extends StatefulWidget {
|
||||
const DOLineDetail();
|
||||
@override
|
||||
_DOLineDetailState createState() => _DOLineDetailState();
|
||||
}
|
||||
|
||||
class _DOLineDetailState extends State<DOLineDetail> {
|
||||
final numberFormatter = new NumberFormat("#,###");
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var chartModel = Provider.of<ChartModel>(context);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
'do.counts',
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 20, left: 20, right: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
LocalText(context, "chart.date"),
|
||||
LocalText(context, "do.total_count")
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: getRowTotalCountWidget(
|
||||
chartModel.podoCount.getDOTotalCounts()),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getRowTotalCountWidget(List<TotalCountData> data) {
|
||||
return data.map((d) {
|
||||
return Container(
|
||||
child: ExpansionTile(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(dateFormatter.format(d.date), style: textStyle),
|
||||
Text(numberFormatter.format(d.totalCount), style: textStyle),
|
||||
],
|
||||
),
|
||||
children: <Widget>[
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
columnSpacing: 100,
|
||||
columns: [
|
||||
MyDataColumn(label: LocalText(context, "do.count.status")),
|
||||
MyDataColumn(label: LocalText(context, "do.count")),
|
||||
],
|
||||
rows: getStatusRow(d.detailCountsList),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MyDataRow> getStatusRow(List<CountData> doList) {
|
||||
doList.sort((a, b) => a.status.compareTo(b.status));
|
||||
return doList.map((d) {
|
||||
var r = MyDataRow(
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(d.status, style: textStyle),
|
||||
),
|
||||
MyDataCell(
|
||||
new Text(
|
||||
numberFormatter.format(d.count),
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return r;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user