Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Widget _tileVoto(Voti voto) {
- bool descriptionExists = (voto.examDes != "" || voto.comment != "");
- return ListTile(
- leading: Container(
- width: 50,
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: 4),
- child: _buildVote(voto),
- ),
- ),
- title: descriptionExists
- ? AutoSizeText(
- voto.examDes != "" ? voto.examDes : voto.comment,
- maxLines: 3,
- maxFontSize: 16,
- )
- : AutoSizeText("Nessun commento aggiunto.", maxFontSize: 16, maxLines: 1),
- subtitle: Row(
- children: <Widget>[
- _buildDate(voto),
- ],
- ),
- );
- }
- Widget _buildDate(Voti voto) {
- final String date = voto.date
- .toString()
- .replaceAll('00:', '')
- .replaceAll('00.000', '')
- .replaceAll('-', ' ');
- final String year = date.substring(0, 4);
- String month = date.substring(5, 7);
- final String day = date.substring(8);
- if (month == '01') {
- month = 'Gennaio';
- } else if (month == '02') {
- month = 'Febbraio';
- } else if (month == '03') {
- month = 'Marzo';
- } else if (month == '04') {
- month = 'Aprile';
- } else if (month == '05') {
- month = 'Maggio';
- } else if (month == '06') {
- month = 'Giugno';
- } else if (month == '07') {
- month = 'Luglio';
- } else if (month == '08') {
- month = 'Agosto';
- } else if (month == '09') {
- month = 'Settembre';
- } else if (month == '10') {
- month = 'Ottobre';
- } else if (month == '11') {
- month = 'Novembre';
- } else {
- month = 'Dicembre';
- }
- return Text(
- '$day$month $year',
- textAlign: TextAlign.start,
- style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400),
- );
- }
- Widget _buildVote(Voti voto) {
- if (voto.value < 6.0) {
- return AutoSizeText(
- '${voto.vote}',
- style: TextStyle(
- fontSize: 18.0,
- color: Colors.red[600],
- fontWeight: FontWeight.w400),
- textAlign: TextAlign.center,
- maxLines: 1,
- );
- } else {
- return AutoSizeText(
- '${voto.vote}',
- style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w400),
- textAlign: TextAlign.center,
- maxLines: 1,
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement