Skip to content

Commit

Permalink
Refatoração
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Sep 22, 2022
1 parent f7a4fce commit de28574
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 495 deletions.
33 changes: 15 additions & 18 deletions lib/components/box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,22 @@ class Box extends StatelessWidget {
),
),
child: Container(
constraints: BoxConstraints(
minHeight: minHeight != null ? minHeight! : 0,
),
margin: EdgeInsets.only(top: 3, left: 3, right: 3),
padding: EdgeInsets.only(bottom: padding != null ? padding! : 0),
decoration: BoxDecoration(
color: Color(0xFFE9E9E9),
borderRadius: BorderRadius.only(
topRight: radius != null
? Radius.circular(radius!)
: Radius.circular(0),
topLeft: radius != null
? Radius.circular(radius!)
: Radius.circular(0),
),
constraints: BoxConstraints(
minHeight: minHeight != null ? minHeight! : 0,
),
margin: EdgeInsets.only(top: 3, left: 3, right: 3),
padding: EdgeInsets.only(bottom: padding != null ? padding! : 0),
decoration: BoxDecoration(
color: Color(0xFFE9E9E9),
borderRadius: BorderRadius.only(
topRight:
radius != null ? Radius.circular(radius!) : Radius.circular(0),
topLeft:
radius != null ? Radius.circular(radius!) : Radius.circular(0),
),
child:
//SingleChildScrollView(scrollDirection: Axis.vertical, child: child),
child),
),
child: child,
),
);
}
}
2 changes: 0 additions & 2 deletions lib/components/dialog_personalizado.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ class _DialogPersonalizadoState extends State<DialogPersonalizado>

@override
void initState() {
//offset = const Offset(0, 2);
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => _slideUp());
//offset = const Offset(0, 2);
}

@override
Expand Down
76 changes: 76 additions & 0 deletions lib/components/dialogs/tarefaDialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:organizei/Repository/TarefaRepository.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/TarefaController.dart';

Future<dynamic> criarTarefa(BuildContext context) {
late TarefaController tarefaController;
//setState(() {
tarefaController = TarefaController(TarefaRepository(), context);
// });

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(
margin: const EdgeInsets.only(top: 24),
child: DialogPersonalizado(
nome: 'Tarefa',
child: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: input(
onSaved: tarefaController.tarefaNome,
textController: tarefaController.controllerNome,
label: 'nome',
),
),
SelectData(tarefaController: tarefaController),
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: input(
onSaved: tarefaController.tarefaObservacao,
textController:
tarefaController.controllerObservacao,
label: 'observação',
),
),
SelectPrioridade(tarefaController: tarefaController),
SelectCor(tarefaController: tarefaController),
Botao(
texto: 'Cadastrar',
cor: const Color(0xFF6385C3),
clicar: () async {
bool succes = await tarefaController.saveTarefa();

if (succes == true) {
Navigator.pop(context);
}
},
),
],
),
),
),
),
),
);
});
});
}
10 changes: 9 additions & 1 deletion lib/components/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Widget input(
{dynamic onSaved,
TextEditingController? textController,
String? label,
bool senha = false}) {
bool senha = false,
bool readOnly = false,
String? placeholder = '',
Function? customFunction}) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
Expand All @@ -21,9 +24,14 @@ Widget input(
color: Colors.white.withOpacity(0),
child: TextFormField(
obscureText: senha,
onTap: () {
return customFunction!();
},
readOnly: readOnly,
onSaved: onSaved,
controller: textController,
decoration: InputDecoration(
hintText: placeholder,
fillColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(
Expand Down
Loading

0 comments on commit de28574

Please sign in to comment.