Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:principal/CalculadoraController.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'CALCULADORA DE IMC',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- double _sliderVal = 100;
- @override
- Widget build(BuildContext context) {
- var tela = MediaQuery.of(context).size.width;
- return Scaffold(
- backgroundColor: Colors.black87,
- appBar: AppBar(
- title: Text("Calculadora de IMC", style: TextStyle(fontSize: tela * .05),),
- centerTitle: true,
- backgroundColor: Colors.transparent,
- elevation: 0.0,
- ),
- body: _body(context, tela),
- );
- }
- Widget _body(context, tela){
- return SingleChildScrollView(
- child: StreamBuilder(
- stream: calcBloc.outCalc,
- builder: (context, snapshot) {
- return Column(
- children: <Widget>[
- Padding(padding: EdgeInsets.only(top: tela * .08)),
- _generos(context, tela, snapshot.data["genero"]),
- Padding(padding: EdgeInsets.only(top: tela * .08)),
- _altura(context, tela, snapshot.data["altura"]),
- ],
- );
- }
- ),
- );
- }
- Widget _generos(context, tela, genero){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: <Widget>[
- GestureDetector(
- onTap: (){
- print("Clicado masculino");
- calcBloc.alteraGenero("Masculino");
- },
- child: Container(
- decoration:
- BoxDecoration(
- color: genero == "Masculino" ? Colors.blue : Colors.black12,
- gradient: LinearGradient(colors: [Colors.blue, Colors.black12],
- ),
- border: Border.all(width: 2, color: Colors.white),
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- ),
- child: Column(
- children: <Widget>[
- Icon(Icons.trending_up, size: tela * .25, color: Colors.white,),
- Text("Masculino", style: TextStyle(fontSize: tela * .05, color: Colors.white),),
- ],
- ),
- ),
- ),
- GestureDetector(
- onTap: (){
- print("Clicado feminino");
- calcBloc.alteraGenero("Feminino");
- },
- child: Container(
- decoration:
- BoxDecoration(
- color: genero == "Feminino" ? Colors.pink : Colors.black12,
- gradient: LinearGradient(colors: [Colors.pink, Colors.black12],
- ),
- border: Border.all(width: 2, color: Colors.white),
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- ),
- child: Column(
- children: <Widget>[
- Icon(Icons.trending_down, size: tela * .25, color: Colors.white,),
- Text("Feminino", style: TextStyle(fontSize: tela * .05, color: Colors.white),),
- ],
- ),
- ),
- ),
- ],
- );
- }
- Widget _altura(context, tela, altura){
- return Container(
- decoration: BoxDecoration(
- color: Color.fromRGBO(0, 0, 199, .35),
- borderRadius: BorderRadius.circular(10)
- ),
- padding: EdgeInsets.only(top: tela * .05, bottom: tela * .05),
- child: Column(
- children: <Widget>[
- Text("Altura", style: TextStyle(color: Colors.white, fontSize: tela *.04),),
- Text(altura.toString(), style: TextStyle(color: Colors.white, fontSize: tela *.08),
- ),
- Text("Centímetros", style: TextStyle(color: Colors.white, fontSize: tela *.04),),
- Slider(
- value: _sliderVal,
- onChanged: (newRating) {
- _sliderVal = newRating;
- print(newRating);
- calcBloc.addAltura(double.parse(newRating.toStringAsFixed(0)));
- // _sliderVal = altura;
- },
- min: 0, max: 300,),
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement