Advertisement
Guest User

Untitled

a guest
May 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.29 KB | None | 0 0
  1. Widget _tileVoto(Voti voto) {
  2.     bool descriptionExists = (voto.examDes != "" || voto.comment != "");
  3.     return ListTile(
  4.       leading: Container(
  5.         width: 50,
  6.         child: Padding(
  7.           padding: EdgeInsets.symmetric(horizontal: 4),
  8.           child: _buildVote(voto),
  9.         ),
  10.       ),
  11.       title: descriptionExists
  12.           ? AutoSizeText(
  13.               voto.examDes != "" ? voto.examDes : voto.comment,
  14.               maxLines: 3,
  15.               maxFontSize: 16,
  16.             )
  17.           : AutoSizeText("Nessun commento aggiunto.", maxFontSize: 16, maxLines: 1),
  18.       subtitle: Row(
  19.         children: <Widget>[
  20.           _buildDate(voto),
  21.         ],
  22.       ),
  23.     );
  24.   }
  25.  
  26.   Widget _buildDate(Voti voto) {
  27.     final String date = voto.date
  28.         .toString()
  29.         .replaceAll('00:', '')
  30.         .replaceAll('00.000', '')
  31.         .replaceAll('-', ' ');
  32.     final String year = date.substring(0, 4);
  33.     String month = date.substring(5, 7);
  34.     final String day = date.substring(8);
  35.     if (month == '01') {
  36.       month = 'Gennaio';
  37.     } else if (month == '02') {
  38.       month = 'Febbraio';
  39.     } else if (month == '03') {
  40.       month = 'Marzo';
  41.     } else if (month == '04') {
  42.       month = 'Aprile';
  43.     } else if (month == '05') {
  44.       month = 'Maggio';
  45.     } else if (month == '06') {
  46.       month = 'Giugno';
  47.     } else if (month == '07') {
  48.       month = 'Luglio';
  49.     } else if (month == '08') {
  50.       month = 'Agosto';
  51.     } else if (month == '09') {
  52.       month = 'Settembre';
  53.     } else if (month == '10') {
  54.       month = 'Ottobre';
  55.     } else if (month == '11') {
  56.       month = 'Novembre';
  57.     } else {
  58.       month = 'Dicembre';
  59.     }
  60.     return Text(
  61.       '$day$month $year',
  62.       textAlign: TextAlign.start,
  63.       style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400),
  64.     );
  65.   }
  66.  
  67.   Widget _buildVote(Voti voto) {
  68.     if (voto.value < 6.0) {
  69.       return AutoSizeText(
  70.         '${voto.vote}',
  71.         style: TextStyle(
  72.             fontSize: 18.0,
  73.             color: Colors.red[600],
  74.             fontWeight: FontWeight.w400),
  75.         textAlign: TextAlign.center,
  76.         maxLines: 1,
  77.       );
  78.     } else {
  79.       return AutoSizeText(
  80.         '${voto.vote}',
  81.         style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w400),
  82.         textAlign: TextAlign.center,
  83.         maxLines: 1,
  84.       );
  85.     }
  86.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement