-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
250 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:organizei/Model/Item/ItemModel.dart'; | ||
import 'package:organizei/Model/Lista/ListaModel.dart'; | ||
import 'package:organizei/Repository/ListaRepository.dart'; | ||
import 'package:organizei/components/botao.dart'; | ||
import 'package:organizei/components/dialog_personalizado.dart'; | ||
import 'package:organizei/components/input.dart'; | ||
import 'package:organizei/components/selectCor.dart'; | ||
import 'package:organizei/components/selectData.dart'; | ||
import 'package:organizei/components/selectPrioridade.dart'; | ||
import '../../../Controller/ListaController.dart'; | ||
|
||
Future<dynamic> criarLista(BuildContext context, | ||
{ListaModel? lista = null, Function? fecharDialog = null}) { | ||
late ListaController listaController; | ||
|
||
listaController = ListaController(ListaRepository(), context); | ||
|
||
late List<ItemModel?>? itens = [ItemModel()]; | ||
|
||
if (lista != null) { | ||
listaController.controllerNome.text = lista.nome ?? ''; | ||
listaController.listaCor(lista.cor); | ||
listaController.listaId(lista.id); | ||
listaController.listaItens(lista.itens); | ||
} | ||
|
||
return showDialog( | ||
barrierDismissible: false, | ||
barrierColor: Colors.white.withOpacity(0), | ||
context: context, | ||
builder: (context) { | ||
return StatefulBuilder(builder: (context, StateSetter setState) { | ||
return Scaffold( | ||
backgroundColor: Colors.transparent, | ||
body: SingleChildScrollView( | ||
scrollDirection: Axis.vertical, | ||
child: Material( | ||
type: MaterialType.transparency, | ||
child: Form( | ||
key: listaController.formKey, | ||
child: Container( | ||
margin: const EdgeInsets.only(top: 24), | ||
height: itens.length < 3 | ||
? MediaQuery.of(context).size.height | ||
: null, | ||
child: DialogPersonalizado( | ||
nome: 'Lista', | ||
child: <Widget>[ | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 16), | ||
child: input( | ||
onSaved: listaController.listaNome, | ||
textController: listaController.controllerNome, | ||
label: 'nome', | ||
), | ||
), | ||
SelectCor( | ||
cor: listaController.listaCor, | ||
corAtual: lista?.cor ?? ''), | ||
ListView.builder( | ||
primary: false, | ||
shrinkWrap: true, | ||
itemCount: itens.length, | ||
itemBuilder: (context, index) { | ||
var item; | ||
|
||
//var dialog; | ||
|
||
var controllerNomeItem = TextEditingController(); | ||
|
||
return Padding( | ||
padding: const EdgeInsets.only(bottom: 16), | ||
child: input( | ||
//onSaved: listaController.listaNome, | ||
textController: controllerNomeItem, | ||
label: 'item', | ||
), | ||
); | ||
}), | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 16), | ||
child: Botao( | ||
texto: 'Novo item', | ||
cor: const Color(0xFF6BC8E4), | ||
clicar: () async { | ||
setState(() { | ||
itens.add(ItemModel()); | ||
}); | ||
|
||
// bool succes = await listaController.saveLista(); | ||
|
||
// if (succes == true) { | ||
// var nav = Navigator.of(context); | ||
// nav.pop(); | ||
|
||
// if (lista?.id != null) { | ||
// //nav.pop(); | ||
// nav.pop(); | ||
// } | ||
// fecharDialog!(); | ||
// } | ||
}, | ||
), | ||
), | ||
Botao( | ||
texto: 'Salvar', | ||
cor: const Color(0xFF6385C3), | ||
clicar: () async { | ||
bool succes = await listaController.saveLista(); | ||
|
||
if (succes == true) { | ||
var nav = Navigator.of(context); | ||
nav.pop(); | ||
|
||
if (lista?.id != null) { | ||
//nav.pop(); | ||
nav.pop(); | ||
} | ||
fecharDialog!(); | ||
} | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:organizei/Model/Tarefa/TarefaModel.dart'; | ||
import 'package:organizei/Repository/TarefaRepository.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'; | ||
|
||
Future<dynamic> visualizarTarefa(BuildContext context, | ||
{required TarefaModel tarefa, Function? fecharDialog = null}) { | ||
late TarefaController tarefaController; | ||
tarefaController = TarefaController(TarefaRepository(), context); | ||
|
||
tarefaController.tarefaId(tarefa.id); | ||
|
||
return showDialog( | ||
barrierDismissible: false, | ||
barrierColor: Colors.white.withOpacity(0), | ||
context: context, | ||
builder: (context) { | ||
return StatefulBuilder(builder: (context, StateSetter setState) { | ||
return Scaffold( | ||
backgroundColor: Colors.transparent, | ||
body: SingleChildScrollView( | ||
scrollDirection: Axis.vertical, | ||
child: Material( | ||
type: MaterialType.transparency, | ||
child: Form( | ||
key: tarefaController.formKey, | ||
child: Container( | ||
height: MediaQuery.of(context).size.height, | ||
margin: const EdgeInsets.only(top: 24), | ||
child: DialogPersonalizado( | ||
nome: tarefa.nome ?? '', | ||
cor: tarefa.cor ?? '', | ||
child: <Widget>[ | ||
Text(tarefa.observacao ?? ''), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: <Widget>[ | ||
const Text( | ||
'data: ', | ||
style: TextStyle( | ||
color: Colors.black, | ||
fontWeight: FontWeight.w700, | ||
), | ||
), | ||
Text(tarefa.data ?? ''), | ||
], | ||
), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: <Widget>[ | ||
const Text( | ||
'prioridade: ', | ||
style: TextStyle( | ||
color: Colors.black, | ||
fontWeight: FontWeight.w700, | ||
), | ||
), | ||
Text(tarefa.prioridade ?? ''), | ||
], | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 16, top: 16), | ||
child: Botao( | ||
texto: 'Concluir', | ||
cor: const Color(0xFF74C198), | ||
clicar: () async { | ||
bool succes = | ||
await tarefaController.concluirTarefa(true); | ||
|
||
if (succes == true) { | ||
Navigator.pop(context); | ||
fecharDialog!(); | ||
} | ||
}, | ||
), | ||
), | ||
Botao( | ||
texto: 'Editar', | ||
cor: const Color(0xFF6385C3), | ||
clicar: () async { | ||
criarTarefa(context, | ||
tarefa: tarefa, fecharDialog: fecharDialog); | ||
}, | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 16, top: 16), | ||
child: Botao( | ||
texto: 'Excluir', | ||
cor: const Color(0xFFEF7E69), | ||
clicar: () async { | ||
bool succes = | ||
await tarefaController.excluirTarefa(); | ||
|
||
if (succes == true) { | ||
Navigator.pop(context); | ||
fecharDialog!(); | ||
} | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters