Advertisement
PabloMartinezfr10

Untitled

Aug 31st, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.69 KB | None | 0 0
  1. class HomePage extends StatelessWidget {
  2.   const HomePage({Key key}) : super(key: key);
  3.  
  4.   @override
  5.   Widget build(BuildContext context) {
  6.     return  Container(
  7.       child: Column(
  8.         children: <Widget>[
  9.           Container(
  10.             child: Row(
  11.               mainAxisAlignment: MainAxisAlignment.spaceBetween,
  12.               children: <Widget>[
  13.                 BlocosHome(FontAwesomeIcons.calendarAlt, 'Agendamento',
  14.                     AgendamentoPage()),
  15.                 BlocosHome(
  16.                     FontAwesomeIcons.microscope, 'Exames', AgendamentoPage()),
  17.               ],
  18.             ),
  19.           ),
  20.           Expanded(
  21.             child: EspecialidadeTile(),
  22.           )
  23.         ],
  24.       ),
  25.     );
  26.   }
  27. }
  28.  
  29.  
  30. //Especialidade Widget
  31.  
  32.  class EspecialidadeTile extends StatelessWidget {
  33.   @override
  34.   Widget build(BuildContext context) {
  35.     return StreamBuilder(
  36.       stream: Firestore.instance.collection('especialidades').snapshots(),
  37.       builder: (context, snapshot) {
  38.         if (!snapshot.hasData) {
  39.           return Center(
  40.             child: CircularProgressIndicator(),
  41.           );
  42.         } else {
  43.           return GridView.builder(
  44.             itemCount: snapshot.data.documents.length,
  45.             gridDelegate:
  46.                 SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
  47.             itemBuilder: (context, index) {
  48.               DocumentSnapshot espec = snapshot.data.documents[index];
  49.               return GestureDetector(
  50.                 child: Container(
  51.                   margin: EdgeInsets.symmetric(horizontal: 10),
  52.                   padding: EdgeInsets.symmetric(horizontal: 5),
  53.                   decoration: BoxDecoration(
  54.                       color: Colors.white,
  55.                       borderRadius: BorderRadius.circular(10),
  56.                       boxShadow: [
  57.                         BoxShadow(
  58.                           color: Colors.black12,
  59.                           offset: Offset(0, 6),
  60.                           blurRadius: 6,
  61.                         ),
  62.                       ]),
  63.                   child: Column(
  64.                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
  65.                     children: <Widget>[
  66.                       SizedBox(
  67.                         height: 150,
  68.                         child: Stack(
  69.                           children: <Widget>[
  70.                             Image.network('${espec['imagem']}'),
  71.                             Positioned(
  72.                               bottom: 0,
  73.                               child: Container(
  74.                                   width: MediaQuery.of(context).size.width / 2 - 30,
  75.                                   height: 30,
  76.                                   color: Colors.black.withOpacity(0.5),
  77.                                   child: Align(
  78.                                     alignment: Alignment.bottomCenter,
  79.                                     child: Text(
  80.                                       '${espec['nome']}',
  81.                                       style: TextStyle(
  82.                                           color: Colors.white, fontSize: 20,fontFamily: 'sans-serif'),
  83.                                     ),
  84.                                   )),
  85.                             )
  86.                           ],
  87.                         ),
  88.                       ),
  89.                       SizedBox(
  90.                         height: 30,
  91.                         child: Align(
  92.                         alignment: Alignment.topLeft,
  93.                         child: Text(
  94.                           '${espec['des']},',
  95.                           style:
  96.                               TextStyle(color: Colors.black87, fontSize: 13, fontFamily: 'sans-serif'),
  97.                               maxLines: 2,
  98.                         ),
  99.                       ),
  100.                       ),
  101.                       SizedBox(
  102.                         height: 10,
  103.                         child: Container(
  104.                           color: Colors.redAccent,
  105.                         ),
  106.                       ),
  107.                     ],
  108.                   ),
  109.                 ),
  110.                 onTap: () {},
  111.               );
  112.             },
  113.           );
  114.         }
  115.       },
  116.     );
  117.   }
  118. }
  119.  
  120.  
  121. //Blocos Home Widget
  122.  
  123.  class BlocosHome extends StatelessWidget {
  124.   final IconData icon;
  125.   final String texto;
  126.   final Widget link;
  127.  
  128.   BlocosHome(this.icon, this.texto, this.link);
  129.  
  130.   @override
  131.   Widget build(BuildContext context) {
  132.     final colorB = Colors.cyan[900];
  133.  
  134.     return Container(
  135.       margin: EdgeInsets.symmetric(vertical: 10, horizontal: 8),
  136.       decoration: BoxDecoration(
  137.           color: Colors.white,
  138.           borderRadius: BorderRadius.circular(10),
  139.           boxShadow: [
  140.             BoxShadow(
  141.               color: Colors.black12,
  142.               offset: Offset(0, 6),
  143.               blurRadius: 6,
  144.             ),
  145.           ]),
  146.       child: SizedBox(
  147.         height: 200,
  148.         width: MediaQuery.of(context).size.width / 2 - 20,
  149.         child: RaisedButton(
  150.           child: Column(
  151.             mainAxisAlignment: MainAxisAlignment.center,
  152.             children: <Widget>[
  153.               Icon(
  154.                 icon,
  155.                 color: Colors.white,
  156.                 size: 70.0,
  157.               ),
  158.               SizedBox(
  159.                 height: 16.0,
  160.               ),
  161.               Text(
  162.                 texto,
  163.                 style: TextStyle(color: Colors.white, fontSize: 20.0),
  164.               )
  165.             ],
  166.           ),
  167.           color: colorB,
  168.           onPressed: () {
  169.             Navigator.push(
  170.                 context, MaterialPageRoute(builder: (context) => link));
  171.           },
  172.         ),
  173.       ),
  174.     );
  175.   }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement