Dashboard
This commit is contained in:
parent
3b56da9abb
commit
da51a60643
|
|
@ -23,6 +23,7 @@ class DashboardChart extends StatefulWidget {
|
||||||
class _DashboardChartState extends State<DashboardChart> {
|
class _DashboardChartState extends State<DashboardChart> {
|
||||||
String _title;
|
String _title;
|
||||||
String _subtitle;
|
String _subtitle;
|
||||||
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
void _onSelectionChanged(charts.SelectionModel model) {
|
void _onSelectionChanged(charts.SelectionModel model) {
|
||||||
final selectedDatum = model.selectedDatum;
|
final selectedDatum = model.selectedDatum;
|
||||||
|
|
@ -99,11 +100,11 @@ class _DashboardChartState extends State<DashboardChart> {
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: widget.data.map((dataGroup) {
|
children: widget.data.map((dataGroup) {
|
||||||
final bool isIncrease =
|
final bool isSelected =
|
||||||
dataGroup.total >= dataGroup.previousTotal;
|
widget.data.indexOf(dataGroup) == _selectedIndex;
|
||||||
|
final bool isIncrease = dataGroup.total >= dataGroup.previousTotal;
|
||||||
final String changeAmount = (isIncrease ? '+' : '') +
|
final String changeAmount = (isIncrease ? '+' : '') +
|
||||||
formatNumber(
|
formatNumber(dataGroup.total - dataGroup.previousTotal, context,
|
||||||
dataGroup.total - dataGroup.previousTotal, context,
|
|
||||||
currencyId: widget.currencyId);
|
currencyId: widget.currencyId);
|
||||||
final changePercent = (isIncrease ? '+' : '-') +
|
final changePercent = (isIncrease ? '+' : '-') +
|
||||||
formatNumber(
|
formatNumber(
|
||||||
|
|
@ -123,25 +124,35 @@ class _DashboardChartState extends State<DashboardChart> {
|
||||||
: '$changeAmount ($changePercent)';
|
: '$changeAmount ($changePercent)';
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
color: Colors.blue,
|
color: isSelected ? Colors.blue : Colors.white,
|
||||||
padding: EdgeInsets.all(14.0),
|
padding: EdgeInsets.all(14.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(localization.lookup(dataGroup.name),
|
Text(localization.lookup(dataGroup.name),
|
||||||
style: Theme.of(context).textTheme.subhead),
|
style: Theme.of(context).textTheme.subhead.copyWith(
|
||||||
|
color: isSelected ? Colors.white : null,
|
||||||
|
fontWeight: FontWeight.w400)),
|
||||||
|
SizedBox(height: 2.0),
|
||||||
Text(
|
Text(
|
||||||
formatNumber(dataGroup.total, context,
|
formatNumber(dataGroup.total, context,
|
||||||
currencyId: widget.currencyId),
|
currencyId: widget.currencyId),
|
||||||
style: Theme.of(context).textTheme.headline),
|
style: Theme.of(context)
|
||||||
changeString.isNotEmpty ? Text(
|
.textTheme
|
||||||
changeString,
|
.headline
|
||||||
style: TextStyle(
|
.copyWith(color: isSelected ? Colors.white : null)),
|
||||||
fontSize: 16.0,
|
changeString.isNotEmpty
|
||||||
color: isIncrease ? Colors.green : Colors.red,
|
? Text(
|
||||||
fontWeight: FontWeight.bold,
|
changeString,
|
||||||
),
|
style: TextStyle(
|
||||||
) : SizedBox(),
|
fontSize: 16.0,
|
||||||
|
color: isSelected
|
||||||
|
? Colors.white
|
||||||
|
: (isIncrease ? Colors.green : Colors.red),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -180,8 +191,7 @@ class _DashboardChartState extends State<DashboardChart> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(_subtitle,
|
Text(_subtitle,
|
||||||
style: Theme.of(context).textTheme.subhead),
|
style: Theme.of(context).textTheme.subhead),
|
||||||
Text(_title,
|
Text(_title, style: Theme.of(context).textTheme.headline),
|
||||||
style: Theme.of(context).textTheme.headline),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue