Advertisement
Guest User

Penilaian

a guest
Jan 24th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 8.87 KB | None | 0 0
  1. import 'dart:io';
  2. import 'package:auto_size_text/auto_size_text.dart';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:url_launcher/url_launcher.dart';
  6. import 'package:vendor5/api/api_service.dart';
  7. import 'package:vendor5/models/Penilaian.dart';
  8.  
  9. class Penilaianpage extends StatefulWidget {
  10.   Penilaianpage({Key key}) : super(key: key);
  11.  
  12.   @override
  13.   _PenilaianpageState createState() => _PenilaianpageState();
  14. }
  15.  
  16. class _PenilaianpageState extends State<Penilaianpage> {
  17.   ApiService apiService;
  18.  
  19.   @override
  20.   void initState() {
  21.     super.initState();
  22.     apiService = ApiService();
  23.   }
  24.  
  25.   @override
  26.   Widget build(BuildContext context) {
  27.     return Scaffold(
  28.       appBar: AppBar(
  29.         elevation: 0.0,
  30.         backgroundColor: Colors.white,
  31.         leading: IconButton(
  32.           icon: Icon(
  33.             Platform.isIOS ? Icons.arrow_back_ios : Icons.arrow_back,
  34.             color: Colors.black,
  35.           ),
  36.           onPressed: () => Navigator.of(context).pop(),
  37.         ),
  38.         title: Text(
  39.           "Penilaian",
  40.           style: TextStyle(color: Colors.black87),
  41.         ),
  42.       ),
  43.       body: SingleChildScrollView(
  44.         child: Container(
  45.           padding: EdgeInsets.all(18.0),
  46.           width: MediaQuery.of(context).size.width,
  47.           height: MediaQuery.of(context).size.height,
  48.           //width: double.infinity,
  49.           child: FutureBuilder(
  50.             future: apiService.getPenilaians(),
  51.             builder:
  52.                 (BuildContext context, AsyncSnapshot<List<Penilaian>> snaphot) {
  53.               if (snaphot.hasError) {
  54.                 var snapshot;
  55.                 return Center(
  56.                   child: Text(
  57.                       "Error bro konek internet dulu: ${snapshot.error.toString()}"),
  58.                 );
  59.               } else if (snaphot.connectionState == ConnectionState.done) {
  60.                 List<Penilaian> penilaians = snaphot.data;
  61.  
  62.                 return _buildList(penilaians);
  63.               } else {
  64.                 return Center(
  65.                   child: CircularProgressIndicator(),
  66.                 );
  67.               }
  68.             },
  69.           ),
  70.         ),
  71.       ),
  72.     );
  73.   }
  74.  
  75.   Widget _buildList(List<Penilaian> penilaians) {
  76.     return Container(
  77.       padding: EdgeInsets.only(top: 10),
  78.       child: ListView.builder(
  79.         itemBuilder: (context, index) {
  80.           Penilaian penilaian = penilaians[index];
  81.           return Container(
  82.             height: 360,
  83.             child: Card(
  84.               elevation: 4.0,
  85.               shape: RoundedRectangleBorder(
  86.                 borderRadius: BorderRadius.circular(10.0),
  87.               ),
  88.               child: Stack(
  89.                 children: <Widget>[
  90.                   Column(
  91.                     children: <Widget>[
  92.                       Container(
  93.                         height: 160.0,
  94.                         decoration: BoxDecoration(
  95.                             borderRadius: BorderRadius.only(
  96.                               topLeft: Radius.circular(10.0),
  97.                               topRight: Radius.circular(10.0),
  98.                             ),
  99.                             image: DecorationImage(
  100.                               image: CachedNetworkImageProvider(
  101.                                   'https://images.unsplash.com/photo-1518770660439-4636190af475?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80'),
  102.                               fit: BoxFit.cover,
  103.                             )),
  104.                       ),
  105.                       Padding(
  106.                         padding: const EdgeInsets.all(16.0),
  107.                         child: AutoSizeText(
  108.                           penilaian.title,
  109.                           style: TextStyle(
  110.                             color: Colors.black87,
  111.                             fontSize: 20.0,
  112.                             fontWeight: FontWeight.bold,
  113.                           ),
  114.                         ),
  115.                       ),
  116.                       Padding(
  117.                         padding: const EdgeInsets.symmetric(horizontal: 16.0),
  118.                         child: Row(
  119.                           children: <Widget>[
  120.                             Text(
  121.                               "vendor instansi :",
  122.                               style: TextStyle(
  123.                                   color: Colors.orange,
  124.                                   fontSize: 14.0,
  125.                                   fontWeight: FontWeight.w300),
  126.                             ),
  127.                             SizedBox(width: 10),
  128.                             Text(
  129.                               penilaian.vendorInstansi,
  130.                               style: TextStyle(
  131.                                 color: Colors.grey,
  132.                                 fontSize: 14.0,
  133.                               ),
  134.                             ),
  135.                           ],
  136.                         ),
  137.                       ),
  138.                       Divider(),
  139.                       Padding(
  140.                         padding: const EdgeInsets.only(top: 10.0),
  141.                         child: Container(
  142.                           width: 280,
  143.                           child: Row(
  144.                             mainAxisAlignment: MainAxisAlignment.spaceBetween,
  145.                             children: <Widget>[
  146.                               Row(
  147.                                 children: <Widget>[
  148.                                   Text(
  149.                                     "kinerja:",
  150.                                     style: TextStyle(
  151.                                       color: Colors.grey,
  152.                                       fontSize: 14.0,
  153.                                     ),
  154.                                   ),
  155.                                   SizedBox(width: 10),
  156.                                   Text(
  157.                                     penilaian.kinerja.toString(),
  158.                                     style: TextStyle(
  159.                                       color: Colors.grey,
  160.                                       fontSize: 14.0,
  161.                                     ),
  162.                                   ),
  163.                                 ],
  164.                               ),
  165.                               Row(
  166.                                 children: <Widget>[
  167.                                   Text(
  168.                                     "ketepatan :",
  169.                                     style: TextStyle(
  170.                                       color: Colors.grey,
  171.                                       fontSize: 14.0,
  172.                                     ),
  173.                                   ),
  174.                                   SizedBox(width: 10),
  175.                                   Text(
  176.                                     penilaian.ketepatan.toString(),
  177.                                     style: TextStyle(
  178.                                       color: Colors.grey,
  179.                                       fontSize: 14.0,
  180.                                     ),
  181.                                   ),
  182.                                 ],
  183.                               ),
  184.                               Row(
  185.                                 children: <Widget>[
  186.                                   Text(
  187.                                     "komunikasi :",
  188.                                     style: TextStyle(
  189.                                       color: Colors.grey,
  190.                                       fontSize: 14.0,
  191.                                     ),
  192.                                   ),
  193.                                   SizedBox(width: 10),
  194.                                   Text(
  195.                                     penilaian.komunikasi.toString(),
  196.                                     style: TextStyle(
  197.                                       color: Colors.grey,
  198.                                       fontSize: 14.0,
  199.                                     ),
  200.                                   ),
  201.                                 ],
  202.                               ),
  203.                             ],
  204.                           ),
  205.                         ),
  206.                       ),
  207.  
  208.                       RaisedButton(
  209.                         color: Color(0xFF162A49),
  210.                         child: Text('Lihat Project'),
  211.                         textColor: Colors.white,
  212.                         shape: RoundedRectangleBorder(
  213.                           borderRadius: BorderRadius.circular(32),
  214.                         ),
  215.                         onPressed: () {
  216.                           launch(penilaian.vendorWebsite);
  217.                         },
  218.                       ),
  219.  
  220.                       //const SizedBox(height: 20.0),
  221.                     ],
  222.                   ),
  223.                 ],
  224.               ),
  225.             ),
  226.           );
  227.         },
  228.         itemCount: penilaians.length,
  229.       ),
  230.     );
  231.   }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement