From 0641e17c44b30784979474311f1de6b364799421 Mon Sep 17 00:00:00 2001 From: wjrcode Date: Sun, 16 Oct 2022 16:40:51 -0300 Subject: [PATCH] Projetos --- .../dialogs/projetos/projetoDialog.dart | 56 +++++--- .../navigation/bottom_navigation_bar.dart | 7 + lib/projetos_page.dart | 127 ++++++++++++++++++ 3 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 lib/projetos_page.dart diff --git a/lib/components/dialogs/projetos/projetoDialog.dart b/lib/components/dialogs/projetos/projetoDialog.dart index fa5defd..0bb6a29 100644 --- a/lib/components/dialogs/projetos/projetoDialog.dart +++ b/lib/components/dialogs/projetos/projetoDialog.dart @@ -1,17 +1,17 @@ import 'package:flutter/material.dart'; -import 'package:organizei/Model/Tarefa/TarefaModel.dart'; -import 'package:organizei/Repository/TarefaRepository.dart'; +import 'package:organizei/Model/Projeto/ProjetoModel.dart'; +import 'package:organizei/Repository/ProjetoRepository.dart'; import 'package:organizei/components/botao.dart'; import 'package:organizei/components/dialog_personalizado.dart'; -import 'package:organizei/components/dialogs/tarefas/tarefaCadastroDialog.dart'; -import '../../../Controller/TarefaController.dart'; +import 'package:organizei/components/dialogs/projetos/projetoCadastroDialog.dart'; +import '../../../Controller/ProjetoController.dart'; Future visualizarProjeto(BuildContext context, - {required TarefaModel tarefa, Function? fecharDialog = null}) { - late TarefaController tarefaController; - tarefaController = TarefaController(TarefaRepository(), context); + {required ProjetoModel projeto, Function? fecharDialog = null}) { + late ProjetoController projetoController; + projetoController = ProjetoController(ProjetoRepository(), context); - tarefaController.tarefaId(tarefa.id); + projetoController.projetoId(projeto.id); return showDialog( barrierDismissible: false, @@ -26,7 +26,7 @@ Future visualizarProjeto(BuildContext context, child: Material( type: MaterialType.transparency, child: Form( - key: tarefaController.formKey, + key: projetoController.formKey, child: Padding( padding: const EdgeInsets.only(top: 24.0), child: ConstrainedBox( @@ -34,22 +34,22 @@ Future visualizarProjeto(BuildContext context, minHeight: MediaQuery.of(context).size.height, ), child: DialogPersonalizado( - nome: tarefa.nome ?? '', - cor: tarefa.cor ?? '', + nome: projeto.nome ?? '', + cor: projeto.cor ?? '', child: [ - Text(tarefa.observacao ?? ''), + Text(projeto.observacao ?? ''), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( - 'data: ', + 'data inicial: ', style: TextStyle( color: Colors.black, fontWeight: FontWeight.w700, ), ), - Text(tarefa.data ?? ''), + Text(projeto.dataInicial ?? ''), ], ), Row( @@ -57,13 +57,27 @@ Future visualizarProjeto(BuildContext context, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( - 'prioridade: ', + 'data final: ', style: TextStyle( color: Colors.black, fontWeight: FontWeight.w700, ), ), - Text(tarefa.prioridade ?? ''), + Text(projeto.dataFinal ?? ''), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + 'progresso: ', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w700, + ), + ), + Text(''), ], ), Padding( @@ -72,8 +86,8 @@ Future visualizarProjeto(BuildContext context, texto: 'Concluir', cor: const Color(0xFF74C198), clicar: () async { - bool succes = - await tarefaController.concluirTarefa(true); + bool succes = await projetoController + .concluirProjeto(true); if (succes == true) { Navigator.pop(context); @@ -86,8 +100,8 @@ Future visualizarProjeto(BuildContext context, texto: 'Editar', cor: const Color(0xFF6385C3), clicar: () async { - criarTarefa(context, - tarefa: tarefa, fecharDialog: fecharDialog); + criarProjeto(context, + projeto: projeto, fecharDialog: fecharDialog); }, ), Padding( @@ -97,7 +111,7 @@ Future visualizarProjeto(BuildContext context, cor: const Color(0xFFEF7E69), clicar: () async { bool succes = - await tarefaController.excluirTarefa(); + await projetoController.excluirProjeto(); if (succes == true) { Navigator.pop(context); diff --git a/lib/components/navigation/bottom_navigation_bar.dart b/lib/components/navigation/bottom_navigation_bar.dart index b9a23fc..f5b8c4d 100644 --- a/lib/components/navigation/bottom_navigation_bar.dart +++ b/lib/components/navigation/bottom_navigation_bar.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:organizei/components/navigation/menu.dart'; import 'package:organizei/home_page.dart'; import 'package:organizei/listas_page.dart'; +import 'package:organizei/projetos_page.dart'; import '../box.dart'; @@ -159,6 +160,12 @@ class _ButtonNavigatorBarState extends State setState(() { widget.iconSelected = 'projetos'; }); + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ProjetosPage()), + ); }, ), ], diff --git a/lib/projetos_page.dart b/lib/projetos_page.dart new file mode 100644 index 0000000..22ec5de --- /dev/null +++ b/lib/projetos_page.dart @@ -0,0 +1,127 @@ +import 'package:flutter/material.dart'; +import 'package:organizei/Controller/ProjetoController.dart'; +import 'package:organizei/Model/Projeto/ProjetoModel.dart'; +import 'package:organizei/Repository/ProjetoRepository.dart'; +import 'package:organizei/components/card_item.dart'; +import 'package:organizei/components/dialogs/projetos/projetoDialog.dart'; +import 'components/navigation/bottom_navigation_bar.dart'; +import 'components/texto_contornado.dart'; + +class ProjetosPage extends StatefulWidget { + const ProjetosPage({Key? key}) : super(key: key); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State { + late String? apelido = ''; + + @override + Widget build(BuildContext context) { + late ProjetoController listaController; + listaController = ProjetoController(ProjetoRepository(), 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: 'Projetos', + tamanho: 32, + cor: const Color(0xFF6385C3), + ) + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0), + child: Column(children: [ + FutureBuilder( + future: listaController.getProjetos(), + 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['projetos'].length == 0) { + return const Center( + child: Padding( + padding: EdgeInsets.only(top: 32.0), + child: Text("Você não tem projetos!"), + ), + ); + } + + return ListView.builder( + primary: false, + shrinkWrap: true, + itemCount: snapshot.data['projetos'].length, + itemBuilder: (context, index) { + var item = ProjetoModel.fromJson( + snapshot.data['projetos'][index], + ); + + return cardItem( + cor: Color(int.tryParse( + item.cor ?? '0xFF6385C3') ?? + 0), + nome: item.nome, + horario: '', + abrirDialog: () { + return visualizarProjeto( + context, + projeto: item, + fecharDialog: () { + setState(() {}); + }, + ); + }); + }); + }), + ]), + ) + ], + ), + ], + ), + ), + ), + floatingActionButton: ButtonNavigatorBar( + iconSelected: 'projetos', + fecharDialog: () { + setState(() {}); + }, + ) + // + ); + } +}