diff --git a/catavento/lib/main.dart b/catavento/lib/main.dart index b8d887c..c793d63 100644 --- a/catavento/lib/main.dart +++ b/catavento/lib/main.dart @@ -3,7 +3,6 @@ import 'package:catavento/constants.dart'; import 'package:catavento/screens/dashboardAdmin/dashboard_admin.dart'; import 'package:catavento/screens/Login/login.dart'; import 'package:catavento/screens/employee-management.dart'; -import 'package:catavento/views/login_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; @@ -21,7 +20,7 @@ void main() { ), home: const LoadView(), routes: { - loginRoute: (context) => const LoginView(), + loginRoute: (context) => const Login(), homeRoute: (context) => const DashBoardAdmin(), crudFuncionariosRoute: (context) => EmployeeManagement(), }, @@ -48,7 +47,7 @@ class LoadView extends StatelessWidget { builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: - return const Login(); + return const DashBoardAdmin(); default: return const CircularProgressIndicator(); } diff --git a/catavento/lib/screens/DashboardAdmin/components/quadroGrafico.dart b/catavento/lib/screens/DashboardAdmin/components/quadroGrafico.dart index 59eb896..b053ad3 100644 --- a/catavento/lib/screens/DashboardAdmin/components/quadroGrafico.dart +++ b/catavento/lib/screens/DashboardAdmin/components/quadroGrafico.dart @@ -24,7 +24,7 @@ class QuadroGraficoState extends State { Widget build(BuildContext context) { final size = MediaQuery.of(context).size; // Tamanho da tela return BlocBuilder( - buildWhen: (previous, current) => current is! FilterState, + buildWhen: (previous, current) => current is! DemandaFilterState, builder: (context, response) { final metaData = response.metaData; diff --git a/catavento/lib/screens/DashboardAdmin/components/search.dart b/catavento/lib/screens/DashboardAdmin/components/search.dart index 918a31c..9638c18 100644 --- a/catavento/lib/screens/DashboardAdmin/components/search.dart +++ b/catavento/lib/screens/DashboardAdmin/components/search.dart @@ -49,7 +49,7 @@ class SearchState extends State { onEditingComplete: () { context.read().add(DemandaFilter( // BACKEND - 'nomeDemanda', + 'nome_demanda', _nomeDemanda.text, )); // BACKEND }, diff --git a/catavento/lib/screens/DashboardAdmin/dashboard_admin.dart b/catavento/lib/screens/DashboardAdmin/dashboard_admin.dart index c03961a..83e972e 100644 --- a/catavento/lib/screens/DashboardAdmin/dashboard_admin.dart +++ b/catavento/lib/screens/DashboardAdmin/dashboard_admin.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'package:catavento/screens/DashboardAdmin/components/demandCard.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:flutter/services.dart'; @@ -19,7 +20,6 @@ import 'package:catavento/shared/widgets/inputs.dart'; import 'package:catavento/screens/DashboardAdmin/components/quadroPrioridade.dart'; import 'package:catavento/screens/DashboardAdmin/components/quadroGrafico.dart'; import 'package:catavento/screens/DashboardAdmin/components/search.dart'; -import 'package:catavento/screens/DashboardAdmin/components/demandCard.dart'; class DashBoardAdmin extends StatelessWidget { const DashBoardAdmin({super.key}); @@ -203,12 +203,12 @@ class ListDemandaState extends State { final demanda = state.databaseResponse[index]; return DemandCard( nomeDemanda: - demanda['nomeDemanda'] ?? 'Nome não disponível', + demanda['nome_demanda'] ?? 'Nome não disponível', status: demanda['status'] ?? 'Status não disponível', codigo: demanda['codigo'] ?? 'Sem código', descricao: demanda['descricao'] ?? 'Sem descricao', id: demanda['id'], - imagemUrl: demanda['imagemUrl'] ?? '', + imagemUrl: demanda['imagem_url'] ?? '', order: index, bloc: context.read(), // BACKEND ); diff --git a/catavento/lib/screens/Login/login.dart b/catavento/lib/screens/Login/login.dart index 633d4f3..b0a9060 100644 --- a/catavento/lib/screens/Login/login.dart +++ b/catavento/lib/screens/Login/login.dart @@ -4,13 +4,13 @@ import 'package:flutter/material.dart'; import 'components/input_purple.dart'; import 'components/button_singIn.dart'; - -class Login extends StatefulWidget{ - const Login ({super.key}); +class Login extends StatefulWidget { + const Login({super.key}); @override - _LoginState createState()=> _LoginState(); + _LoginState createState() => _LoginState(); } + class _LoginState extends State { bool isLoading = false; @override @@ -51,7 +51,8 @@ class _LoginState extends State { SizedBox( height: 60, ), - Form(child: Column( + Form( + child: Column( children: [ PurpleTextField( label: "Digite o nome do seu usuário", @@ -60,7 +61,9 @@ class _LoginState extends State { color: Color(0xCCACACAC), ), ), - SizedBox(height: 20,), + SizedBox( + height: 20, + ), PurpleTextField( label: "Digite a sua senha", icon: Icon( @@ -72,22 +75,20 @@ class _LoginState extends State { )), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ Container( - margin: EdgeInsets.fromLTRB(0, 50, 20, 0), child: ButtonSingIn( - title: Text("Entrar" , style: TextStyle( - color: Colors.white - ),), + title: Text( + "Entrar", + style: TextStyle(color: Colors.white), + ), isLoading: isLoading, icon: Icon( Icons.keyboard_arrow_right_rounded, color: Colors.white, ), onPressed: () { - setState(() { isLoading = !isLoading; }); @@ -97,7 +98,6 @@ class _LoginState extends State { ], ) //SizedBox(height: 35), - ], ), ), @@ -118,9 +118,4 @@ class _LoginState extends State { ), ); } - - - } - - diff --git a/catavento/lib/screens/dashboardAdmin/components/blocks.dart b/catavento/lib/screens/dashboardAdmin/components/blocks.dart index fae97c1..d9383aa 100644 --- a/catavento/lib/screens/dashboardAdmin/components/blocks.dart +++ b/catavento/lib/screens/dashboardAdmin/components/blocks.dart @@ -1,5 +1,3 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; class Blocks extends StatefulWidget { @@ -26,7 +24,6 @@ class Blocks extends StatefulWidget { } class BlocksState extends State { - @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; @@ -42,12 +39,10 @@ class BlocksState extends State { height: blockHeight, padding: EdgeInsets.all(8.0), decoration: BoxDecoration( - color: widget.color, - borderRadius: BorderRadius.circular(widget.borderRadius) - ), + color: widget.color, + borderRadius: BorderRadius.circular(widget.borderRadius)), ), - - if (widget.title != null) + if (widget.title != null) Positioned( top: 10, left: 0, @@ -63,15 +58,13 @@ class BlocksState extends State { ), ), ), - Positioned.fill( child: Align( alignment: Alignment.center, child: widget.child, ), ), - ], ); } -} \ No newline at end of file +} diff --git a/catavento/lib/screens/dashboardAdmin/components/demandCard.dart b/catavento/lib/screens/dashboardAdmin/components/demandCard.dart index 130c5de..d94ea74 100644 --- a/catavento/lib/screens/dashboardAdmin/components/demandCard.dart +++ b/catavento/lib/screens/dashboardAdmin/components/demandCard.dart @@ -1,33 +1,198 @@ import 'package:flutter/material.dart'; -// esse componente nao esta sendo utilizado -class ReducedDemandCard extends StatelessWidget { - final String demanda; +import 'package:catavento/bloc/demanda_bloc.dart'; +import 'package:catavento/shared/widgets/dialog.dart'; +import 'package:catavento/screens/dashboardAdmin/components/infoCard.dart'; +import 'package:catavento/shared/widgets/inputs.dart'; +import 'package:catavento/shared/widgets/confirmDialog.dart'; - const ReducedDemandCard({required this.demanda, super.key}); +class DemandCard extends StatelessWidget { + final String nomeDemanda; + final String status; + final String codigo; + final String descricao; + final int id; + final String imagemUrl; + final int order; + final DemandaBloc bloc; // BACKEND + + const DemandCard({ + super.key, + required this.nomeDemanda, + required this.codigo, + required this.status, + required this.descricao, + required this.id, + required this.order, + required this.imagemUrl, + required this.bloc, // BACKEND + }); @override Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.1), - blurRadius: 4, - offset: const Offset(0, 2), - ), - ], - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Icon(Icons.cake, color: Color(0xFF015C98)), - const SizedBox(width: 8), - Text(demanda), - ], + final TextEditingController nomeController = + TextEditingController(text: nomeDemanda); + final TextEditingController codigoController = + TextEditingController(text: codigo); + final TextEditingController descricaoController = + TextEditingController(text: descricao); + + return Card( + margin: EdgeInsets.symmetric(vertical: 8.0), + child: ListTile( + title: Text(nomeDemanda), + subtitle: Text( + 'Código: ${codigo.isNotEmpty ? codigo : 'Sem código'}\nStatus: $status'), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + imagemUrl.isNotEmpty + ? Image.network(imagemUrl, width: 50, height: 50) + : Icon(Icons.image, size: 50), + IconButton( + icon: Icon(Icons.info), + onPressed: () { + _showInfoDialog(context, nomeDemanda, codigo, descricao, status, + "https://via.placeholder.com/150"); + }, + ), + // botão de Editar. + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + // editar a demanda + _showEditDialog( + context, + nomeController, + codigoController, + descricaoController, + bloc); // BACKEND (não retirar o bloc, o resto OK) + }, + ), + // apagar + IconButton( + icon: Icon(Icons.delete), + onPressed: () async { + showDialog( + context: context, + builder: (BuildContext context) { + return ConfirmDialog( + title: 'Confirmar Exclusão', + contente: + 'Tem certeza de que deseja apagar esta demanda?', + onConfirm: () { + Navigator.of(context).pop(); // Fecha o diálogo + bloc.add(DemandaDelete(id, order)); // BACKEND + }, + ); + }, + ); + }), + ], + ), ), ); } + + // Função para mostrar as informações da demanda em um diálogo + void _showInfoDialog(BuildContext context, String nome, String codigo, + String descricao, String status, String imageUrl) { + showDialog( + context: context, + builder: (BuildContext context) { + return ReusableDialog( + title: "Informações da Demanda", + body: InfoCard( + nome: nome, + codigo: codigo, + descricao: descricao, + status: status, + imageUrl: imageUrl, + ), + confirmBeforeClose: false, + ); + }, + ); + } + + void _showEditDialog( + BuildContext context, + TextEditingController nomeController, + TextEditingController codigoController, + TextEditingController descricaoController, + DemandaBloc bloc) { + showDialog( + context: context, + builder: (context) { + return ReusableDialog( + title: "Editar Demanda", + confirmBeforeClose: true, // Ativa a confirmação para fechar a janela + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + InputTextField( + labelText: "Nome da Demanda", + hintText: "Digite o nome da demanda", + controller: nomeController, + ), + const SizedBox(height: 10), + InputTextField( + labelText: "Código da Demanda", + hintText: "Digite o código da demanda", + controller: codigoController, + ), + const SizedBox(height: 10), + InputTextField( + labelText: "Descrição", + hintText: "Digite a descrição", + controller: descricaoController, + maxLines: 3, + keyboardType: TextInputType.multiline, + ), + const SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + onPressed: () { + // Conexão com o Backend + bloc.add(DemandaUpdate( + id, + order, + nomeController.text, + codigoController.text, + descricaoController.text, + )); + Navigator.pop(context); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF50B432), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(22), + ), + ), + child: const Text("Salvar"), + ), + const SizedBox(width: 10), + ElevatedButton( + onPressed: () { + Navigator.pop(context); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFD54A3D), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(22), + ), + ), + child: const Text("Cancelar"), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } } diff --git a/catavento/lib/screens/dashboardAdmin/components/funcionarioCard.dart b/catavento/lib/screens/dashboardAdmin/components/funcionarioCard.dart index 60c3677..003bda0 100644 --- a/catavento/lib/screens/dashboardAdmin/components/funcionarioCard.dart +++ b/catavento/lib/screens/dashboardAdmin/components/funcionarioCard.dart @@ -1,10 +1,10 @@ -import 'package:catavento/screens/components/infoFuncionarios.dart'; -import 'package:catavento/screens/components/showDialog.dart'; +import 'package:catavento/screens/dashboardAdmin/components/infoFuncionarios.dart'; +import 'package:catavento/screens/dashboardAdmin/components/showDialog.dart'; import 'package:flutter/material.dart'; import 'input.dart'; import 'confirmDialog.dart'; -class FuncionarioCard extends StatefulWidget{ +class FuncionarioCard extends StatefulWidget { final String nomeFuncionario; final String status; final String setor; @@ -22,17 +22,14 @@ class FuncionarioCard extends StatefulWidget{ } } -class FuncionarioCardState extends State{ - +class FuncionarioCardState extends State { @override Widget build(BuildContext context) { - return Card( margin: EdgeInsets.symmetric(vertical: 8.0), child: ListTile( title: Text(widget.nomeFuncionario), - subtitle: Text( - 'Setor: ${widget.setor}\nStatus: ${widget.status}'), + subtitle: Text('Setor: ${widget.setor}\nStatus: ${widget.status}'), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -48,17 +45,20 @@ class FuncionarioCardState extends State{ height: 402, title: 'nomeFuncionario', //Inserir o nome do funcionario child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - - children: [ - Infofuncionarios(nome: "Fulano", email: "email", status: "Ativo", setor: "Montagem", demanda: "Hello Kitty") //Trocar para as informações do banco de dados - ] - ), + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Infofuncionarios( + nome: "Fulano", + email: "email", + status: "Ativo", + setor: "Montagem", + demanda: + "Hello Kitty") //Trocar para as informações do banco de dados + ]), ); }, ); - }, ), // botão de Editar. @@ -74,47 +74,59 @@ class FuncionarioCardState extends State{ height: 402, title: 'Editar', child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - - children: [ - Inputs(text: "Nome:",), - SizedBox(height: MediaQuery.of(context).size.height * 0.02), - Inputs(text: "Setor:",), - SizedBox(height: MediaQuery.of(context).size.height * 0.02), - Inputs(text: "Email:",), - SizedBox(height: MediaQuery.of(context).size.height * 0.02), - Inputs(text: "Nome de usuário:",), - SizedBox(height: MediaQuery.of(context).size.height * 0.02), - Inputs(text: "Senha:",), - SizedBox(height: MediaQuery.of(context).size.height * 0.08), - - Positioned.fill( - child: Center( - child: ElevatedButton(onPressed: (){ - //Lógica do botão - Navigator.pop(context); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.green, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(22) - ) - ), - child: Text( - "Cadastrar", - style: TextStyle(color: Colors.white), - ) - - ) - ) - ) - ] - ), + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Inputs( + text: "Nome:", + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02), + Inputs( + text: "Setor:", + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02), + Inputs( + text: "Email:", + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02), + Inputs( + text: "Nome de usuário:", + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02), + Inputs( + text: "Senha:", + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.08), + Positioned.fill( + child: Center( + child: ElevatedButton( + onPressed: () { + //Lógica do botão + Navigator.pop(context); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(22))), + child: Text( + "Cadastrar", + style: TextStyle(color: Colors.white), + )))) + ]), ); }, ); - }, ), // apagar @@ -141,4 +153,4 @@ class FuncionarioCardState extends State{ ), ); } -} \ No newline at end of file +} diff --git a/catavento/lib/screens/dashboardAdmin/components/graph.dart b/catavento/lib/screens/dashboardAdmin/components/graph.dart index 7f1fd19..f4b04d4 100644 --- a/catavento/lib/screens/dashboardAdmin/components/graph.dart +++ b/catavento/lib/screens/dashboardAdmin/components/graph.dart @@ -22,24 +22,22 @@ class PizzaChart extends StatelessWidget { return LayoutBuilder( builder: (context, constraints) { return SizedBox( - width: constraints.maxWidth, // Largura total disponível - height: constraints.maxHeight, // Altura total disponível + width: constraints.maxWidth, + height: constraints.maxHeight, child: PieChart( PieChartData( sections: [ PieChartSectionData( - value: completasPercent * 100, // Percentual de completas + value: completasPercent * 100, title: '${(completasPercent * 100).toStringAsFixed(1)}%', color: colors[0], - radius: - constraints.maxWidth * 0.3, // Ajusta com base no tamanho + radius: constraints.maxWidth * 0.3, ), PieChartSectionData( - value: restantesPercent * 100, // Percentual de restantes + value: restantesPercent * 100, title: '${(restantesPercent * 100).toStringAsFixed(1)}%', color: colors[1], - radius: - constraints.maxWidth * 0.3, // Ajusta com base no tamanho + radius: constraints.maxWidth * 0.3, ), ], centerSpaceRadius: @@ -51,3 +49,74 @@ class PizzaChart extends StatelessWidget { ); } } + +class ChartContainer extends StatelessWidget { + final int completas; + final int restantes; + final List colors; + + const ChartContainer({ + super.key, + required this.completas, + required this.restantes, + required this.colors, + }); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: 150, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.2), + blurRadius: 8, + offset: Offset(0, 4), + ), + ], + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0), + child: Row( + children: [ + // Texto à esquerda + Expanded( + flex: 2, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Completas: $completas", + style: TextStyle(fontSize: 16, color: Colors.black), + ), + SizedBox(height: 5), + Text( + "Restantes: $restantes", + style: TextStyle(fontSize: 16, color: Colors.black), + ), + SizedBox(height: 10), + Text( + "Total: ${completas + restantes}", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ], + ), + ), + // Gráfico à direita + Expanded( + flex: 3, + child: PizzaChart( + completas: completas, + restantes: restantes, + colors: colors, + ), + ), + ], + ), + ), + ); + } +} diff --git a/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart b/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart index ae6ff47..83e972e 100644 --- a/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart +++ b/catavento/lib/screens/dashboardAdmin/dashboard_admin.dart @@ -1,72 +1,36 @@ import 'dart:io'; +import 'package:catavento/screens/DashboardAdmin/components/demandCard.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:flutter/services.dart'; +import 'package:image_picker/image_picker.dart'; +// BACKEND import 'package:catavento/bloc/demanda_bloc.dart'; import 'package:catavento/bloc/demanda_controller.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:intl/intl.dart'; -import 'package:catavento/screens/dashboardAdmin/components/stage_demand.dart'; -import 'package:catavento/screens/dashboardAdmin/components/menu.dart'; import '../../services/table_import/table_import.dart'; import '../../services/table_import/table_picker.dart'; -import '../dashboardAdmin/components/confirmDialog.dart'; -import 'package:image_picker/image_picker.dart'; +// components +import 'package:catavento/shared/widgets/header.dart'; +import 'package:catavento/shared/widgets/menu.dart'; +import 'package:catavento/shared/widgets/dialog.dart'; +import 'package:catavento/shared/widgets/inputs.dart'; +import 'package:catavento/screens/DashboardAdmin/components/quadroPrioridade.dart'; +import 'package:catavento/screens/DashboardAdmin/components/quadroGrafico.dart'; +import 'package:catavento/screens/DashboardAdmin/components/search.dart'; class DashBoardAdmin extends StatelessWidget { const DashBoardAdmin({super.key}); @override Widget build(BuildContext context) { + String formattedDate = DateFormat('dd/MM/yyyy').format(DateTime.now()); + return Scaffold( drawer: Navbar(), - appBar: AppBar( - backgroundColor: Colors.transparent, - elevation: 0, - iconTheme: const IconThemeData( - color: Color(0xFF015C98), - ), - leading: Builder( - builder: (BuildContext context) { - return Padding( - padding: const EdgeInsets.only(left: 20), // Padding aqui - child: Material( - color: Colors.transparent, // Mantém o fundo transparente - child: InkWell( - onTap: () { - Scaffold.of(context).openDrawer(); // Abre o Drawer - }, - child: const Icon( - Icons.menu, - size: 40.0, - color: Color(0xFF015C98), - ), - ), - ), - ); - }, - ), - actions: [ - Padding( - padding: const EdgeInsets.only( - right: 20), // Ajuste o valor conforme necessário - child: TextButton.icon( - icon: const Icon(Icons.history, size: 18.0), - label: const Text("Ver Histórico"), - onPressed: () {}, - style: TextButton.styleFrom( - foregroundColor: Colors.white, - backgroundColor: const Color(0xFF015C98), - padding: - const EdgeInsets.symmetric(horizontal: 15, vertical: 10), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), - ), - ), - ), - ], - ), + appBar: CustomHeader(title: 'Demandas atuais $formattedDate'), extendBodyBehindAppBar: true, body: Stack( children: [ @@ -108,270 +72,87 @@ class AddDemandPageAdmin extends StatefulWidget { } } -//Estrutura da pagina class AddDemandPageAdminState extends State { late final DemandaController demandaController; @override void initState() { - // demandaController = DemandaController(context.read()); - // demandaController.initialize(); super.initState(); } @override Widget build(BuildContext context) { - String formattedDate = DateFormat('dd/MM/yyyy').format(DateTime.now()); + final size = MediaQuery.of(context).size; // Obtém o tamanho da tela - return Stack( - children: [ - Center( + return SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(20), + child: Center( child: Column( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - //Titulo - Text( - 'Demandas atuais $formattedDate', - style: TextStyle(fontSize: 29.5, color: Color(0xFF015C98)), + // Barra de Pesquisa + Padding( + padding: EdgeInsets.zero, + child: Search(), ), - - SizedBox(height: 40), - - //Barra de pesquisa - Search(), - - SizedBox( - height: 30, - ), - - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - QuadroPrioridade(), - SizedBox( - width: 16, - ), - ListDemanda(), - SizedBox( - width: 16, - ), - QuadroGrafico() - ], - ), - - SizedBox( - height: 37, + SizedBox(height: 20), + + // Ajustando a altura com Flex/Expanded + Padding( + padding: EdgeInsets.symmetric(horizontal: 0), + child: LayoutBuilder( + builder: (context, constraints) { + return constraints.maxWidth > 600 + ? Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // ainda falta ajustar a responsividade desse quadro, além de q o design vai mudar + Flexible( + flex: 1, + child: QuadroPrioridade(), + ), + SizedBox(width: 15), + Flexible( + flex: 2, + child: ListDemanda(), + ), + SizedBox(width: 15), + Flexible( + flex: 1, + child: QuadroGrafico(), + ), + ], + ) + : Column( + children: [ + Expanded( + child: QuadroPrioridade(), + ), + SizedBox(height: size.height * 0.02), + Expanded( + child: ListDemanda(), + ), + SizedBox(height: size.height * 0.02), + Expanded( + child: QuadroGrafico(), + ), + ], + ); + }, + ), ), ], ), - ) - ], + ), + ), ); } @override void dispose() { super.dispose(); - // demandaController.finalize(); - } -} - -//Icon Menu -class IconMenu extends StatefulWidget { - const IconMenu({super.key}); - - @override - State createState() { - return IconMenuState(); - } -} - -//Icon Menu -class IconMenuState extends State { - @override - Widget build(BuildContext context) { - //Icon Menu - return Positioned( - top: 20, - left: 20, - child: IconButton( - iconSize: 50, - onPressed: () { - //Logica do menu - }, - icon: Icon(Icons.menu), - color: Color(0xFF015C98), - ), - ); - } -} - -//Graficos -class QuadroGrafico extends StatefulWidget { - const QuadroGrafico({super.key}); - - @override - State createState() { - return QuadroGraficoState(); - } -} - -//Graficos -class QuadroGraficoState extends State { - @override - Widget build(BuildContext context) { - return BlocBuilder( - buildWhen: (previous, current) => current is! DemandaFilterState, - builder: (context, response) { - final metaData = response.metaData; - - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - //Grafico 1 - Container( - width: 340, - height: 132, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - ), - child: Padding( - padding: - EdgeInsets.symmetric(vertical: 15.0, horizontal: 30.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Completas: ${metaData['completo']}\n" - "Restantes: ${metaData['restantes']}\n", - style: TextStyle( - fontSize: 17, - color: Colors.black, - ), - ), - SizedBox( - height: 2, - ), - Text( - "Total: ${metaData['total']}", - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.black), - ) - ], - ))), - - SizedBox( - height: 20, - ), - - Container( - width: 340, - height: 132, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: - EdgeInsets.only(top: 10.0, bottom: 10.0, left: 60.0), - child: Icon( - Icons.cake, - size: 80.0, - color: Colors.pink, - ), - ), - SizedBox( - width: 30, - ), - Padding( - padding: EdgeInsets.only(top: 25.0, right: 40.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - "${metaData['fabricacao']}", - style: TextStyle( - fontSize: 30, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - SizedBox( - height: 2, - ), - Text( - "Em fabricação", - style: - TextStyle(fontSize: 18, color: Colors.black), - ) - ], - )), - ], - )), - - SizedBox( - height: 30, - ), - - Container( - width: 340, - height: 132, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: - EdgeInsets.only(top: 10.0, bottom: 10.0, left: 60.0), - child: Icon( - Icons.layers, - size: 80.0, - color: Color(0xFF015C98), - ), - ), - SizedBox( - width: 40, - ), - Padding( - padding: EdgeInsets.only(top: 25.0, right: 20.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - "${metaData['espera']}", - style: TextStyle( - fontSize: 30, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - SizedBox( - height: 2, - ), - Text( - "Em espera", - style: - TextStyle(fontSize: 18, color: Colors.black), - ) - ], - )), - ], - )), - ], - ); - }, - ); } } @@ -394,40 +175,51 @@ class ListDemandaState extends State { @override Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; // Tamanho da tela return Container( - padding: EdgeInsets.all(7.0), - width: 499, - height: 438, + padding: EdgeInsets.all(10.0), + width: size.width * 0.9, + height: size.height * 0.65, decoration: BoxDecoration( color: Color(0xFFFFFFFF), borderRadius: BorderRadius.circular(17), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.3), + spreadRadius: 1, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], ), child: Column( children: [ - Expanded(child: BlocBuilder( - builder: (context, state) { - return ListView.builder( - itemCount: state.databaseResponse.length, - itemBuilder: (context, index) { - final demanda = state.databaseResponse[index]; - return DemandCard( - nomeDemanda: - demanda['nomeDemanda'] ?? 'Nome não disponível', - status: demanda['status'] ?? 'Status não disponível', - codigo: demanda['codigo'] ?? 'Sem código', - descricao: demanda['descricao'] ?? 'Sem descricao', - id: demanda['id'], - imagemUrl: demanda['imagemUrl'] ?? '', - order: index, - bloc: context.read(), - ); - }, - ); - }, - )), - SizedBox(height: 16), // Espaço entre a lista e o botão + Expanded( + child: BlocBuilder( + builder: (context, state) { + return ListView.builder( + itemCount: state.databaseResponse.length, + itemBuilder: (context, index) { + final demanda = state.databaseResponse[index]; + return DemandCard( + nomeDemanda: + demanda['nome_demanda'] ?? 'Nome não disponível', + status: demanda['status'] ?? 'Status não disponível', + codigo: demanda['codigo'] ?? 'Sem código', + descricao: demanda['descricao'] ?? 'Sem descricao', + id: demanda['id'], + imagemUrl: demanda['imagem_url'] ?? '', + order: index, + bloc: context.read(), // BACKEND + ); + }, + ); + }, + ), + ), + SizedBox(height: 10), // Espaço entre a lista e o botão ButtonAddDemanda( - bloc: context.read(), + bloc: context.read(), // BACKEND ), ], ), @@ -435,11 +227,12 @@ class ListDemandaState extends State { } } +//ignore: must_be_immutable class ButtonAddDemanda extends StatelessWidget { - final DemandaBloc bloc; + final DemandaBloc bloc; // BACKEND ButtonAddDemanda({ super.key, - required this.bloc, + required this.bloc, // BACKEND }); final TextEditingController _nomeController = TextEditingController(); @@ -471,7 +264,7 @@ class ButtonAddDemanda extends StatelessWidget { height: 47, child: ElevatedButton( onPressed: () { - AddInfoDemand(context); + addInfoDemand(context); }, style: ElevatedButton.styleFrom( backgroundColor: Color(0xFF015C98), @@ -487,1158 +280,99 @@ class ButtonAddDemanda extends StatelessWidget { ); } - Future AddInfoDemand(BuildContext context) => showGeneralDialog( + Future addInfoDemand(BuildContext context) => showDialog( context: context, - pageBuilder: (context, animation1, animation2) { - return Container(); - }, - transitionBuilder: (context, a1, a2, widget) { - return ScaleTransition( - scale: Tween(begin: 0.5, end: 1.0).animate(a1), - child: AlertDialog( - backgroundColor: Color(0xFFD1EEFF), - content: SizedBox( - height: 446, - width: 534, - child: Padding( - padding: const EdgeInsets.only(top: 41), - child: Column( - children: [ - // campo dos formulários - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Expanded( - child: Align( - alignment: Alignment.center, - child: Text( - "Nova demanda", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.close, - size: 25, - ), - ) - ], - ), - SizedBox( - height: 47, - ), - - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(right: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Código", - style: TextStyle( - fontSize: 15, color: Colors.black), - ), - TextField( - controller: _codigoController, - decoration: InputDecoration( - hintText: "Código da demanda", - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - ) - ], - ), - ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Nome", - style: TextStyle( - fontSize: 15, color: Colors.black), - ), - TextField( - controller: _nomeController, - decoration: InputDecoration( - hintText: "Nome da demanda", - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - ) - ], - ), - ), - ), - ], - ), - SizedBox( - height: 47, - ), - // campo de descricao - Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Text( - "Descrição", - style: - TextStyle(fontSize: 15, color: Colors.black), - ), - ), - ], - ), - TextField( - controller: _descricaoController, - maxLines: 3, - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - ), - SizedBox(height: 5), - // Botão para selecionar foto - Row( - children: [ - Expanded( - child: ElevatedButton( - onPressed: () { - _selecionarFoto(context); - }, - child: Text("Selecionar Foto"), - ), - ), - ], - ), - SizedBox( - height: 10, - ), - ElevatedButton( - onPressed: () async { - if (_nomeController.text.isNotEmpty && - _codigoController.text.isNotEmpty) { - bloc.add(DemandaCreate( - nomeDemanda: _nomeController.text, - codigo: _codigoController.text, - descricao: _descricaoController.text, - foto: fotoSelecionada, - )); - - Navigator.pop(context); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "Por favor, preencha todos os campos")), - ); - } - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF015C98), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(22))), - child: Text( - "Cadastrar demanda", - style: TextStyle(color: Colors.white), - ), - ), - ], - ), - ), - ), - ), - ); - }, - ); -} - -class ButtonConcluir extends StatelessWidget { - const ButtonConcluir({super.key}); - - @override - Widget build(BuildContext context) { - return Expanded( - child: SizedBox( - width: 169, - height: 33, - child: ElevatedButton( - onPressed: () { - //Lógica do botão - showDialogConfirm(context); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF50B432), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(27))), - child: Text( - "Concluir", - style: TextStyle( - color: Colors.white, - fontSize: 15, - ), - )), - ), - ); - } -} - -void showDialogConfirm(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text( - "Deseja confirmar a operação?", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - content: Text( - "Essa operação não poderá ser revertida", - style: TextStyle( - fontSize: 20, - color: Colors.black, - ), - ), - actions: [ - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: 137, - height: 57, - child: ElevatedButton( - onPressed: () { - //Lógica do botão - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF50B432), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(22))), - child: Text( - "Sim", - style: TextStyle( - fontSize: 20, - color: Colors.white, - ), - )), - ), - SizedBox( - width: 40, - ), - SizedBox( - width: 137, - height: 57, - child: TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - style: TextButton.styleFrom( - backgroundColor: Color(0xFFD54A3D), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(22))), - child: Text( - "Não", - style: TextStyle( - fontSize: 20, - color: Colors.white, - ), - )), - ) - ], - )), - ], - ); - }); -} - -//Botão de escolha prioridade -class ButtonChoosePriority extends StatefulWidget { - const ButtonChoosePriority({super.key}); - - @override - State createState() { - return ButtonChoosePriorityState(); - } -} - -class ButtonChoosePriorityState extends State { - String? selectedOption; - - @override - Widget build(BuildContext context) { - return Container( - width: 146, - height: 25, - padding: EdgeInsets.symmetric(horizontal: 10), - decoration: BoxDecoration( - border: Border.all(color: Colors.grey, width: 2), - borderRadius: BorderRadius.circular(9), - color: Colors.white, - ), - child: DropdownButton( - isExpanded: true, - hint: Text( - "Escolha uma opção", - style: TextStyle(fontSize: 15, color: Colors.black.withOpacity(0.5)), - ), - underline: SizedBox(), - value: selectedOption, - onChanged: (String? newValue) { - setState(() { - selectedOption = newValue; - }); - }, - items: ["Alta", "Média", "Baixa"].map((String option) { - return DropdownMenuItem( - value: option, - child: Text(option), - ); - }).toList(), - ), - ); - } -} - -//input do nome e do id -Widget inputNameID() { - return SizedBox( - width: 143, - height: 24, - //input do código - child: TextField( - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - textAlignVertical: TextAlignVertical.center, - maxLines: 1, - decoration: InputDecoration( - contentPadding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 10.0), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2))), - ), - ); -} - -//input das datas -Widget inputDate() { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - width: 95, - height: 25, - //input da data - child: TextField( - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - textAlignVertical: TextAlignVertical.center, - maxLines: 1, - decoration: InputDecoration( - hintText: 'dd/mm/yy', - hintStyle: - TextStyle(fontSize: 15, color: Colors.black.withOpacity(0.5)), - contentPadding: - EdgeInsets.symmetric(vertical: 2.0, horizontal: 10.0), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.grey, width: 2))), - ), - ), - SizedBox( - width: 10, - ), - Icon( - Icons.calendar_month, - color: Colors.black26, - ) - ], - ); -} - -class Search extends StatefulWidget { - const Search({super.key}); - - @override - State createState() { - return SearchState(); - } -} - -class SearchState extends State { - final TextEditingController _nomeDemanda = TextEditingController(); - @override - Widget build(BuildContext context) { - return SizedBox( - width: 499, - height: 32, - child: TextField( - controller: _nomeDemanda, - decoration: InputDecoration( - prefixIcon: Icon( - Icons.search, - color: Color(0xFF015C98), - ), - //Icon de pesquisa - - hintText: "Insira o nome de uma demanda para iniciar uma busca", - hintStyle: TextStyle( - fontSize: 11, - color: Colors.black.withOpacity(0.5) //Opacidade do texto - ), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(16), - borderSide: BorderSide(color: Colors.white, width: 2), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white, width: 2), - borderRadius: BorderRadius.circular(16), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white, width: 2), - borderRadius: BorderRadius.circular(16), - )), - onEditingComplete: () { - context.read().add(DemandaFilter( - 'nomeDemanda', - _nomeDemanda.text, - )); - }, - ), - ); - } -} - -class QuadroPrioridade extends StatefulWidget { - const QuadroPrioridade({super.key}); - - @override - State createState() { - return QuadroPrioridadeState(); - } -} - -class QuadroPrioridadeState extends State { - Color colorQ = Color(0xFFC3206F); - - //Troca a cor do quadro - void prioridadeAlta() { - setState(() { - colorQ = Color(0xFFC3206F); - }); - } - - //Troca a cor do quadro - void prioridadeMedia() { - setState(() { - colorQ = Color(0xFFFF66B0); - }); - } - - //Troca a cor do quadro - void prioridadeBaixa() { - setState(() { - colorQ = Color(0xFFFFC6E1); - }); - } - - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - //Quadro de prioridade - Container( - width: 340, - height: 398, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), color: colorQ), - ), - - SizedBox( - height: 15, - ), - - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - //Botão alta prioridade - SizedBox( - width: 97, - height: 24, - child: ElevatedButton( - onPressed: prioridadeAlta, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFC3206F), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - )), - child: Text( - 'Alta', - style: TextStyle( - color: Colors.black, - ), - ), - ), - ), - - SizedBox( - width: 17, - ), - - //Botão média prioridade - SizedBox( - width: 97, - height: 24, - child: ElevatedButton( - onPressed: prioridadeMedia, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFFF66B0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - )), - child: Text( - 'Média', - style: TextStyle( - color: Colors.black, - ), - ), - ), - ), - - SizedBox( - width: 17, - ), - - //Botão baixa prioridade - SizedBox( - width: 97, - height: 24, - child: ElevatedButton( - onPressed: prioridadeBaixa, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFFFC6E1), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - )), - child: Text( - 'Baixa', - style: TextStyle( - color: Colors.black, - ), - ), - ), - ), - ], - ) - ], - ); - } -} - -// Dialog -void _showCustomDialog( - BuildContext context, - String name, - String code, - DateTime createdAt, - DateTime updatedAt, - String description, - String imageCake) { - String createdAtFormat = DateFormat('dd/MM/yyyy').format(createdAt); - String updatedAtFormat = DateFormat('dd/MM/yyyy').format(updatedAt); - - showGeneralDialog( - context: context, - pageBuilder: (context, animation1, animation2) { - return Container(); - }, - transitionBuilder: (context, a1, a2, widget) { - return ScaleTransition( - scale: Tween(begin: 0.5, end: 1.0).animate(a1), - child: AlertDialog( - backgroundColor: Color(0xFFD1EEFF), - content: SizedBox( - width: 560, - child: Padding( - padding: const EdgeInsets.only(top: 41), - child: Container( - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Expanded( - child: Align( - //Aqui ficará o nome da demanda ou qual demanda será - alignment: Alignment.center, - child: Text("Nome da demanda ${name}", - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - )), - )), - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.close, - size: 25, - )) - ], - ), - SizedBox(height: 31), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 186, - height: 202, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - image: DecorationImage( - image: AssetImage(imageCake))), - ), - SizedBox(width: 30), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - RichText( - text: TextSpan( - text: "Código: ", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - children: [TextSpan(text: "${code}")])), - SizedBox(height: 10), - RichText( - text: TextSpan( - text: "Data do pedido: ", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - children: [ - TextSpan(text: "${createdAtFormat}") - ])), - SizedBox(height: 10), - RichText( - text: TextSpan( - text: "Prazo: ", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - children: [ - TextSpan(text: "${updatedAtFormat}") - ])), - SizedBox(height: 10), - RichText( - text: TextSpan( - text: "Descrição: ", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15), - children: [ - TextSpan(text: "${description}") - ])), - ], - ) - ], - ), - SizedBox( - height: 40, - ), - Text( - "Acompanhamento da produção", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), - ), - SizedBox( - height: 10, - ), - Text( - "Status: Em andamento", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 16), - ), - SizedBox( - height: 20, - ), - StageDemand(status: "finished"), - SizedBox( - height: 20, - ), - StageDemand(status: "InProgress"), - SizedBox( - height: 20, - ), - StageDemand(status: "Erro"), - ], - ), - ), - )), - shape: OutlineInputBorder( - borderRadius: BorderRadius.circular(16.0), - borderSide: BorderSide.none), - ), - ); - }, - ); -} - -class DemandCard extends StatelessWidget { - final String nomeDemanda; - final String status; - final String codigo; - final String descricao; - final int id; - final String imagemUrl; - final int order; - final DemandaBloc bloc; - - const DemandCard({ - super.key, - required this.nomeDemanda, - required this.codigo, - required this.status, - required this.descricao, - required this.id, - required this.order, - required this.imagemUrl, - required this.bloc, // Função de atualização - }); - - @override - Widget build(BuildContext context) { - final TextEditingController _nomeController = - TextEditingController(text: nomeDemanda); - final TextEditingController _codigoController = - TextEditingController(text: codigo); - final TextEditingController _descricaoController = - TextEditingController(text: descricao); - - return Card( - margin: EdgeInsets.symmetric(vertical: 8.0), - child: ListTile( - title: Text(nomeDemanda), - subtitle: Text( - 'Código: ${codigo.isNotEmpty ? codigo : 'Sem código'}\nStatus: $status'), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - imagemUrl.isNotEmpty - ? Image.network(imagemUrl, width: 50, height: 50) - : Icon(Icons.image, size: 50), - IconButton( - icon: Icon(Icons.info), - onPressed: () { - _showInfoDialog( - context, nomeDemanda, codigo, descricao, status); - }, - ), - // botão de Editar. - IconButton( - icon: Icon(Icons.edit), - onPressed: () { - // editar a demanda - _showEditDialog(context, _nomeController, _codigoController, - _descricaoController, bloc); - }, - ), - // apagar - IconButton( - icon: Icon(Icons.delete), - onPressed: () async { - showDialog( - context: context, - builder: (BuildContext context) { - return ConfirmDialog( - title: 'Confirmar Exclusão', - contente: - 'Tem certeza de que deseja apagar esta demanda?', - onConfirm: () { - Navigator.of(context).pop(); // Fecha o diálogo - bloc.add( - DemandaDelete(id, order)); // Executa a exclusão - }, - ); - }, - ); - }), - ], - ), - ), - ); - } - - // Função para mostrar as informações da demanda em um diálogo - void _showInfoDialog(BuildContext context, String nome, String codigo, - String descricao, String status) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text("Informações da Demanda"), - content: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Nome: $nome", - style: TextStyle(fontWeight: FontWeight.bold)), - SizedBox(height: 10), - Text("Código: $codigo", - style: TextStyle(fontWeight: FontWeight.bold)), - SizedBox(height: 10), - Text("Status: $status", - style: TextStyle(fontWeight: FontWeight.bold)), - SizedBox(height: 10), - Text("Descrição: $descricao", - style: TextStyle(fontWeight: FontWeight.bold)), - ], - ), - ), - actions: [ - ElevatedButton( - onPressed: () { - Navigator.pop(context); // Fechar o diálogo - }, - child: Text("Fechar"), - ), - ], - ); - }, - ); - } - - // Função que exibe o diálogo de edição - void _showEditDialog( - BuildContext context, - TextEditingController nomeController, - TextEditingController codigoController, - TextEditingController descricaoController, - DemandaBloc bloc) { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text("Editar Demanda"), - content: SingleChildScrollView( - child: Column( - children: [ - TextField( - controller: nomeController, - decoration: InputDecoration(labelText: "Nome da Demanda"), - ), - TextField( - controller: codigoController, - decoration: InputDecoration(labelText: "Código da Demanda"), - ), - TextField( - controller: descricaoController, - decoration: - InputDecoration(labelText: "Descrição da Demanda"), - maxLines: null, // Permite múltiplas linhas - minLines: 4, - ), - ], - ), - ), - actions: [ - ElevatedButton( - onPressed: () { - // Atualizar a demanda no Supabase - bloc.add(DemandaUpdate( - id, - order, - nomeController.text, - codigoController.text, - descricaoController.text, - )); - //_updateDemanda(nomeController.text, codigoController.text,descricaoController.text); - Navigator.pop(context); // Fechar o diálogo - }, - child: Text("Salvar"), - ), - ElevatedButton( - onPressed: () { - Navigator.pop(context); // Fechar o diálogo sem salvar - }, - child: Text("Cancelar"), - ), - ], - ); - }, - ); - } -} - -Widget _buildActionButton({ - required IconData icon, - required String label, - required VoidCallback onPressed, -}) { - return Row( - children: [ - IconButton( - icon: Icon(icon), - iconSize: 18, - onPressed: onPressed, - ), - SizedBox(width: 5), - Text( - label, - style: TextStyle( - fontSize: 12, - ), - ), - ], - ); -} - -// EDITAR DEMANDA -// O parâmetro 'context' informa onde o widget será inserido na árvore de widgets. -void editarDemanda(BuildContext context) { - showGeneralDialog( - context: - context, // Indica onde o diálogo será exibido na árvore de widgets. - pageBuilder: (context, animation1, animation2) { - return Container(); - }, - transitionBuilder: (context, a1, a2, widget) { - return ScaleTransition( - scale: Tween(begin: 0.5, end: 1.0).animate(a1), - child: AlertDialog( - backgroundColor: Color(0xFFD1EEFF), - content: SizedBox( - height: 446, - width: 534, - child: Padding( - padding: const EdgeInsets.only(top: 41), + builder: (BuildContext context) { + return ReusableDialog( + title: "Nova demanda", + confirmBeforeClose: true, + body: SingleChildScrollView( child: Column( + mainAxisSize: MainAxisSize.min, children: [ - // Título do diálogo Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( - child: Align( - alignment: Alignment.center, - child: Text( - "Editar demanda", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), + child: InputTextField( + labelText: "Código", + hintText: "Código da demanda", + controller: _codigoController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], ), ), - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.close, - size: 25, + Expanded( + child: InputTextField( + labelText: "Nome", + hintText: "Nome da demanda", + controller: _nomeController, ), ), ], ), - - SizedBox(height: 30), - - // Campos de código - Row( - mainAxisAlignment: MainAxisAlignment.center, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Align( - alignment: Alignment.centerLeft, - child: Text( - "Código", - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - ), - ), - SizedBox(width: 10), - inputNameID(), - SizedBox(width: 50), - ], - ), - - SizedBox(height: 14), - - // Campos de data do pedido e prazo - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Align( - alignment: Alignment.centerLeft, - child: Text( - "Data do pedido", - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - ), - ), - SizedBox(width: 10), - inputDate(), - SizedBox(width: 54), - Align( - alignment: Alignment.centerLeft, - child: Text( - "Prazo", - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - ), + InputTextField( + labelText: "Descrição", + hintText: "Digite a descrição", + controller: _descricaoController, + maxLines: 3, ), - SizedBox(width: 10), - inputDate(), ], ), - - SizedBox(height: 24), - - // Descrição + const SizedBox(height: 20), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.only(bottom: 70), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Descrição", - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - ), - ), - ), - SizedBox(width: 10), - SizedBox( - width: 339, - height: 92, - child: TextField( - style: TextStyle( - fontSize: 15, - color: Colors.black, - ), - maxLines: null, - minLines: 6, - decoration: InputDecoration( - hintStyle: TextStyle(fontSize: 15), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: - BorderSide(color: Colors.grey, width: 2), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: - BorderSide(color: Colors.grey, width: 2), - ), - ), + Expanded( + child: ElevatedButton( + onPressed: () { + _selecionarFoto(context); + }, + child: const Text("Selecionar Foto"), ), ), ], ), - - SizedBox(height: 23), - - // Prioridade - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Align( - alignment: Alignment.centerLeft, - child: Text( - "Prioridade", - style: TextStyle( - fontSize: 15, - color: Colors.black, + const SizedBox(height: 10), + ElevatedButton( + onPressed: () async { + if (_nomeController.text.isNotEmpty && + _codigoController.text.isNotEmpty) { + bloc.add(DemandaCreate( + nomeDemanda: _nomeController.text, + codigo: _codigoController.text, + descricao: _descricaoController.text, + foto: fotoSelecionada, + )); + Navigator.pop(context); + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: + Text("Por favor, preencha todos os campos"), ), - ), + ); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF015C98), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(22), ), - SizedBox(width: 10), - ButtonChoosePriority(), - ], + ), + child: const Text( + "Cadastrar demanda", + style: TextStyle(color: Colors.white), + ), ), - - SizedBox(height: 47), - - // Botão de Concluir - ButtonConcluir(), ], ), ), - ), - shape: OutlineInputBorder( - borderRadius: BorderRadius.circular(16.0), - borderSide: BorderSide.none, - ), - ), + ); + }, ); - }, - ); } diff --git a/catavento/lib/screens/employee-management.dart b/catavento/lib/screens/employee-management.dart index 0602fdf..91e6d7d 100644 --- a/catavento/lib/screens/employee-management.dart +++ b/catavento/lib/screens/employee-management.dart @@ -1,18 +1,10 @@ -import 'dart:ffi'; -import 'package:catavento/bloc/usuario_bloc.dart'; -import 'package:catavento/screens/components/ativAndamentoCard.dart'; -import 'package:catavento/screens/components/confirmDialog.dart'; -import 'package:catavento/screens/components/graficInfo.dart'; -import 'package:catavento/screens/components/input.dart'; -import 'package:catavento/screens/dashboard_admin.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'components/background.dart'; -import 'components/header.dart'; -import 'components/blocks.dart'; -import 'components/showDialog.dart'; -import 'package:catavento/screens/components/menu.dart'; -import 'components/funcionarioCard.dart'; + +import 'DashboardAdmin/components/background.dart'; +import 'DashboardAdmin/components/blocks.dart'; +import 'DashboardAdmin/components/header.dart'; +import 'DashboardAdmin/components/input.dart'; +import 'DashboardAdmin/components/showDialog.dart'; class EmployeeManagement extends StatelessWidget { final List> funcionarios = [ @@ -41,12 +33,11 @@ class EmployeeManagement extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Blocks( - color: Colors.white, - height: 97, - width: 321, - borderRadius: 26, - children: [ - Row( + color: Colors.white, + height: 97, + width: 321, + borderRadius: 26, + child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -63,9 +54,7 @@ class EmployeeManagement extends StatelessWidget { children: [], ) ], - ) - ], - ), + )), SizedBox(height: MediaQuery.of(context).size.height * 0.02), /*Blocks( @@ -267,7 +256,7 @@ class EmployeeManagement extends StatelessWidget { ], ) - ) + )*/ ], ), ],