From bbb0ae94fb5c3bb08e36a30b6697e3f4695531bc Mon Sep 17 00:00:00 2001 From: Willian <47341070+wjrcode@users.noreply.github.com> Date: Tue, 18 Oct 2022 10:43:32 -0300 Subject: [PATCH] dash --- lib/dashborad_page.dart | 116 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 lib/dashborad_page.dart diff --git a/lib/dashborad_page.dart b/lib/dashborad_page.dart new file mode 100644 index 0000000..910c72b --- /dev/null +++ b/lib/dashborad_page.dart @@ -0,0 +1,116 @@ +import 'package:flutter/material.dart'; +import 'package:organizei/Controller/DashboardController.dart'; +import 'package:organizei/Repository/DashboardRepository.dart'; +import 'package:organizei/components/card_item.dart'; +import 'components/navigation/bottom_navigation_bar.dart'; +import 'components/texto_contornado.dart'; + +class DashboardPage extends StatefulWidget { + const DashboardPage({Key? key}) : super(key: key); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State { + @override + Widget build(BuildContext context) { + late DashboardController dashboardController; + dashboardController = DashboardController(DashboardRepository(), context); + + return Scaffold( + resizeToAvoidBottomInset: false, + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + extendBody: true, + backgroundColor: const Color(0xFFE9E9E9), + body: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + TextoContornado( + texto: 'Dashboard', + tamanho: 32, + cor: Color(0xFF6385C3), + ) + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0), + child: Column(children: [ + FutureBuilder( + future: dashboardController.getDashboard(), + builder: (context, AsyncSnapshot snapshot) { + if (!snapshot.hasData) { + return const Center( + child: CircularProgressIndicator()); + } + + if (snapshot.hasError) { + return const Center( + child: Text('Ocorreu um erro!'), + ); + } + + if (snapshot.data['dashboard'].length == 0) { + return const Center( + child: Padding( + padding: EdgeInsets.only(top: 32.0), + child: Text("Você não tem dashboard!"), + ), + ); + } + + return ListView.builder( + primary: false, + shrinkWrap: true, + itemCount: snapshot.data['dashboard'].length, + itemBuilder: (context, index) { + return cardItem( + cor: Color(int.tryParse( + snapshot.data['dashboard'][index] + ['cor'] ?? + '0xFF6385C3') ?? + 0), + //nome: item.nome, + horario: snapshot.data['dashboard'][index] + ['msg'], + dash: snapshot.data['dashboard'][index] + ['dash'], + ); + }); + }), + ]), + ) + ], + ), + ], + ), + ), + ), + floatingActionButton: ButtonNavigatorBar( + iconSelected: 'dashboard', + fecharDialog: () { + setState(() {}); + }, + ) + // + ); + } +}