diff --git a/README.md b/README.md index 198dead..be72edd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ ## Etapa de desenvolvimento -### Semana 2 - 11/11/2021 - 18/11/20213 +### Semana 3 e 4 - 18/11/2021 - 02/12/2021 + +- [ ] R2 - Tela de pedidos + - [x] T5 - Resgatando dados do firestore do R2/T4 - Lindomar Rodrigues +- [ ] R4 - Firebase + - [x] Documentos cadastrados(estáticos) - Marcos Gilmário + + +### Semana 2 - 11/11/2021 - 18/11/2021 - [ ] R0 - Tela de início - [x] T6 - state, model e action do R0/T1 - Pablo henrique diff --git a/lib/actions/banner_de_categoria_action.dart b/lib/actions/banner_de_categoria_action.dart index 7adc449..bf185ba 100644 --- a/lib/actions/banner_de_categoria_action.dart +++ b/lib/actions/banner_de_categoria_action.dart @@ -1,16 +1,21 @@ import 'package:ifood_engenharia_de_software/models/banner_de_categoria_model.dart'; class AlterarBannerDeCategoria { + final List listacategoria; - AlterarBannerDeCategoria(this.listacategoria); + AlterarBannerDeCategoria( this.listacategoria); - BannerDeCategoriaModel bannerdecategoriaData = const BannerDeCategoriaModel([ - CategoriaBanner('Express'), - CategoriaBanner('Mercado'), - CategoriaBanner('Farmácia'), - CategoriaBanner('Bebidas'), - CategoriaBanner('Pizza'), - CategoriaBanner('Lanches') - ]); + BannerDeCategoriaModel bannerdecategoriaData = const BannerDeCategoriaModel( + [ CategoriaBanner('Salgados','https://cdn.discordapp.com/attachments/814528592419094570/912145821808599060/salgados1.jpg'), + CategoriaBanner('Lanches','https://cdn.discordapp.com/attachments/814528592419094570/912145821292716062/lanches1.jpg'), + CategoriaBanner('Carnes','https://cdn.discordapp.com/attachments/814528592419094570/912145821049438238/carnes1.jpg'), + CategoriaBanner('Pizza','https://cdn.discordapp.com/attachments/814528592419094570/912145821565341736/pizza1.jpg'), + CategoriaBanner('Japonesa','https://cdn.discordapp.com/attachments/814528592419094570/912154611559858266/19C1-japonesa.png'), + CategoriaBanner('Açaí','https://cdn.discordapp.com/attachments/814528592419094570/912154798323793930/19C1-acai.png'), + CategoriaBanner('Bebidas','https://cdn.discordapp.com/attachments/814528592419094570/912191740105089054/19C1-bebidas.png'), + CategoriaBanner('Saudável','https://cdn.discordapp.com/attachments/814528592419094570/912191814440742992/19C1-saudavel-v2.png'), + CategoriaBanner('Brasileira','https://cdn.discordapp.com/attachments/814528592419094570/912191878458380308/19C1-brasileira-v2.png'), + CategoriaBanner('Cozinha Rápida','https://cdn.discordapp.com/attachments/814528592419094570/912191949136605184/19C1-comida-rapida.png') + ]); } diff --git a/lib/actions/card_mais_pedidos_por_vc_action.dart b/lib/actions/card_mais_pedidos_por_vc_action.dart new file mode 100644 index 0000000..6048e6b --- /dev/null +++ b/lib/actions/card_mais_pedidos_por_vc_action.dart @@ -0,0 +1,20 @@ +import 'package:ifood_engenharia_de_software/models/mais_pedidos_por_vc_model.dart'; + +class AlterarMaisPedidos { + final List maispedidoslist; + + AlterarMaisPedidos(this.maispedidoslist); + + MaisPedidosModel maispedidosData = const MaisPedidosModel([ + MaisPedidos('Bar do Diluc', 'Fechado', + 'https://cdn.discordapp.com/attachments/809775517493624852/910734117115674624/b3225dcdeebef9074c9c082afde8d495_2527226506439238336.png'), + MaisPedidos('Noelle´s Pancakes', '', + 'https://cdn.discordapp.com/attachments/809775517493624852/910732173445832754/4ea27fde21b997bc3fb141786fc1719c_6363129461192613770.png'), + MaisPedidos('Escudo Inquebrável', 'Fechado', + 'https://cdn.discordapp.com/attachments/809775517493624852/910740130833244160/show.png'), + MaisPedidos('Presente dos Reis', 'Fechado', + 'https://media.discordapp.net/attachments/809775517493624852/910736507881553931/b891ddaf349a66bf1cdcccabec3c9a5b.png'), + MaisPedidos('Vikings', '', + 'https://cdn.discordapp.com/attachments/809775517493624852/910736208626323497/22132_800x800.png') + ]); +} diff --git a/lib/actions/peca_novamente_action.dart b/lib/actions/peca_novamente_action.dart index 09c5012..25c1711 100644 --- a/lib/actions/peca_novamente_action.dart +++ b/lib/actions/peca_novamente_action.dart @@ -1,12 +1,27 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:ifood_engenharia_de_software/models/peca_novamente_model.dart'; -class AlterarPecaNovamente { - final String urlLogoRestaurante; - final List pedidos; +import '../app_store.dart'; - AlterarPecaNovamente(this.urlLogoRestaurante, this.pedidos); +class AtualizarPecaNovamente { + FirebaseFirestore firestore = FirebaseFirestore.instance; + final PecaNovamenteModel pecaNovamenteData; - PecaNovamenteModel pecaNovamenteData = const PecaNovamenteModel( - 'https://aguardando.fase.de.utilizar.o.storage/', - [Produto('Pizza G Calabresa C/Borda Mista', 1)]); + AtualizarPecaNovamente({this.pecaNovamenteData = const PecaNovamenteModel()}); + + void atualizar() { + firestore + .collection('pecadenovo') + .doc('zVxxTLxTaNDSsy4LWmfH') + .get() + .then((DocumentSnapshot documento) { + String urlLogoRestaurante = documento['logo_estabelecimento_img_url']; + Produto produto = Produto(documento['produto'], documento['quantidade']); + PecaNovamenteModel pecaNovamenteData = PecaNovamenteModel( + urlLogoRestaurante: urlLogoRestaurante, pedidos: [produto]); + + appStore.dispatcher( + AtualizarPecaNovamente(pecaNovamenteData: pecaNovamenteData)); + }); + } } diff --git a/lib/actions/ultimas_lojas_action.dart b/lib/actions/ultimas_lojas_action.dart new file mode 100644 index 0000000..2adebe0 --- /dev/null +++ b/lib/actions/ultimas_lojas_action.dart @@ -0,0 +1,16 @@ +import 'package:ifood_engenharia_de_software/models/ultimas_lojas_model.dart'; + +class AlterarUltimasLojas { + final List listadaslojas; + + AlterarUltimasLojas(this.listadaslojas); + + UltimasLojasModel ultimaslojasData = const UltimasLojasModel( + [ + Lojas("McDonald's",'https://i.imgur.com/L8VcJbD.png'), + Lojas('Burger King','https://i.imgur.com/BhBX8HH.png'), + Lojas('Giraffas','https://i.imgur.com/0I9W33L.png'), + Lojas('Subway','https://i.imgur.com/rYyDTK6.png'), + ] + ); +} diff --git a/lib/app_reducer.dart b/lib/app_reducer.dart index e13bf49..4411eee 100644 --- a/lib/app_reducer.dart +++ b/lib/app_reducer.dart @@ -1,16 +1,28 @@ import 'actions/banner_de_categoria_action.dart'; import 'actions/card_da_categoria_componente_action.dart'; +import 'actions/card_mais_pedidos_por_vc_action.dart'; import 'actions/navegacao_rodape_action.dart'; import 'actions/peca_novamente_action.dart'; +import 'actions/card_da_categoria_componente_action.dart'; import 'app_state.dart'; +import 'actions/banner_de_categoria_action.dart'; +import 'actions/ultimas_lojas_action.dart'; AppState reducer(AppState state, dynamic action) { if (action is AlterarPagina) { - return AppState(paginaAtual: action.pagina); - } else if (action is AlterarPecaNovamente) { + if (action.pagina == 2) { + AtualizarPecaNovamente().atualizar(); + } + return AppState( + paginaAtual: action.pagina, pecaNovamenteData: state.pecaNovamenteData); + } else if (action is AtualizarPecaNovamente) { return AppState( paginaAtual: state.paginaAtual, pecaNovamenteData: action.pecaNovamenteData); + } else if (action is AlterarMaisPedidos) { + return AppState( + paginaAtual: state.paginaAtual, + maispedidosData: action.maispedidosData); } else if (action is AlterarBannerDeCategoria) { return AppState( paginaAtual: state.paginaAtual, @@ -18,8 +30,13 @@ AppState reducer(AppState state, dynamic action) { } else if (action is AlterarCard) { return AppState( paginaAtual: state.paginaAtual, - cardcategoriaData: action.cardcategoriaData); - } else { + cardcategoriaData:action.cardcategoriaData); + }else if (action is AlterarUltimasLojas) { + return AppState( + paginaAtual: state.paginaAtual, + ultimaslojasData:action.ultimaslojasData); + }else { + return AppState(); } } diff --git a/lib/app_state.dart b/lib/app_state.dart index 0875544..b45fa9b 100644 --- a/lib/app_state.dart +++ b/lib/app_state.dart @@ -1,29 +1,46 @@ import 'package:flutter/material.dart'; import 'package:ifood_engenharia_de_software/utilities/cores.dart'; +import 'models/ultimas_lojas_model.dart'; + import 'models/banner_de_categoria_model.dart'; import 'models/card_da_categoria_componente_model.dart'; +import 'models/mais_pedidos_por_vc_model.dart'; import 'models/peca_novamente_model.dart'; class AppState { final int paginaAtual; final PecaNovamenteModel pecaNovamenteData; final CategoriaModel cardcategoriaData; - + final MaisPedidosModel maispedidosData; + final UltimasLojasModel ultimaslojasData; final BannerDeCategoriaModel bannerdecategoriaData; AppState( {this.paginaAtual = 0, - this.pecaNovamenteData = const PecaNovamenteModel( - 'https://aguardando.fase.de.utilizar.o.storage/', - [Produto('Pizza G Calabresa C/Borda Mista', 1)]), + + this.pecaNovamenteData = const PecaNovamenteModel(), this.bannerdecategoriaData = const BannerDeCategoriaModel([ - CategoriaBanner('express'), - CategoriaBanner('Mercado'), - CategoriaBanner('Farmácia'), - CategoriaBanner('Bebidas'), - CategoriaBanner('Pizza'), - CategoriaBanner('Lanches') + CategoriaBanner('Salgados', + 'https://cdn.discordapp.com/attachments/814528592419094570/912145821808599060/salgados1.jpg'), + CategoriaBanner('Lanches', + 'https://cdn.discordapp.com/attachments/814528592419094570/912145821292716062/lanches1.jpg'), + CategoriaBanner('Carnes', + 'https://cdn.discordapp.com/attachments/814528592419094570/912145821049438238/carnes1.jpg'), + CategoriaBanner('Pizza', + 'https://cdn.discordapp.com/attachments/814528592419094570/912145821565341736/pizza1.jpg'), + CategoriaBanner('Japonesa', + 'https://cdn.discordapp.com/attachments/814528592419094570/912154611559858266/19C1-japonesa.png'), + CategoriaBanner('Açaí', + 'https://cdn.discordapp.com/attachments/814528592419094570/912154798323793930/19C1-acai.png'), + CategoriaBanner('Bebidas', + 'https://cdn.discordapp.com/attachments/814528592419094570/912191740105089054/19C1-bebidas.png'), + CategoriaBanner('Saudável', + 'https://cdn.discordapp.com/attachments/814528592419094570/912191814440742992/19C1-saudavel-v2.png'), + CategoriaBanner('Brasileira', + 'https://cdn.discordapp.com/attachments/814528592419094570/912191878458380308/19C1-brasileira-v2.png'), + CategoriaBanner('Cozinha Rápida', + 'https://cdn.discordapp.com/attachments/814528592419094570/912191949136605184/19C1-comida-rapida.png'), ]), this.cardcategoriaData = const CategoriaModel([ Categoria('Pizza', AppCores.vermelhoPrincipal, @@ -38,5 +55,26 @@ class AppState { 'https://cdn.discordapp.com/attachments/809775517493624852/910621467291570186/japones.jpg'), Categoria('Doces', Color(0xffF8879B), 'https://cdn.discordapp.com/attachments/868118606448324638/910683119441547284/saudavel.jpg') - ])}); + ]), + this.maispedidosData = const MaisPedidosModel([ + MaisPedidos('Bar do Diluc', 'Fechado', + 'https://cdn.discordapp.com/attachments/809775517493624852/910734117115674624/b3225dcdeebef9074c9c082afde8d495_2527226506439238336.png'), + MaisPedidos('Noelle´s Pancakes', '', + 'https://cdn.discordapp.com/attachments/809775517493624852/910732173445832754/4ea27fde21b997bc3fb141786fc1719c_6363129461192613770.png'), + MaisPedidos('Escudo Inquebrável', 'Fechado', + 'https://cdn.discordapp.com/attachments/809775517493624852/910740130833244160/show.png'), + MaisPedidos('Presente dos Reis', 'Fechado', + 'https://media.discordapp.net/attachments/809775517493624852/910736507881553931/b891ddaf349a66bf1cdcccabec3c9a5b.png'), + MaisPedidos('Vikings', '', + 'https://cdn.discordapp.com/attachments/809775517493624852/910736208626323497/22132_800x800.png') + ]), + this.ultimaslojasData = const UltimasLojasModel( + [ + Lojas("McDonald's",'https://i.imgur.com/L8VcJbD.png'), + Lojas('Burger King','https://i.imgur.com/BhBX8HH.png'), + Lojas('Giraffas','https://i.imgur.com/0I9W33L.png'), + Lojas('Subway','https://i.imgur.com/rYyDTK6.png'), + ]), + + }); } diff --git a/lib/components/busca/banner_de_categoria_componente.dart b/lib/components/busca/banner_de_categoria_componente.dart index d297636..5b4c57e 100644 --- a/lib/components/busca/banner_de_categoria_componente.dart +++ b/lib/components/busca/banner_de_categoria_componente.dart @@ -1,39 +1,74 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ifood_engenharia_de_software/models/banner_de_categoria_model.dart'; -import 'package:ifood_engenharia_de_software/utilities/cores.dart'; class BannersDeCategorias extends StatelessWidget { final List listacategoria; - + const BannersDeCategorias({Key? key, required this.listacategoria}) : super(key: key); @override Widget build(BuildContext context) { - final ButtonStyle style = ElevatedButton.styleFrom( - textStyle: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold), - fixedSize: const Size(175, 70), - primary: AppCores.vermelhoPrincipal); return GridView.builder( + scrollDirection: Axis.vertical, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: (4 / 2), - crossAxisSpacing: 20, - mainAxisSpacing: 20), + crossAxisSpacing: 10, + mainAxisSpacing: 10), shrinkWrap: true, itemCount: listacategoria.length, itemBuilder: (BuildContext context, index) { - return ElevatedButton( - style: style, - onPressed: () {}, - child: Column(children: [ - const SizedBox(height: 15), - Row(children: [ - Text(listacategoria[index].nome), - ]) - ])); - }); + return Container( + height: 100, + width: 400, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.grey[100], + image: DecorationImage( + fit: BoxFit.fill, + image: NetworkImage(listacategoria[index].imgurl) + ), + ), + + child:Padding( + padding: const EdgeInsets.all(5), + child:Text(listacategoria[index].nome, + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold, color: Colors.white),) + ) + ); + } + ); } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/components/inicio/ultimas_lojas_componente.dart b/lib/components/inicio/ultimas_lojas_componente.dart index 2f801ef..59e1d12 100644 --- a/lib/components/inicio/ultimas_lojas_componente.dart +++ b/lib/components/inicio/ultimas_lojas_componente.dart @@ -1,53 +1,81 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ifood_engenharia_de_software/utilities/cores.dart'; +import 'package:ifood_engenharia_de_software/models/ultimas_lojas_model.dart'; +import 'package:ifood_engenharia_de_software/actions/navegacao_rodape_action.dart'; +import 'package:ifood_engenharia_de_software/app_store.dart'; class UltimasLojasRestaurante extends StatelessWidget { - final List listalojas; + final List listalojas; const UltimasLojasRestaurante({Key? key, required this.listalojas}) : super(key: key); @override Widget build(BuildContext context) { - return Column(children: [ - const Align( - alignment: Alignment.topLeft, - child: Padding( - padding: EdgeInsets.only(left: 15.0), - child: Text( - 'Últimas lojas', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), - ), - )), - Expanded( - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - itemCount: listalojas.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.only(top: 12), - child: Column( - children: [ - const CircleAvatar( - radius: 33, - ), - Padding( - padding: const EdgeInsets.all(4.0), - child: Text( - listalojas[index], - textAlign: TextAlign.left, - style: const TextStyle( - color: AppCores.preto54, - fontSize: 13, - fontWeight: FontWeight.w400), - ), - ) - ], + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Align( + alignment: Alignment.topLeft, + child: Padding( + padding: EdgeInsets.only(left: 15.0), + child: Text( + 'Últimas lojas', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), ), - ); - })) - ]); + )), + Align( + alignment: Alignment.topRight, + child: Padding( + padding: const EdgeInsets.only(right: 15.0), + child: InkWell( + child: const Text( + 'Ver mais', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13, + color: Colors.red), + ), + onTap: () { + appStore.dispatcher(AlterarPagina(2)); + }, + ))), + ], + ), + Padding( + padding: const EdgeInsets.only(top: 12.0), + child: SizedBox( + height: 130, + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: const BouncingScrollPhysics(), + itemCount: listalojas.length, + itemBuilder: (_, index) => SizedBox( + width: MediaQuery.of(context).size.width * 0.25, + child: Column(children: [ + CircleAvatar( + radius: 33, + backgroundImage: + NetworkImage(listalojas[index].logourl), + backgroundColor: Colors.transparent), + Padding( + padding: const EdgeInsets.all(4.0), + child: Text( + listalojas[index].nome, + textAlign: TextAlign.left, + style: const TextStyle( + color: AppCores.preto54, + fontSize: 13, + fontWeight: FontWeight.w400), + ), + ) + ]), + ))), + ), + ], + ); } } diff --git a/lib/components/pedidos/mais_pedidos_por_vc.dart b/lib/components/pedidos/mais_pedidos_por_vc.dart new file mode 100644 index 0000000..21bdd4c --- /dev/null +++ b/lib/components/pedidos/mais_pedidos_por_vc.dart @@ -0,0 +1,74 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:ifood_engenharia_de_software/models/mais_pedidos_por_vc_model.dart'; + +class MaisPedidosPorVcCard extends StatelessWidget { + final List maispedidoslist; + + const MaisPedidosPorVcCard({Key? key, required this.maispedidoslist}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 200, + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: const BouncingScrollPhysics(), + itemCount: maispedidoslist.length, // this for snapping + itemBuilder: (_, index) => SizedBox( + width: MediaQuery.of(context).size.width * 0.38, + child: Column(children: [ + const SizedBox(height: 40), + Container( + height: 140, + width: 130, + padding: const EdgeInsets.all(1), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + const BorderRadius.all(Radius.circular(8)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 7, + offset: const Offset(0, 3), + ), + ], + ), + child: Column( + children: [ + const SizedBox(height: 10), + CircleAvatar( + radius: 36.0, + backgroundImage: + NetworkImage(maispedidoslist[index].fotourl), + backgroundColor: Colors.transparent, + ), + const SizedBox(height: 10), + const Padding( + padding: EdgeInsets.all(0.5), + ), + Text( + maispedidoslist[index].nome, + style: const TextStyle( + color: Colors.black, fontSize: 14), + ), + Padding( + padding: const EdgeInsets.all(1), + child: Text( + maispedidoslist[index].estado, + style: const TextStyle( + color: Colors.grey, + fontSize: 12, + fontWeight: FontWeight.bold), + ), + ) + ], + ), + ), + ]), + ))); + } +} diff --git a/lib/components/pedidos/peca_novamente_card_componente.dart b/lib/components/pedidos/peca_novamente_card_componente.dart index 69a0f26..7b00ea7 100644 --- a/lib/components/pedidos/peca_novamente_card_componente.dart +++ b/lib/components/pedidos/peca_novamente_card_componente.dart @@ -5,9 +5,13 @@ import 'package:ifood_engenharia_de_software/utilities/cores.dart'; class PecaNovamenteCard extends StatelessWidget { final int quantidade; final String produto; + final String logoEstabelecimentoImgUrl; const PecaNovamenteCard( - {Key? key, required this.quantidade, required this.produto}) + {Key? key, + required this.quantidade, + required this.produto, + required this.logoEstabelecimentoImgUrl}) : super(key: key); @override @@ -39,12 +43,13 @@ class PecaNovamenteCard extends StatelessWidget { children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: const [ - Text( + children: [ + const Text( 'Peça de novo', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), - Text('logo') + Image.network(logoEstabelecimentoImgUrl, width: 50,) + ], ), Row( diff --git a/lib/layouts/default.dart b/lib/layouts/default.dart index 7022cd1..3ae1d12 100644 --- a/lib/layouts/default.dart +++ b/lib/layouts/default.dart @@ -7,6 +7,7 @@ import 'package:ifood_engenharia_de_software/pages/busca.dart'; import 'package:ifood_engenharia_de_software/pages/inicio.dart'; import 'package:ifood_engenharia_de_software/pages/pedidos.dart'; import 'package:ifood_engenharia_de_software/pages/perfil.dart'; +import 'package:ifood_engenharia_de_software/pages/register_page.dart'; class LayoutDefault extends StatefulWidget { final User user; @@ -44,6 +45,8 @@ class _LayoutDefaultState extends State return PaginaPerfil( user: _currentUser, ); + } else if (appStore.state.paginaAtual == 4) { + return const RegisterPage(); } else { return const Text('Error!!'); } diff --git a/lib/models/banner_de_categoria_model.dart b/lib/models/banner_de_categoria_model.dart index 9473c6e..33c640e 100644 --- a/lib/models/banner_de_categoria_model.dart +++ b/lib/models/banner_de_categoria_model.dart @@ -1,15 +1,20 @@ class CategoriaBanner { final String nome; - - const CategoriaBanner(this.nome); + final String imgurl; + const CategoriaBanner(this.nome,this.imgurl); } class BannerDeCategoriaModel { + final List listacategoria; - const BannerDeCategoriaModel(this.listacategoria); + const BannerDeCategoriaModel( this.listacategoria); + + fromFirestore() { + + } - fromFirestore() {} + toFirestore() { - toFirestore() {} + } } diff --git a/lib/models/mais_pedidos_por_vc_model.dart b/lib/models/mais_pedidos_por_vc_model.dart new file mode 100644 index 0000000..d665241 --- /dev/null +++ b/lib/models/mais_pedidos_por_vc_model.dart @@ -0,0 +1,21 @@ +class MaisPedidos { + final String nome; + final String estado; + final String fotourl; + + const MaisPedidos(this.nome, this.estado, this.fotourl); +} + +class MaisPedidosModel { + final List maispedidoslist; + + const MaisPedidosModel(this.maispedidoslist); + + fromFirestore() { + // TODO + } + + toFirestore() { + // TODO + } +} diff --git a/lib/models/peca_novamente_model.dart b/lib/models/peca_novamente_model.dart index 8253890..7098ec1 100644 --- a/lib/models/peca_novamente_model.dart +++ b/lib/models/peca_novamente_model.dart @@ -9,13 +9,7 @@ class PecaNovamenteModel { final String urlLogoRestaurante; final List pedidos; - const PecaNovamenteModel(this.urlLogoRestaurante, this.pedidos); + const PecaNovamenteModel( + {this.urlLogoRestaurante = '', this.pedidos = const [Produto('', 0)]}); - fromFirestore() { - // TODO - } - - toFirestore() { - // TODO - } } diff --git a/lib/models/ultimas_lojas_model.dart b/lib/models/ultimas_lojas_model.dart new file mode 100644 index 0000000..6f58a72 --- /dev/null +++ b/lib/models/ultimas_lojas_model.dart @@ -0,0 +1,20 @@ +class Lojas { + final String nome; + final String logourl; + + const Lojas(this.nome, this.logourl); +} + +class UltimasLojasModel { + final List listadaslojas; + + const UltimasLojasModel(this.listadaslojas); + + fromFirestore() { + // TODO + } + + toFirestore() { + // TODO + } +} diff --git a/lib/pages/busca.dart b/lib/pages/busca.dart index 80a2c16..f8c800a 100644 --- a/lib/pages/busca.dart +++ b/lib/pages/busca.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:ifood_engenharia_de_software/components/busca/banner_de_categoria_componente.dart'; import 'package:ifood_engenharia_de_software/components/busca/caixa_de_pesquisa_componente.dart'; - import '../app_store.dart'; class PaginaBusca extends StatefulWidget { @@ -18,14 +17,26 @@ class _PaginaBuscaState extends State return Scaffold( body: Column(children: [ const MecanismodeBusca(), + + const Align( + alignment: Alignment.topLeft, + child:Padding( + padding: EdgeInsets.only(left: 20,bottom:30), + child:Text( + 'Categorias', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ) + ) + ), AnimatedBuilder( animation: appStore, builder: (_, __) { return SizedBox( - width: 340, - child: BannersDeCategorias( - listacategoria: - appStore.state.bannerdecategoriaData.listacategoria)); + width:390, + child:BannersDeCategorias(listacategoria: + appStore.state.bannerdecategoriaData.listacategoria + ) + ); }) ])); } diff --git a/lib/pages/inicio.dart b/lib/pages/inicio.dart index 50bbd3e..3d89ede 100644 --- a/lib/pages/inicio.dart +++ b/lib/pages/inicio.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:ifood_engenharia_de_software/app_store.dart'; import 'package:ifood_engenharia_de_software/components/inicio/card_da_categoria_componente.dart'; import 'package:ifood_engenharia_de_software/components/inicio/menu_de_redirecionamento_componente.dart'; import 'package:ifood_engenharia_de_software/components/inicio/ultimas_lojas_componente.dart'; +import 'package:ifood_engenharia_de_software/utilities/cores.dart'; +import 'package:ifood_engenharia_de_software/app_store.dart'; class PaginaInicio extends StatefulWidget { const PaginaInicio({Key? key}) : super(key: key); @@ -20,22 +21,25 @@ class _PaginaInicioState extends State const Text('inicio', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)), const Menu(), + + AnimatedBuilder( + animation: appStore, + builder: (_, index) { + return CategoriaCard(categoriaLista: + + appStore.state.cardcategoriaData.categoriaLista + + );}), + + + AnimatedBuilder( - animation: appStore, - builder: (_, index) { - return CategoriaCard( - categoriaLista: - appStore.state.cardcategoriaData.categoriaLista); - }), - const Expanded( - child: UltimasLojasRestaurante( - listalojas: [ - 'Loja exemplo1', - 'Loja exemplo2', - 'Loja exemplo3', - 'Loja exemplo4' - ], - )) + animation: appStore, + builder: (_, index) { + return UltimasLojasRestaurante( + listalojas: + appStore.state.ultimaslojasData.listadaslojas); + }), ]), ); } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 89833d7..a69cd27 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -5,11 +5,13 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:ifood_engenharia_de_software/actions/navegacao_rodape_action.dart'; +import 'package:ifood_engenharia_de_software/app_store.dart'; import 'package:ifood_engenharia_de_software/layouts/default.dart'; import 'package:ifood_engenharia_de_software/pages/register_page.dart'; import 'package:ifood_engenharia_de_software/utilities/cores.dart'; -import 'package:ifood_engenharia_de_software/utils/fire_auth.dart'; -import 'package:ifood_engenharia_de_software/utils/validator.dart'; +import 'package:ifood_engenharia_de_software/utilities/fire_auth.dart'; +import 'package:ifood_engenharia_de_software/utilities/validator.dart'; class LoginPage extends StatefulWidget { const LoginPage({Key? key}) : super(key: key); @@ -55,139 +57,163 @@ class _LoginPageState extends State { _focusPassword.unfocus(); }, child: Scaffold( - body: FutureBuilder( - future: _initializeFirebase(), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - return Padding( - padding: const EdgeInsets.only(left: 24.0, right: 24.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(100))), - padding: const EdgeInsets.only(bottom: 24.0), - /* child: Column(children: [ - Image.network( - "https://cdn.discordapp.com/attachments/868118606448324638/910704703380287539/background.png") - ]), */ - ), - Form( - key: _formKey, - child: Column( - children: [ - TextFormField( - controller: _emailTextController, - focusNode: _focusEmail, - validator: (value) => Validator.validateEmail( - email: value, - ), - decoration: InputDecoration( - hintText: "Email", - errorBorder: UnderlineInputBorder( - borderRadius: BorderRadius.circular(6.0), - borderSide: const BorderSide( - color: Colors.red, + resizeToAvoidBottomInset: false, // set it to false + body: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: NetworkImage( + "https://cdn.discordapp.com/attachments/777244158875402271/915417555856916510/background-login.jpg"), + fit: BoxFit.cover, + ), + ), + child: SingleChildScrollView( + child: FutureBuilder( + future: _initializeFirebase(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return Padding( + padding: const EdgeInsets.only( + left: 24.0, right: 24.0, top: 80.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 150, + decoration: const BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(15))), + padding: const EdgeInsets.only(bottom: 150.0, top: 0), + child: Column(children: [ + Image.network( + "https://cdn.discordapp.com/attachments/777244158875402271/915370339364655154/unknown.png") + ]), + ), + Form( + key: _formKey, + child: Column( + children: [ + TextFormField( + controller: _emailTextController, + focusNode: _focusEmail, + validator: (value) => Validator.validateEmail( + email: value, + ), + decoration: InputDecoration( + border: const OutlineInputBorder(), + hintText: "Email", + errorBorder: UnderlineInputBorder( + borderRadius: BorderRadius.circular(6.0), + borderSide: const BorderSide( + color: Colors.red, + ), + ), ), ), - ), - ), - const SizedBox(height: 8.0), - TextFormField( - controller: _passwordTextController, - focusNode: _focusPassword, - obscureText: true, - validator: (value) => Validator.validatePassword( - password: value, - ), - decoration: InputDecoration( - hintText: "Senha", - errorBorder: UnderlineInputBorder( - borderRadius: BorderRadius.circular(6.0), - borderSide: const BorderSide( - color: AppCores.vermelhoPrincipal, + const SizedBox(height: 8.0), + TextFormField( + controller: _passwordTextController, + focusNode: _focusPassword, + obscureText: true, + validator: (value) => + Validator.validatePassword( + password: value, + ), + decoration: InputDecoration( + border: const OutlineInputBorder(), + hintText: "Senha", + errorBorder: UnderlineInputBorder( + borderRadius: BorderRadius.circular(6.0), + borderSide: const BorderSide( + color: AppCores.vermelhoPrincipal, + ), + ), ), ), - ), - ), - const SizedBox(height: 24.0), - _isProcessing - ? const CircularProgressIndicator() - : Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () async { - _focusEmail.unfocus(); - _focusPassword.unfocus(); - - if (_formKey.currentState! - .validate()) { - setState(() { - _isProcessing = true; - }); - - User? user = await FireAuth - .signInUsingEmailPassword( - email: _emailTextController.text, - password: - _passwordTextController.text, - ); - - setState(() { - _isProcessing = false; - }); - - if (user != null) { - Navigator.of(context) - .pushReplacement( + const SizedBox(height: 24.0), + _isProcessing + ? const CircularProgressIndicator() + : Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: OutlinedButton( + style: OutlinedButton.styleFrom( + side: const BorderSide( + width: 2.0, + color: AppCores + .vermelhoPrincipal), + ), + onPressed: () async { + _focusEmail.unfocus(); + _focusPassword.unfocus(); + + if (_formKey.currentState! + .validate()) { + setState(() { + _isProcessing = true; + }); + + User? user = await FireAuth + .signInUsingEmailPassword( + email: + _emailTextController.text, + password: + _passwordTextController + .text, + ); + + setState(() { + _isProcessing = false; + }); + + if (user != null) { + appStore.dispatcher( + AlterarPagina(0)); + } + } + }, + child: const Text( + 'ENTRAR', + style: TextStyle( + color: AppCores + .vermelhoPrincipal), + ), + ), + ), + const SizedBox(width: 24.0), + Expanded( + child: ElevatedButton( + onPressed: () { + Navigator.of(context).push( MaterialPageRoute( builder: (context) => - LayoutDefault(user: user), + const RegisterPage(), ), ); - } - } - }, - child: const Text( - 'Entrar', - style: TextStyle(color: Colors.white), - ), - ), - ), - const SizedBox(width: 24.0), - Expanded( - child: ElevatedButton( - onPressed: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - const RegisterPage(), + }, + child: const Text( + 'CADASTRAR', + style: TextStyle( + color: Colors.white), ), - ); - }, - child: const Text( - 'Cadastrar-se', - style: TextStyle(color: Colors.white), + ), ), - ), - ), - ], - ) - ], - ), - ) - ], - ), - ); - } - return const Center( - child: CircularProgressIndicator(), - ); - }, + ], + ) + ], + ), + ) + ], + ), + ); + } + return const Center( + child: CircularProgressIndicator(), + ); + }, + ), + ), ), ), ); diff --git a/lib/pages/pedidos.dart b/lib/pages/pedidos.dart index 35f67c4..3afab96 100644 --- a/lib/pages/pedidos.dart +++ b/lib/pages/pedidos.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:ifood_engenharia_de_software/components/pedidos/historico_componente.dart'; import 'package:ifood_engenharia_de_software/components/pedidos/peca_novamente_card_componente.dart'; +import 'package:ifood_engenharia_de_software/components/pedidos/mais_pedidos_por_vc.dart'; import 'package:ifood_engenharia_de_software/utilities/cores.dart'; +import 'package:ifood_engenharia_de_software/app_store.dart'; import '../app_store.dart'; @@ -34,15 +36,31 @@ class _PaginaPedidosState extends State animation: appStore, builder: (_, __) { return PecaNovamenteCard( - quantidade: - appStore.state.pecaNovamenteData.pedidos[0].quantidade, + quantidade: appStore.state.pecaNovamenteData.pedidos[0].quantidade, produto: appStore.state.pecaNovamenteData.pedidos[0].nome, + logoEstabelecimentoImgUrl: appStore.state.pecaNovamenteData.urlLogoRestaurante, ); }, ) ]), ), const SizedBox(height: 100), + const Align( + alignment: Alignment.topLeft, + child: Padding( + padding: EdgeInsets.only(left: 15.0), + child: Text( + 'Mais Pedidos Por Você', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + ), + )), + AnimatedBuilder( + animation: appStore, + builder: (_, index) { + return MaisPedidosPorVcCard( + maispedidoslist: + appStore.state.maispedidosData.maispedidoslist); + }), const Expanded(child: HistoricoCard()) ], ), diff --git a/lib/pages/perfil.dart b/lib/pages/perfil.dart index 2ed5f60..7dff387 100644 --- a/lib/pages/perfil.dart +++ b/lib/pages/perfil.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:ifood_engenharia_de_software/components/perfil/abas_inferiores_do_perfil_componente.dart'; import 'package:ifood_engenharia_de_software/components/perfil/cabecalho_perfil_componente.dart'; -import 'package:ifood_engenharia_de_software/utils/fire_auth.dart'; +import 'package:ifood_engenharia_de_software/utilities/fire_auth.dart'; import '../components/perfil/card_convide_amigos.dart'; import 'login_page.dart'; diff --git a/lib/pages/register_page.dart b/lib/pages/register_page.dart index 33120c0..0cb26d6 100644 --- a/lib/pages/register_page.dart +++ b/lib/pages/register_page.dart @@ -1,12 +1,16 @@ // ignore_for_file: import_of_legacy_library_into_null_safe, unused_import -import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/widgets.dart'; +import 'package:ifood_engenharia_de_software/actions/navegacao_rodape_action.dart'; +import 'package:ifood_engenharia_de_software/app_store.dart'; + import 'package:ifood_engenharia_de_software/pages/login_page.dart'; import 'package:ifood_engenharia_de_software/pages/perfil.dart'; -import 'package:ifood_engenharia_de_software/utils/fire_auth.dart'; -import 'package:ifood_engenharia_de_software/utils/validator.dart'; +import 'package:ifood_engenharia_de_software/utilities/cores.dart'; +import 'package:ifood_engenharia_de_software/utilities/fire_auth.dart'; +import 'package:ifood_engenharia_de_software/utilities/validator.dart'; class RegisterPage extends StatefulWidget { const RegisterPage({Key? key}) : super(key: key); @@ -37,118 +41,119 @@ class _RegisterPageState extends State { _focusPassword.unfocus(); }, child: Scaffold( + appBar: AppBar( + centerTitle: false, + backgroundColor: AppCores.branco, + foregroundColor: AppCores.vermelhoPrincipal, + title: const Text('Cadastro', + style: TextStyle(color: AppCores.vermelhoPrincipal)), + ), + resizeToAvoidBottomInset: false, body: Padding( padding: const EdgeInsets.all(24.0), - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Form( - key: _registerFormKey, - child: Column( - children: [ - TextFormField( - controller: _nameTextController, - focusNode: _focusName, - validator: (value) => Validator.validateName( - name: value, - ), - decoration: InputDecoration( - hintText: "Name", - errorBorder: UnderlineInputBorder( - borderRadius: BorderRadius.circular(6.0), - borderSide: const BorderSide( - color: Colors.red, - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Form( + key: _registerFormKey, + child: Column( + children: [ + TextFormField( + controller: _nameTextController, + focusNode: _focusName, + validator: (value) => Validator.validateName( + name: value, + ), + decoration: InputDecoration( + border: const OutlineInputBorder(), + hintText: "Name", + errorBorder: UnderlineInputBorder( + borderRadius: BorderRadius.circular(6.0), + borderSide: const BorderSide( + color: Colors.red, ), ), ), - const SizedBox(height: 16.0), - TextFormField( - controller: _emailTextController, - focusNode: _focusEmail, - validator: (value) => Validator.validateEmail( - email: value, - ), - decoration: InputDecoration( - hintText: "Email", - errorBorder: UnderlineInputBorder( - borderRadius: BorderRadius.circular(6.0), - borderSide: const BorderSide( - color: Colors.red, - ), + ), + const SizedBox(height: 16.0), + TextFormField( + controller: _emailTextController, + focusNode: _focusEmail, + validator: (value) => Validator.validateEmail( + email: value, + ), + decoration: InputDecoration( + border: const OutlineInputBorder(), + hintText: "Email", + errorBorder: UnderlineInputBorder( + borderRadius: BorderRadius.circular(6.0), + borderSide: const BorderSide( + color: AppCores.vermelhoPrincipal, ), ), ), - const SizedBox(height: 16.0), - TextFormField( - controller: _passwordTextController, - focusNode: _focusPassword, - obscureText: true, - validator: (value) => Validator.validatePassword( - password: value, - ), - decoration: InputDecoration( - hintText: "Senha", - errorBorder: UnderlineInputBorder( - borderRadius: BorderRadius.circular(6.0), - borderSide: const BorderSide( - color: Colors.red, - ), + ), + const SizedBox(height: 16.0), + TextFormField( + controller: _passwordTextController, + focusNode: _focusPassword, + obscureText: true, + validator: (value) => Validator.validatePassword( + password: value, + ), + decoration: InputDecoration( + border: const OutlineInputBorder(), + hintText: "Senha", + errorBorder: UnderlineInputBorder( + borderRadius: BorderRadius.circular(6.0), + borderSide: const BorderSide( + color: Colors.red, ), ), ), - const SizedBox(height: 32.0), - _isProcessing - ? const CircularProgressIndicator() - : Row( - children: [ - Expanded( - child: ElevatedButton( - onPressed: () async { - setState(() { - _isProcessing = true; - }); + ), + const SizedBox(height: 32.0), + _isProcessing + ? const CircularProgressIndicator() + : Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () async { + setState(() { + _isProcessing = true; + }); - if (_registerFormKey.currentState! - .validate()) { - User? user = await FireAuth - .registerUsingEmailPassword( - name: _nameTextController.text, - email: _emailTextController.text, - password: - _passwordTextController.text, - ); + if (_registerFormKey.currentState! + .validate()) { + User? user = await FireAuth + .registerUsingEmailPassword( + name: _nameTextController.text, + email: _emailTextController.text, + password: _passwordTextController.text, + ); - setState(() { - _isProcessing = false; - }); + setState(() { + _isProcessing = false; + }); - if (user != null) { - Navigator.of(context) - .pushAndRemoveUntil( - MaterialPageRoute( - builder: (context) => - const LoginPage(), - ), - ModalRoute.withName('/'), - ); - } + if (user != null) { + appStore.dispatcher(AlterarPagina(0)); } - }, - child: const Text( - 'Cadastrar', - style: TextStyle(color: Colors.white), - ), + } + }, + child: const Text( + 'Cadastrar', + style: TextStyle(color: Colors.white), ), ), - ], - ) - ], - ), - ) - ], - ), + ), + ], + ) + ], + ), + ) + ], ), ), ), diff --git a/lib/utils/fire_auth.dart b/lib/utilities/fire_auth.dart similarity index 89% rename from lib/utils/fire_auth.dart rename to lib/utilities/fire_auth.dart index f5539fd..651c4dc 100644 --- a/lib/utils/fire_auth.dart +++ b/lib/utilities/fire_auth.dart @@ -1,6 +1,7 @@ // ignore_for_file: avoid_print import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/cupertino.dart'; class FireAuth { // For registering a new user @@ -25,9 +26,9 @@ class FireAuth { user = auth.currentUser; } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { - print('The password provided is too weak.'); + print('A senha fornecida é muito fraca'); } else if (e.code == 'email-already-in-use') { - print('The account already exists for that email.'); + print('Já existe uma conta vinculada a este email'); } } catch (e) { print(e); @@ -53,7 +54,7 @@ class FireAuth { } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { print('Usuário não encontrado para esse email'); - } else if (e.code == 'Senha') { + } else if (e.code == 'wrong-password') { print('A senha inserida está incorreta.'); } } diff --git a/lib/utils/validator.dart b/lib/utilities/validator.dart similarity index 85% rename from lib/utils/validator.dart rename to lib/utilities/validator.dart index 7683e0d..2996534 100644 --- a/lib/utils/validator.dart +++ b/lib/utilities/validator.dart @@ -5,7 +5,7 @@ class Validator { } if (name.isEmpty) { - return 'Name can\'t be empty'; + return 'O campo nome não pode ser vazio'; } return null; @@ -34,9 +34,9 @@ class Validator { } if (password.isEmpty) { - return 'Password can\'t be empty'; + return 'A senha não pode ser vazia'; } else if (password.length < 6) { - return 'Enter a password with length at least 6'; + return 'Insira uma senha com 6 cracteres ou mais'; } return null;