refactored stat tablerow rendering a bit
This commit is contained in:
parent
413b1fd133
commit
c7800a3f62
1 changed files with 32 additions and 75 deletions
|
@ -23,6 +23,23 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text getStatTableText(double value){
|
||||||
|
var text = "-";
|
||||||
|
var color = Colors.grey.shade500;
|
||||||
|
if (value != null){
|
||||||
|
text = value.toString() + "%";
|
||||||
|
color = value >= 70 ? Colors.green : Colors.red;
|
||||||
|
}
|
||||||
|
return Text(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
color: color
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -91,21 +108,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
getStatTableText(snapshot.data["7d month"]),
|
||||||
snapshot.hasData ?
|
getStatTableText(snapshot.data["30d month"]),
|
||||||
snapshot.data["7d month"].toString() + "%" : "-",
|
getStatTableText(snapshot.data["All month"]),
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["30d month"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["All month"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
|
@ -122,21 +127,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
getStatTableText(snapshot.data["7d century"]),
|
||||||
snapshot.hasData ?
|
getStatTableText(snapshot.data["30d century"]),
|
||||||
snapshot.data["7d century"].toString() + "%" : "-",
|
getStatTableText(snapshot.data["All century"]),
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["30d century"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["All century"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
|
@ -153,21 +146,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
getStatTableText(snapshot.data["7d leap"]),
|
||||||
snapshot.hasData ?
|
getStatTableText(snapshot.data["30d leap"]),
|
||||||
snapshot.data["7d leap"].toString() + "%" : "-",
|
getStatTableText(snapshot.data["All leap"]),
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["30d leap"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["All leap"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
|
@ -184,21 +165,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
getStatTableText(snapshot.data["7d mod"]),
|
||||||
snapshot.hasData ?
|
getStatTableText(snapshot.data["30d mod"]),
|
||||||
snapshot.data["7d mod"].toString() + "%" : "-",
|
getStatTableText(snapshot.data["All mod"]),
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["30d mod"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["All mod"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
|
@ -209,21 +178,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
),
|
),
|
||||||
Text(
|
getStatTableText(snapshot.data["7d all"]),
|
||||||
snapshot.hasData ?
|
getStatTableText(snapshot.data["30d all"]),
|
||||||
snapshot.data["7d mod"].toString() + "%" : "-",
|
getStatTableText(snapshot.data["All all"]),
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["30d mod"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
snapshot.hasData ?
|
|
||||||
snapshot.data["All mod"].toString() + "%" : "-",
|
|
||||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue