Skip to content

Commit

Permalink
Projetos
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Oct 16, 2022
1 parent db99c42 commit 0641e17
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 21 deletions.
56 changes: 35 additions & 21 deletions lib/components/dialogs/projetos/projetoDialog.dart
Original file line number Diff line number Diff line change
@@ -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<dynamic> 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,
Expand All @@ -26,44 +26,58 @@ Future<dynamic> 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(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height,
),
child: DialogPersonalizado(
nome: tarefa.nome ?? '',
cor: tarefa.cor ?? '',
nome: projeto.nome ?? '',
cor: projeto.cor ?? '',
child: <Widget>[
Text(tarefa.observacao ?? ''),
Text(projeto.observacao ?? ''),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text(
'data: ',
'data inicial: ',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
Text(tarefa.data ?? ''),
Text(projeto.dataInicial ?? ''),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
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: <Widget>[
const Text(
'progresso: ',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
Text(''),
],
),
Padding(
Expand All @@ -72,8 +86,8 @@ Future<dynamic> 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);
Expand All @@ -86,8 +100,8 @@ Future<dynamic> visualizarProjeto(BuildContext context,
texto: 'Editar',
cor: const Color(0xFF6385C3),
clicar: () async {
criarTarefa(context,
tarefa: tarefa, fecharDialog: fecharDialog);
criarProjeto(context,
projeto: projeto, fecharDialog: fecharDialog);
},
),
Padding(
Expand All @@ -97,7 +111,7 @@ Future<dynamic> visualizarProjeto(BuildContext context,
cor: const Color(0xFFEF7E69),
clicar: () async {
bool succes =
await tarefaController.excluirTarefa();
await projetoController.excluirProjeto();

if (succes == true) {
Navigator.pop(context);
Expand Down
7 changes: 7 additions & 0 deletions lib/components/navigation/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -159,6 +160,12 @@ class _ButtonNavigatorBarState extends State<ButtonNavigatorBar>
setState(() {
widget.iconSelected = 'projetos';
});

Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ProjetosPage()),
);
},
),
],
Expand Down
127 changes: 127 additions & 0 deletions lib/projetos_page.dart
Original file line number Diff line number Diff line change
@@ -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<ProjetosPage> createState() => _HomePageState();
}

class _HomePageState extends State<ProjetosPage> {
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: <Widget>[
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: const <Widget>[
TextoContornado(
texto: 'Projetos',
tamanho: 32,
cor: const Color(0xFF6385C3),
)
],
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0),
child: Column(children: <Widget>[
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(() {});
},
)
//
);
}
}

0 comments on commit 0641e17

Please sign in to comment.