|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_collapsing_toolbar/flutter_collapsing_toolbar.dart'; |
| 3 | +import 'package:lottie/lottie.dart'; |
| 4 | +import 'dados.dart'; |
| 5 | +import 'package:url_launcher/url_launcher.dart'; |
| 6 | + |
| 7 | +void main() => runApp(MyApp()); |
| 8 | + |
| 9 | +const kSampleIcons = [ |
| 10 | + Icons.track_changes_outlined, |
| 11 | + Icons.wifi_protected_setup_outlined, |
| 12 | + Icons.account_box_outlined, |
| 13 | +]; |
| 14 | +const kSampleIconLabels = [ |
| 15 | + 'DADOS', |
| 16 | + 'GITHUB', |
| 17 | +]; |
| 18 | + |
| 19 | +class MyApp extends StatefulWidget { |
| 20 | + @override |
| 21 | + _MyAppState createState() => _MyAppState(); |
| 22 | +} |
| 23 | + |
| 24 | +class _MyAppState extends State<MyApp> { |
| 25 | + final controller = ScrollController(); |
| 26 | + double headerOffset = 0.0; |
| 27 | + final String githubUrl = 'https://github.com/LeticiaBHB'; |
| 28 | + |
| 29 | + |
| 30 | + @override |
| 31 | + Widget build(BuildContext context) { |
| 32 | + return MaterialApp( |
| 33 | + initialRoute: '/', |
| 34 | + routes: { |
| 35 | + '/dados': (context) => dados(), |
| 36 | + }, |
| 37 | + home: Scaffold( |
| 38 | + body: Container( |
| 39 | + margin: const EdgeInsets.only(top: 24.0), |
| 40 | + child: Column( |
| 41 | + children: [ |
| 42 | + Align( |
| 43 | + alignment: Alignment.topCenter, |
| 44 | + child: CollapsingToolbar( |
| 45 | + controller: controller, |
| 46 | + expandedHeight: 160, |
| 47 | + collapsedHeight: 64, |
| 48 | + decorationForegroundColor: Colors.deepOrange.shade400, |
| 49 | + decorationBackgroundColor: Colors.brown.shade200, |
| 50 | + onCollapsing: (double offset) { |
| 51 | + setState(() { |
| 52 | + headerOffset = offset; |
| 53 | + }); |
| 54 | + }, |
| 55 | + leading: Container( |
| 56 | + margin: EdgeInsets.only(left: 12), |
| 57 | + padding: EdgeInsets.all(4), |
| 58 | + decoration: ShapeDecoration( |
| 59 | + color: Colors.orange[200], |
| 60 | + shape: CircleBorder(), |
| 61 | + ), |
| 62 | + child: Icon( |
| 63 | + Icons.access_alarm_outlined, |
| 64 | + size: 24, |
| 65 | + color: Colors.red, |
| 66 | + ), |
| 67 | + ), |
| 68 | + title: Text( |
| 69 | + 'Material Particulado - PM 2.5', |
| 70 | + style: TextStyle( |
| 71 | + fontSize: 16, |
| 72 | + color: Colors.black, |
| 73 | + fontWeight: FontWeight.w600, |
| 74 | + ), |
| 75 | + ), |
| 76 | + featureCount: 2, |
| 77 | + featureIconBuilder: (context, index) { |
| 78 | + return InkWell( |
| 79 | + onTap: () => _onFeaturePressed(context, index), |
| 80 | + // Passar o contexto e o índice para o método |
| 81 | + child: Icon( |
| 82 | + kSampleIcons[index], |
| 83 | + size: 54, |
| 84 | + color: Colors.orange[200], |
| 85 | + ), |
| 86 | + ); |
| 87 | + }, |
| 88 | + featureLabelBuilder: (context, index) { |
| 89 | + return Text( |
| 90 | + kSampleIconLabels[index], |
| 91 | + textAlign: TextAlign.center, |
| 92 | + maxLines: 1, |
| 93 | + style: TextStyle( |
| 94 | + fontSize: 12, |
| 95 | + color: Colors.black, |
| 96 | + ), |
| 97 | + ); |
| 98 | + }, |
| 99 | + featureOnPressed: (BuildContext context, int index) {}, |
| 100 | + ), |
| 101 | + ), |
| 102 | + Expanded( |
| 103 | + child: Container( |
| 104 | + color: Colors.brown.shade200, |
| 105 | + child: SingleChildScrollView( |
| 106 | + controller: controller, |
| 107 | + child: Column( |
| 108 | + children: [ |
| 109 | + Container( |
| 110 | + height: headerOffset, |
| 111 | + ), |
| 112 | + Lottie.asset( |
| 113 | + 'assets/appbar.json', |
| 114 | + width: 200, |
| 115 | + height: 200, |
| 116 | + fit: BoxFit.fill, |
| 117 | + ), |
| 118 | + Container( |
| 119 | + height: 200, |
| 120 | + width: 350, |
| 121 | + color: Colors.brown.shade200, |
| 122 | + child: Center( |
| 123 | + child: Column( |
| 124 | + mainAxisAlignment: MainAxisAlignment.center, |
| 125 | + children: [ |
| 126 | + Text( |
| 127 | + "PM2.5 é um sério problema de poluição atmosférica que afeta a saúde e o meio ambiente.", |
| 128 | + textAlign: TextAlign.center, |
| 129 | + style: TextStyle( |
| 130 | + color: Colors.black, fontSize: 20), |
| 131 | + ), |
| 132 | + SizedBox(height: 16), |
| 133 | + // Espaço de 16 de altura entre os parágrafos |
| 134 | + Text( |
| 135 | + "E a medicina veterinária é a guardiã da Saúde Única. Tendo isto em vista venho por meio deste apresentar os dados processados, em comparação com mortalidade de aves migratórias", |
| 136 | + textAlign: TextAlign.center, |
| 137 | + style: TextStyle( |
| 138 | + color: Colors.black, fontSize: 20), |
| 139 | + ), |
| 140 | + ], |
| 141 | + ), |
| 142 | + ), |
| 143 | + ), |
| 144 | + Container( |
| 145 | + child: Image.asset('assets/saudeunica.png'), |
| 146 | + width: 200, |
| 147 | + height: 200, |
| 148 | + ), |
| 149 | + ], |
| 150 | + ), |
| 151 | + ), |
| 152 | + ), |
| 153 | + ), |
| 154 | + ], |
| 155 | + ), |
| 156 | + ), |
| 157 | + ), |
| 158 | + ); |
| 159 | + } |
| 160 | + |
| 161 | + // Método para abrir URLs em um navegador externo |
| 162 | + Future<void> _launchURL(String url) async { |
| 163 | + if (await canLaunch(url)) { |
| 164 | + await launch(url); |
| 165 | + } else { |
| 166 | + throw 'Não foi possível abrir a URL: $url'; |
| 167 | + } |
| 168 | + } |
| 169 | + |
| 170 | + // Método para lidar com o evento do botão de recurso |
| 171 | + void _onFeaturePressed(BuildContext context, int index) { |
| 172 | + switch (index) { |
| 173 | + case 0: |
| 174 | + // Abre a página 'dados' quando o primeiro recurso é pressionado |
| 175 | + Navigator.pushNamed(context, '/dados'); |
| 176 | + break; |
| 177 | + case 1: |
| 178 | + // Abre o link do GitHub no navegador externo quando o segundo recurso é pressionado |
| 179 | + _launchURL(githubUrl); |
| 180 | + break; |
| 181 | + default: |
| 182 | + } |
| 183 | + } |
| 184 | +} |
0 commit comments