From b1cf601e59110f51b199472ec9d1adc0513eec64 Mon Sep 17 00:00:00 2001 From: Willian <47341070+wjrcode@users.noreply.github.com> Date: Thu, 22 Sep 2022 17:45:52 -0300 Subject: [PATCH] Ajustes --- lib/Controller/TarefaController.dart | 2 +- lib/components/dialogs/tarefaDialog.dart | 9 +++++--- .../navigation/bottom_navigation_bar.dart | 3 +-- lib/components/navigation/menu.dart | 21 ++++--------------- lib/components/selectCor.dart | 7 +++---- lib/components/selectData.dart | 14 ++++++------- lib/components/selectPrioridade.dart | 6 +++--- 7 files changed, 25 insertions(+), 37 deletions(-) diff --git a/lib/Controller/TarefaController.dart b/lib/Controller/TarefaController.dart index fea8886..5b2b0b0 100644 --- a/lib/Controller/TarefaController.dart +++ b/lib/Controller/TarefaController.dart @@ -20,10 +20,10 @@ class TarefaController extends Base { tarefaCor(String? value) => model.cor = value.toString(); var controllerNome = TextEditingController(); - var controllerDataehora = TextEditingController(); var controllerObservacao = TextEditingController(); var controllerPrioridade = TextEditingController(); var controllerCor = TextEditingController(); + var controllerDataehora = TextEditingController(); Future saveTarefa() async { if (!formKey.currentState!.validate()) { diff --git a/lib/components/dialogs/tarefaDialog.dart b/lib/components/dialogs/tarefaDialog.dart index f84e95a..3b32340 100644 --- a/lib/components/dialogs/tarefaDialog.dart +++ b/lib/components/dialogs/tarefaDialog.dart @@ -41,7 +41,9 @@ Future criarTarefa(BuildContext context) { label: 'nome', ), ), - SelectData(tarefaController: tarefaController), + SelectData( + controller: tarefaController.controllerDataehora, + onSaved: tarefaController.tarefaDataehora), Padding( padding: const EdgeInsets.only(bottom: 16), child: input( @@ -51,8 +53,9 @@ Future criarTarefa(BuildContext context) { label: 'observação', ), ), - SelectPrioridade(tarefaController: tarefaController), - SelectCor(tarefaController: tarefaController), + SelectPrioridade( + prioridade: tarefaController.tarefaPrioridade), + SelectCor(cor: tarefaController.tarefaCor), Botao( texto: 'Cadastrar', cor: const Color(0xFF6385C3), diff --git a/lib/components/navigation/bottom_navigation_bar.dart b/lib/components/navigation/bottom_navigation_bar.dart index 6511fde..9b0588c 100644 --- a/lib/components/navigation/bottom_navigation_bar.dart +++ b/lib/components/navigation/bottom_navigation_bar.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:organizei/components/navigation/menu.dart'; @@ -50,7 +49,7 @@ class _ButtonNavigatorBarState extends State offset: offset, duration: const Duration(milliseconds: 250), curve: Curves.easeInOut, - child: Container(child: Menu(customFunction: _slideDown)), + child: Container(child: Menu(fecharMenu: _slideDown)), ), Box( radius: 30, diff --git a/lib/components/navigation/menu.dart b/lib/components/navigation/menu.dart index 528ac1b..c640c51 100644 --- a/lib/components/navigation/menu.dart +++ b/lib/components/navigation/menu.dart @@ -1,31 +1,17 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -//import 'package:intl/intl.dart'; -import 'package:organizei/Repository/TarefaRepository.dart'; -import 'package:organizei/components/botao.dart'; -import 'package:organizei/components/box.dart'; import 'package:organizei/components/dialog_personalizado.dart'; import 'package:organizei/components/dialogs/tarefaDialog.dart'; -import 'package:organizei/components/input.dart'; -import 'package:organizei/components/texto_contornado.dart'; -import 'package:organizei/home_page.dart'; -import 'package:intl/date_symbol_data_local.dart'; -import 'package:intl/intl.dart' as intl; - -import '../../Controller/TarefaController.dart'; class Menu extends StatefulWidget { - const Menu({Key? key, this.customFunction}) : super(key: key); + const Menu({Key? key, this.fecharMenu}) : super(key: key); - final customFunction; + final fecharMenu; @override State createState() => _MenuState(); } class _MenuState extends State { - late TarefaController tarefaController; - @override Widget build(BuildContext context) { return Column( @@ -53,7 +39,7 @@ class _MenuState extends State { children: [ GestureDetector( onTap: () { - widget.customFunction(); + widget.fecharMenu(); showDialog( barrierDismissible: false, barrierColor: Colors.white.withOpacity(0), @@ -184,6 +170,7 @@ class _MenuState extends State { GestureDetector( onTap: () { criarTarefa(context); + widget.fecharMenu(); }, child: AbsorbPointer( child: Row( diff --git a/lib/components/selectCor.dart b/lib/components/selectCor.dart index 50a456b..4c4fb70 100644 --- a/lib/components/selectCor.dart +++ b/lib/components/selectCor.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:organizei/Controller/TarefaController.dart'; class SelectCor extends StatefulWidget { - final TarefaController tarefaController; - const SelectCor({Key? key, required this.tarefaController}) : super(key: key); + final dynamic cor; + const SelectCor({Key? key, required this.cor}) : super(key: key); @override State createState() => _SelectCorState(); @@ -48,8 +48,7 @@ class _SelectCorState extends State { setState(() { corSelected = strone; }); - widget.tarefaController - .tarefaCor(corSelected.toString()); + widget.cor(corSelected.toString()); }, child: Container( width: 60, diff --git a/lib/components/selectData.dart b/lib/components/selectData.dart index b7eb85e..061bd57 100644 --- a/lib/components/selectData.dart +++ b/lib/components/selectData.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:organizei/Controller/TarefaController.dart'; import 'package:organizei/components/input.dart'; import 'package:intl/date_symbol_data_local.dart'; import 'package:intl/intl.dart' as intl; class SelectData extends StatefulWidget { - final TarefaController tarefaController; - const SelectData({Key? key, required this.tarefaController}) + final dynamic onSaved; + final TextEditingController? controller; + const SelectData({Key? key, required this.onSaved, this.controller}) : super(key: key); @override @@ -29,8 +29,8 @@ class _SelectDataState extends State { return Padding( padding: const EdgeInsets.only(bottom: 16), child: input( - onSaved: widget.tarefaController.tarefaDataehora, - textController: widget.tarefaController.controllerDataehora, + onSaved: widget.onSaved, + textController: widget.controller, label: 'data e hora', placeholder: 'Selecione a data e hora', readOnly: true, @@ -119,14 +119,14 @@ class _SelectDataState extends State { date = newDate; }); - widget.tarefaController.tarefaDataehora(newDateTime.toString()); + widget.onSaved(newDateTime.toString()); intl.Intl.defaultLocale = 'pt_BR'; initializeDateFormatting('pt_BR'); intl.DateFormat('dd/MM/yyyy HH:mm').format(newDateTime); - widget.tarefaController.controllerDataehora.text = + widget.controller!.text = intl.DateFormat('dd/MM/yyyy HH:mm').format(newDateTime); }), ); diff --git a/lib/components/selectPrioridade.dart b/lib/components/selectPrioridade.dart index 0f0e5c2..2abc208 100644 --- a/lib/components/selectPrioridade.dart +++ b/lib/components/selectPrioridade.dart @@ -5,8 +5,8 @@ import '../Controller/TarefaController.dart'; const List list = ['baixa', 'média', 'alta']; class SelectPrioridade extends StatefulWidget { - final TarefaController? tarefaController; - const SelectPrioridade({Key? key, this.tarefaController}) : super(key: key); + final dynamic prioridade; + const SelectPrioridade({Key? key, this.prioridade}) : super(key: key); @override State createState() => _DropdownButtonExampleState(); @@ -50,7 +50,7 @@ class _DropdownButtonExampleState extends State { borderRadius: BorderRadius.circular(16.0), ), ), - onSaved: widget.tarefaController!.tarefaPrioridade, + onSaved: widget.prioridade, value: dropdownValue, elevation: 16, style: const TextStyle(color: Colors.grey),