From de2857445528bfc21af5658b7af0400ca95f99d8 Mon Sep 17 00:00:00 2001 From: Willian <47341070+wjrcode@users.noreply.github.com> Date: Thu, 22 Sep 2022 16:20:27 -0300 Subject: [PATCH] =?UTF-8?q?Refatora=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/box.dart | 33 +- lib/components/dialog_personalizado.dart | 2 - lib/components/dialogs/tarefaDialog.dart | 76 ++++ lib/components/input.dart | 10 +- lib/components/navigation/menu.dart | 478 +---------------------- lib/components/selectCor.dart | 76 ++++ lib/components/selectData.dart | 278 +++++++++++++ lib/components/selectPrioridade.dart | 73 ++++ 8 files changed, 531 insertions(+), 495 deletions(-) create mode 100644 lib/components/dialogs/tarefaDialog.dart create mode 100644 lib/components/selectCor.dart create mode 100644 lib/components/selectData.dart create mode 100644 lib/components/selectPrioridade.dart diff --git a/lib/components/box.dart b/lib/components/box.dart index f6161ac..d224a78 100644 --- a/lib/components/box.dart +++ b/lib/components/box.dart @@ -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, + ), ); } } diff --git a/lib/components/dialog_personalizado.dart b/lib/components/dialog_personalizado.dart index 87e3c87..44cdaba 100644 --- a/lib/components/dialog_personalizado.dart +++ b/lib/components/dialog_personalizado.dart @@ -36,10 +36,8 @@ class _DialogPersonalizadoState extends State @override void initState() { - //offset = const Offset(0, 2); super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) => _slideUp()); - //offset = const Offset(0, 2); } @override diff --git a/lib/components/dialogs/tarefaDialog.dart b/lib/components/dialogs/tarefaDialog.dart new file mode 100644 index 0000000..f84e95a --- /dev/null +++ b/lib/components/dialogs/tarefaDialog.dart @@ -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 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: [ + 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); + } + }, + ), + ], + ), + ), + ), + ), + ), + ); + }); + }); +} diff --git a/lib/components/input.dart b/lib/components/input.dart index bda037d..625fcee 100644 --- a/lib/components/input.dart +++ b/lib/components/input.dart @@ -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, @@ -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( diff --git a/lib/components/navigation/menu.dart b/lib/components/navigation/menu.dart index 545fdca..528ac1b 100644 --- a/lib/components/navigation/menu.dart +++ b/lib/components/navigation/menu.dart @@ -1,12 +1,16 @@ 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'; @@ -242,478 +246,4 @@ class _MenuState extends State { ], ); } - - Future criarTarefa(BuildContext context) { - setState(() { - tarefaController = TarefaController(TarefaRepository(), context); - }); - List cores = [ - 0xFF6385C3, - 0xFFEF7E69, - 0xFF6BC8E4, - 0xFFF7BC36, - 0xFF74C198 - ]; - - late int corSelected = 0; - - DateTime date = new DateTime.now(); - final horas = date.hour.toString(); - final horasf = horas.padLeft(2, '0'); - final minutos = date.minute.toString(); - final minutosf = minutos.padLeft(2, '0'); - - 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', - //minHeight: MediaQuery.of(context).size.height * 0.8, - child: [ - Padding( - padding: const EdgeInsets.only(bottom: 16), - child: input( - onSaved: tarefaController.tarefaNome, - textController: tarefaController.controllerNome, - label: 'nome', - ), - ), - // Padding( - // padding: const EdgeInsets.only(bottom: 16), - // child: input( - // onSaved: tarefaController.tarefaDataehora, - // textController: - // tarefaController.controllerDataehora, - // label: 'data e hora', - // ), - // ), - Botao( - texto: 'data', - cor: const Color(0xFF6385C3), - clicar: () async { - DateTime? newDate = await veipls( - context: context, - initialDate: date, - firstDate: DateTime(2020), - lastDate: DateTime(2100), - builder: (BuildContext context, child) { - return Theme( - data: Theme.of(context).copyWith( - colorScheme: ColorScheme.light( - primary: Color(0xFF6385C3), - ), - dialogTheme: DialogTheme( - backgroundColor: Color(0xFFE9E9E9), - elevation: 1, - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 3, - color: Colors.black), - borderRadius: BorderRadius.circular( - 16.0), // this is the border radius of the picker - ), - ), - ), - child: child!, - ); - }); - - if (newDate == null) return; - - final time = await showTimePicker( - context: context, - initialTime: TimeOfDay( - hour: date.hour, minute: date.minute), - builder: (BuildContext context, child) { - return Theme( - data: ThemeData.light().copyWith( - timePickerTheme: - TimePickerThemeData( - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 3, - color: Colors.black), - borderRadius: BorderRadius.circular( - 16.0), // this is the border radius of the picker - ), - backgroundColor: - Color(0xFFE9E9E9), - hourMinuteColor: - MaterialStateColor.resolveWith( - (states) => states - .contains( - MaterialState - .selected) - ? Color(0xFFE9E9E9) - : Color(0xFFE9E9E9)), - dialHandColor: Color(0xFFE9E9E9), - dialTextColor: MaterialStateColor - .resolveWith((states) => - states.contains( - MaterialState - .selected) - ? Colors.black - : Colors.black), - hourMinuteTextColor: - MaterialStateColor.resolveWith( - (states) => states - .contains( - MaterialState - .selected) - ? Color(0xFF6385C3) - : Colors.black), - dialBackgroundColor: - Color(0xFF6385C3), - ), - textButtonTheme: - TextButtonThemeData( - style: ButtonStyle( - foregroundColor: - MaterialStateColor - .resolveWith( - (states) => - Color( - 0xFF6385C3)), - overlayColor: - MaterialStateColor - .resolveWith( - (states) => - Color(0xFF6385C3), - )))), - child: child!, - ); - }); - - if (time == null) return; - - final newDateTime = DateTime( - date.year, - date.month, - date.day, - time.hour, - time.minute, - ); - - setState(() { - date = newDate; - }); - - tarefaController - .tarefaDataehora(newDateTime.toString()); - }), - Padding( - padding: const EdgeInsets.only(bottom: 16), - child: input( - onSaved: tarefaController.tarefaObservacao, - textController: - tarefaController.controllerObservacao, - label: 'observação', - ), - //child: Input(label: 'observação'), - ), - Padding( - padding: const EdgeInsets.only(bottom: 16), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - 'prioridade', - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.w400, - ), - ), - DropdownButtonExample( - tarefaController: tarefaController), - ], - ), - //child: Input(label: 'senha'), - ), - const Text( - 'cor', - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.w400, - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: 16), - child: Expanded( - child: SizedBox( - height: 50, - child: ListView( - itemExtent: 70.0, - scrollDirection: Axis.horizontal, - children: cores.map((strone) { - return GestureDetector( - onTap: () { - setState(() { - corSelected = strone; - }); - tarefaController.tarefaCor( - corSelected.toString()); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color(strone), - border: Border.all( - width: corSelected == strone - ? 5 - : 3, - color: corSelected == strone - ? Colors.white - : Colors.black, - style: BorderStyle.solid, - )), - ), - ); - }).toList(), - ), - ), - )), - // Container( - // height: 200, - // ), - Botao( - texto: 'Cadastrar', - cor: const Color(0xFF6385C3), - clicar: () async { - bool succes = await tarefaController.saveTarefa(); - - if (succes == true) { - Navigator.pop(context); - //entrar(context); - } - }, - ), - ], - ), - ), - ), - ), - ), - ); - }); - }); - } -} - -Future veipls({ - required BuildContext context, - required DateTime initialDate, - required DateTime firstDate, - required DateTime lastDate, - DateTime? currentDate, - DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar, - SelectableDayPredicate? selectableDayPredicate, - String? helpText, - String? cancelText, - String? confirmText, - Locale? locale, - bool useRootNavigator = true, - RouteSettings? routeSettings, - TextDirection? textDirection, - TransitionBuilder? builder, - DatePickerMode initialDatePickerMode = DatePickerMode.day, - String? errorFormatText, - String? errorInvalidText, - String? fieldHintText, - String? fieldLabelText, - TextInputType? keyboardType, - Offset? anchorPoint, -}) async { - assert(context != null); - assert(initialDate != null); - assert(firstDate != null); - assert(lastDate != null); - initialDate = DateUtils.dateOnly(initialDate); - firstDate = DateUtils.dateOnly(firstDate); - lastDate = DateUtils.dateOnly(lastDate); - assert( - !lastDate.isBefore(firstDate), - 'lastDate $lastDate must be on or after firstDate $firstDate.', - ); - assert( - !initialDate.isBefore(firstDate), - 'initialDate $initialDate must be on or after firstDate $firstDate.', - ); - assert( - !initialDate.isAfter(lastDate), - 'initialDate $initialDate must be on or before lastDate $lastDate.', - ); - assert( - selectableDayPredicate == null || selectableDayPredicate(initialDate), - 'Provided initialDate $initialDate must satisfy provided selectableDayPredicate.', - ); - assert(initialEntryMode != null); - assert(useRootNavigator != null); - assert(initialDatePickerMode != null); - assert(debugCheckHasMaterialLocalizations(context)); - - Widget dialog = DatePickerDialog( - initialDate: initialDate, - firstDate: firstDate, - lastDate: lastDate, - currentDate: currentDate, - initialEntryMode: initialEntryMode, - selectableDayPredicate: selectableDayPredicate, - helpText: helpText, - cancelText: cancelText, - confirmText: confirmText, - initialCalendarMode: initialDatePickerMode, - errorFormatText: errorFormatText, - errorInvalidText: errorInvalidText, - fieldHintText: fieldHintText, - fieldLabelText: fieldLabelText, - keyboardType: keyboardType, - ); - - if (textDirection != null) { - dialog = Directionality( - textDirection: textDirection, - child: dialog, - ); - } - - if (locale != null) { - dialog = Localizations.override( - context: context, - locale: locale, - child: dialog, - ); - } - - return showDialog( - barrierDismissible: false, - barrierColor: Colors.white.withOpacity(0), - context: context, - useRootNavigator: useRootNavigator, - routeSettings: routeSettings, - builder: (BuildContext context) { - return builder == null ? dialog : builder(context, dialog); - }, - anchorPoint: anchorPoint, - ); -} - -Future showTimePicker({ - required BuildContext context, - required TimeOfDay initialTime, - TransitionBuilder? builder, - bool useRootNavigator = true, - TimePickerEntryMode initialEntryMode = TimePickerEntryMode.dial, - String? cancelText, - String? confirmText, - String? helpText, - String? errorInvalidText, - String? hourLabelText, - String? minuteLabelText, - RouteSettings? routeSettings, - EntryModeChangeCallback? onEntryModeChanged, - Offset? anchorPoint, -}) async { - assert(context != null); - assert(initialTime != null); - assert(useRootNavigator != null); - assert(initialEntryMode != null); - assert(debugCheckHasMaterialLocalizations(context)); - - final Widget dialog = TimePickerDialog( - initialTime: initialTime, - initialEntryMode: initialEntryMode, - cancelText: cancelText, - confirmText: confirmText, - helpText: helpText, - errorInvalidText: errorInvalidText, - hourLabelText: hourLabelText, - minuteLabelText: minuteLabelText, - onEntryModeChanged: onEntryModeChanged, - ); - return showDialog( - barrierDismissible: false, - barrierColor: Colors.white.withOpacity(0), - context: context, - useRootNavigator: useRootNavigator, - builder: (BuildContext context) { - return builder == null ? dialog : builder(context, dialog); - }, - routeSettings: routeSettings, - anchorPoint: anchorPoint, - ); -} - -const List list = ['baixa', 'média', 'alta']; - -class DropdownButtonExample extends StatefulWidget { - late TarefaController? tarefaController; - DropdownButtonExample({Key? key, this.tarefaController}) : super(key: key); - - @override - State createState() => _DropdownButtonExampleState(); -} - -class _DropdownButtonExampleState extends State { - String dropdownValue = list.first; - - @override - Widget build(BuildContext context) { - return DropdownButtonFormField( - borderRadius: BorderRadius.circular(20), - icon: const Icon(Icons.expand_more), - decoration: InputDecoration( - fillColor: Colors.white, - filled: true, - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.black, - width: 3.0, - ), - borderRadius: BorderRadius.circular(16.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.black, - width: 3.0, - ), - borderRadius: BorderRadius.circular(16.0), - ), - ), - onSaved: widget.tarefaController!.tarefaPrioridade, - value: dropdownValue, - elevation: 16, - style: const TextStyle(color: Colors.grey), - onChanged: (String? value) { - // This is called when the user selects an item. - setState(() { - dropdownValue = value!; - }); - }, - items: list.map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ); - } } diff --git a/lib/components/selectCor.dart b/lib/components/selectCor.dart new file mode 100644 index 0000000..50a456b --- /dev/null +++ b/lib/components/selectCor.dart @@ -0,0 +1,76 @@ +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); + + @override + State createState() => _SelectCorState(); +} + +class _SelectCorState extends State { + List cores = [ + 0xFF6385C3, + 0xFFEF7E69, + 0xFF6BC8E4, + 0xFFF7BC36, + 0xFF74C198 + ]; + + late int corSelected = 0; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'cor', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w400, + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Expanded( + child: SizedBox( + height: 50, + child: ListView( + itemExtent: 70.0, + scrollDirection: Axis.horizontal, + children: cores.map((strone) { + return GestureDetector( + onTap: () { + setState(() { + corSelected = strone; + }); + widget.tarefaController + .tarefaCor(corSelected.toString()); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Color(strone), + border: Border.all( + width: corSelected == strone ? 5 : 3, + color: corSelected == strone + ? Colors.white + : Colors.black, + style: BorderStyle.solid, + )), + ), + ); + }).toList(), + ), + ), + )), + ], + ); + } +} diff --git a/lib/components/selectData.dart b/lib/components/selectData.dart new file mode 100644 index 0000000..b7eb85e --- /dev/null +++ b/lib/components/selectData.dart @@ -0,0 +1,278 @@ +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}) + : super(key: key); + + @override + State createState() => _SelectDataState(); +} + +class _SelectDataState extends State { + List cores = [ + 0xFF6385C3, + 0xFFEF7E69, + 0xFF6BC8E4, + 0xFFF7BC36, + 0xFF74C198 + ]; + + late int corSelected = 0; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 16), + child: input( + onSaved: widget.tarefaController.tarefaDataehora, + textController: widget.tarefaController.controllerDataehora, + label: 'data e hora', + placeholder: 'Selecione a data e hora', + readOnly: true, + customFunction: () async { + DateTime date = new DateTime.now(); + + DateTime? newDate = await showDatePicker( + context: context, + initialDate: date, + firstDate: DateTime(2020), + lastDate: DateTime(2100), + builder: (BuildContext context, child) { + return Theme( + data: Theme.of(context).copyWith( + colorScheme: const ColorScheme.light( + primary: Color(0xFF6385C3), + ), + dialogTheme: DialogTheme( + backgroundColor: const Color(0xFFE9E9E9), + elevation: 1, + shape: RoundedRectangleBorder( + side: const BorderSide(width: 3, color: Colors.black), + borderRadius: BorderRadius.circular(16.0), + ), + ), + ), + child: child!, + ); + }, + ); + + if (newDate == null) return; + + final time = await showTimePicker( + context: context, + initialTime: TimeOfDay(hour: date.hour, minute: date.minute), + builder: (BuildContext context, child) { + return Theme( + data: ThemeData.light().copyWith( + timePickerTheme: TimePickerThemeData( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 3, color: Colors.black), + borderRadius: BorderRadius.circular(16.0), + ), + backgroundColor: const Color(0xFFE9E9E9), + hourMinuteColor: MaterialStateColor.resolveWith( + (states) => states.contains(MaterialState.selected) + ? const Color(0xFFE9E9E9) + : const Color(0xFFE9E9E9)), + dialHandColor: Color(0xFFE9E9E9), + dialTextColor: MaterialStateColor.resolveWith( + (states) => states.contains(MaterialState.selected) + ? Colors.black + : Colors.black), + hourMinuteTextColor: MaterialStateColor.resolveWith( + (states) => states.contains(MaterialState.selected) + ? const Color(0xFF6385C3) + : Colors.black), + dialBackgroundColor: const Color(0xFF6385C3), + ), + textButtonTheme: TextButtonThemeData( + style: ButtonStyle( + foregroundColor: MaterialStateColor.resolveWith( + (states) => const Color(0xFF6385C3)), + overlayColor: MaterialStateColor.resolveWith( + (states) => const Color(0xFF6385C3), + ), + ), + ), + ), + child: child!, + ); + }); + + if (time == null) return; + + final newDateTime = DateTime( + newDate.year, + newDate.month, + newDate.day, + time.hour, + time.minute, + ); + + setState(() { + date = newDate; + }); + + widget.tarefaController.tarefaDataehora(newDateTime.toString()); + + intl.Intl.defaultLocale = 'pt_BR'; + initializeDateFormatting('pt_BR'); + + intl.DateFormat('dd/MM/yyyy HH:mm').format(newDateTime); + + widget.tarefaController.controllerDataehora.text = + intl.DateFormat('dd/MM/yyyy HH:mm').format(newDateTime); + }), + ); + } +} + +Future showDatePicker({ + required BuildContext context, + required DateTime initialDate, + required DateTime firstDate, + required DateTime lastDate, + DateTime? currentDate, + DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar, + SelectableDayPredicate? selectableDayPredicate, + String? helpText, + String? cancelText, + String? confirmText, + Locale? locale, + bool useRootNavigator = true, + RouteSettings? routeSettings, + TextDirection? textDirection, + TransitionBuilder? builder, + DatePickerMode initialDatePickerMode = DatePickerMode.day, + String? errorFormatText, + String? errorInvalidText, + String? fieldHintText, + String? fieldLabelText, + TextInputType? keyboardType, + Offset? anchorPoint, +}) async { + assert(context != null); + assert(initialDate != null); + assert(firstDate != null); + assert(lastDate != null); + initialDate = DateUtils.dateOnly(initialDate); + firstDate = DateUtils.dateOnly(firstDate); + lastDate = DateUtils.dateOnly(lastDate); + assert( + !lastDate.isBefore(firstDate), + 'lastDate $lastDate must be on or after firstDate $firstDate.', + ); + assert( + !initialDate.isBefore(firstDate), + 'initialDate $initialDate must be on or after firstDate $firstDate.', + ); + assert( + !initialDate.isAfter(lastDate), + 'initialDate $initialDate must be on or before lastDate $lastDate.', + ); + assert( + selectableDayPredicate == null || selectableDayPredicate(initialDate), + 'Provided initialDate $initialDate must satisfy provided selectableDayPredicate.', + ); + assert(initialEntryMode != null); + assert(useRootNavigator != null); + assert(initialDatePickerMode != null); + assert(debugCheckHasMaterialLocalizations(context)); + + Widget dialog = DatePickerDialog( + initialDate: initialDate, + firstDate: firstDate, + lastDate: lastDate, + currentDate: currentDate, + initialEntryMode: initialEntryMode, + selectableDayPredicate: selectableDayPredicate, + helpText: helpText, + cancelText: cancelText, + confirmText: confirmText, + initialCalendarMode: initialDatePickerMode, + errorFormatText: errorFormatText, + errorInvalidText: errorInvalidText, + fieldHintText: fieldHintText, + fieldLabelText: fieldLabelText, + keyboardType: keyboardType, + ); + + if (textDirection != null) { + dialog = Directionality( + textDirection: textDirection, + child: dialog, + ); + } + + if (locale != null) { + dialog = Localizations.override( + context: context, + locale: locale, + child: dialog, + ); + } + + return showDialog( + barrierDismissible: false, + barrierColor: Colors.white.withOpacity(0), + context: context, + useRootNavigator: useRootNavigator, + routeSettings: routeSettings, + builder: (BuildContext context) { + return builder == null ? dialog : builder(context, dialog); + }, + anchorPoint: anchorPoint, + ); +} + +Future showTimePicker({ + required BuildContext context, + required TimeOfDay initialTime, + TransitionBuilder? builder, + bool useRootNavigator = true, + TimePickerEntryMode initialEntryMode = TimePickerEntryMode.dial, + String? cancelText, + String? confirmText, + String? helpText, + String? errorInvalidText, + String? hourLabelText, + String? minuteLabelText, + RouteSettings? routeSettings, + EntryModeChangeCallback? onEntryModeChanged, + Offset? anchorPoint, +}) async { + assert(context != null); + assert(initialTime != null); + assert(useRootNavigator != null); + assert(initialEntryMode != null); + assert(debugCheckHasMaterialLocalizations(context)); + + final Widget dialog = TimePickerDialog( + initialTime: initialTime, + initialEntryMode: initialEntryMode, + cancelText: cancelText, + confirmText: confirmText, + helpText: helpText, + errorInvalidText: errorInvalidText, + hourLabelText: hourLabelText, + minuteLabelText: minuteLabelText, + onEntryModeChanged: onEntryModeChanged, + ); + return showDialog( + barrierDismissible: false, + barrierColor: Colors.white.withOpacity(0), + context: context, + useRootNavigator: useRootNavigator, + builder: (BuildContext context) { + return builder == null ? dialog : builder(context, dialog); + }, + routeSettings: routeSettings, + anchorPoint: anchorPoint, + ); +} diff --git a/lib/components/selectPrioridade.dart b/lib/components/selectPrioridade.dart new file mode 100644 index 0000000..0f0e5c2 --- /dev/null +++ b/lib/components/selectPrioridade.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; + +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); + + @override + State createState() => _DropdownButtonExampleState(); +} + +class _DropdownButtonExampleState extends State { + String dropdownValue = list.first; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'prioridade', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w400, + ), + ), + DropdownButtonFormField( + borderRadius: BorderRadius.circular(20), + icon: const Icon(Icons.expand_more), + decoration: InputDecoration( + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.black, + width: 3.0, + ), + borderRadius: BorderRadius.circular(16.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.black, + width: 3.0, + ), + borderRadius: BorderRadius.circular(16.0), + ), + ), + onSaved: widget.tarefaController!.tarefaPrioridade, + value: dropdownValue, + elevation: 16, + style: const TextStyle(color: Colors.grey), + onChanged: (String? value) { + // This is called when the user selects an item. + setState(() { + dropdownValue = value!; + }); + }, + items: list.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ], + ); + } +}