diff --git a/lib/Controller/DashboardController.dart b/lib/Controller/DashboardController.dart new file mode 100644 index 0000000..5028902 --- /dev/null +++ b/lib/Controller/DashboardController.dart @@ -0,0 +1,18 @@ +import 'dart:ffi'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart'; +import 'package:organizei/Controller/Base/Base.dart'; +import 'package:organizei/Repository/DashboardRepository.dart'; + +class DashboardController extends Base { + DashboardController(this.repository, this.context); + + final BuildContext context; + final DashboardRepository repository; + final formKey = GlobalKey(); + + Future> getDashboard() async { + return await repository.getDashboard(); + } +} diff --git a/lib/Repository/DashboardRepository.dart b/lib/Repository/DashboardRepository.dart new file mode 100644 index 0000000..3e2987a --- /dev/null +++ b/lib/Repository/DashboardRepository.dart @@ -0,0 +1,17 @@ +import 'dart:convert'; +import 'package:organizei/Model/API/APIModel.dart'; +import 'package:http/http.dart' as http; + +class DashboardRepository { + Future> getDashboard() async { + Uri url = Uri.parse(ApiModel().ApiUrl + '/dashboard'); + + var _url = Uri.parse(url.toString()); + final response = + await http.get(_url, headers: await ApiModel().getHeaders()); + + Map jsonMap = jsonDecode(response.body); + + return jsonMap; + } +} diff --git a/lib/components/card_item.dart b/lib/components/card_item.dart index 6b2fbe4..4848120 100644 --- a/lib/components/card_item.dart +++ b/lib/components/card_item.dart @@ -6,18 +6,27 @@ class cardItem extends StatelessWidget { final Color? cor; final String? horario; final String? nome; + final String? dash; final Function? abrirDialog; const cardItem( - {Key? key, this.cor, this.horario, this.nome, this.abrirDialog}) + {Key? key, + this.cor, + this.horario, + this.nome, + this.abrirDialog, + this.dash}) : super(key: key); String formatarNome() { - if (this.nome!.length > 17) { - String nomeAbreviado = this.nome!.substring(0, 17); + if (nome != null && nome!.length > 17) { + String nomeAbreviado = nome!.substring(0, 17); return nomeAbreviado + '...'; - } else - return this.nome!; + } else if (nome == null) { + return ''; + } else { + return nome!; + } } @override @@ -36,35 +45,51 @@ class cardItem extends StatelessWidget { ), ), child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(21)), + borderRadius: const BorderRadius.all(Radius.circular(21)), child: GestureDetector( onTap: () { - abrirDialog!(); + if (abrirDialog != null) abrirDialog!(); }, child: Row( children: [ - Container( - width: 90, - //height: 90, - height: double.infinity, - decoration: BoxDecoration( - //borderRadius: BorderRadius.all(Radius.circular(16)), - color: cor, - ), - ), - Expanded( - child: ListTile( - title: TextoContornado( - texto: formatarNome(), - tamanho: 24, - cor: cor, - ), - subtitle: Text( - horario!, - style: TextStyle(fontSize: 16.0), - ), - ), - ), + dash == null + ? Container( + width: 90, + //height: 90, + height: double.infinity, + decoration: BoxDecoration( + //borderRadius: BorderRadius.all(Radius.circular(16)), + color: cor, + ), + ) + : Container( + width: 90, + child: Center( + child: TextoContornado( + texto: dash, tamanho: 32, cor: cor), + )), + nome != null + ? Expanded( + child: ListTile( + title: TextoContornado( + texto: formatarNome(), + tamanho: 24, + cor: cor, + ), + subtitle: Text( + horario!, + style: const TextStyle(fontSize: 16.0), + ), + ), + ) + : Expanded( + child: ListTile( + subtitle: Text( + horario!, + style: const TextStyle(fontSize: 16.0), + ), + ), + ), // Row( // children: [ // GestureDetector( diff --git a/lib/components/dialogs/login/entrarDialog.dart b/lib/components/dialogs/login/entrarDialog.dart index c537186..b9f559d 100644 --- a/lib/components/dialogs/login/entrarDialog.dart +++ b/lib/components/dialogs/login/entrarDialog.dart @@ -65,7 +65,6 @@ Future entrar(BuildContext context) { await loginController.autentica(); if (succes) { - print('fkfjkl'); Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => diff --git a/lib/components/navigation/bottom_navigation_bar.dart b/lib/components/navigation/bottom_navigation_bar.dart index f5b8c4d..eaac17a 100644 --- a/lib/components/navigation/bottom_navigation_bar.dart +++ b/lib/components/navigation/bottom_navigation_bar.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:organizei/components/navigation/menu.dart'; +import 'package:organizei/dashborad_page.dart'; import 'package:organizei/home_page.dart'; import 'package:organizei/listas_page.dart'; import 'package:organizei/projetos_page.dart'; @@ -98,6 +99,11 @@ class _ButtonNavigatorBarState extends State setState(() { widget.iconSelected = 'dashboard'; }); + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => DashboardPage(), + ), + ); }, ), Container( diff --git a/lib/dashborad_page.dart b/lib/dashborad_page.dart index 910c72b..b669c72 100644 --- a/lib/dashborad_page.dart +++ b/lib/dashborad_page.dart @@ -52,7 +52,7 @@ class _HomePageState extends State { ), ), Padding( - padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0), + padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 110), child: Column(children: [ FutureBuilder( future: dashboardController.getDashboard(), diff --git a/lib/listas_page.dart b/lib/listas_page.dart index 77ba541..0d6702a 100644 --- a/lib/listas_page.dart +++ b/lib/listas_page.dart @@ -30,88 +30,92 @@ class _HomePageState extends State { body: SingleChildScrollView( scrollDirection: Axis.vertical, child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextoContornado( - texto: 'Listas', - tamanho: 32, - cor: const Color(0xFF6385C3), - ) - ], - ), - ], + child: Padding( + padding: const EdgeInsets.only(bottom: 110.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + Padding( + padding: + const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 110), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextoContornado( + texto: 'Listas', + tamanho: 32, + cor: const Color(0xFF6385C3), + ) + ], + ), + ], + ), ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0), - child: Column(children: [ - FutureBuilder( - future: listaController.getListas(), - builder: (context, AsyncSnapshot snapshot) { - if (!snapshot.hasData) { - return const Center( - child: CircularProgressIndicator()); - } + Padding( + padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0), + child: Column(children: [ + FutureBuilder( + future: listaController.getListas(), + builder: (context, AsyncSnapshot snapshot) { + if (!snapshot.hasData) { + return const Center( + child: CircularProgressIndicator()); + } - if (snapshot.hasError) { - return const Center( - child: Text('Ocorreu um erro!'), - ); - } + if (snapshot.hasError) { + return const Center( + child: Text('Ocorreu um erro!'), + ); + } - if (snapshot.data['listas'].length == 0) { - return const Center( - child: Padding( - padding: EdgeInsets.only(top: 32.0), - child: Text("Você não tem listas!"), - ), - ); - } + if (snapshot.data['listas'].length == 0) { + return const Center( + child: Padding( + padding: EdgeInsets.only(top: 32.0), + child: Text("Você não tem listas!"), + ), + ); + } - return ListView.builder( - primary: false, - shrinkWrap: true, - itemCount: snapshot.data['listas'].length, - itemBuilder: (context, index) { - var item = ListaModel.fromJson( - snapshot.data['listas'][index], - ); + return ListView.builder( + primary: false, + shrinkWrap: true, + itemCount: snapshot.data['listas'].length, + itemBuilder: (context, index) { + var item = ListaModel.fromJson( + snapshot.data['listas'][index], + ); - return cardItem( - cor: Color(int.tryParse( - item.cor ?? '0xFF6385C3') ?? - 0), - nome: item.nome, - horario: '', - abrirDialog: () { - return visualizarLista( - context, - lista: item, - fecharDialog: () { - setState(() {}); - }, - ); - }); - }); - }), - ]), - ) - ], - ), - ], + return cardItem( + cor: Color(int.tryParse( + item.cor ?? '0xFF6385C3') ?? + 0), + nome: item.nome, + horario: '', + abrirDialog: () { + return visualizarLista( + context, + lista: item, + fecharDialog: () { + setState(() {}); + }, + ); + }); + }); + }), + ]), + ) + ], + ), + ], + ), ), ), ), diff --git a/lib/projetos_page.dart b/lib/projetos_page.dart index 22ec5de..b48e144 100644 --- a/lib/projetos_page.dart +++ b/lib/projetos_page.dart @@ -30,88 +30,91 @@ class _HomePageState extends State { body: SingleChildScrollView( scrollDirection: Axis.vertical, child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - TextoContornado( - texto: 'Projetos', - tamanho: 32, - cor: const Color(0xFF6385C3), - ) - ], - ), - ], + child: Padding( + padding: const EdgeInsets.only(bottom: 110.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + TextoContornado( + texto: 'Projetos', + tamanho: 32, + cor: const Color(0xFF6385C3), + ) + ], + ), + ], + ), ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0), - child: Column(children: [ - FutureBuilder( - future: listaController.getProjetos(), - builder: (context, AsyncSnapshot snapshot) { - if (!snapshot.hasData) { - return const Center( - child: CircularProgressIndicator()); - } + Padding( + padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0), + child: Column(children: [ + FutureBuilder( + future: listaController.getProjetos(), + builder: (context, AsyncSnapshot snapshot) { + if (!snapshot.hasData) { + return const Center( + child: CircularProgressIndicator()); + } - if (snapshot.hasError) { - return const Center( - child: Text('Ocorreu um erro!'), - ); - } + if (snapshot.hasError) { + return const Center( + child: Text('Ocorreu um erro!'), + ); + } - if (snapshot.data['projetos'].length == 0) { - return const Center( - child: Padding( - padding: EdgeInsets.only(top: 32.0), - child: Text("Você não tem projetos!"), - ), - ); - } + if (snapshot.data['projetos'].length == 0) { + return const Center( + child: Padding( + padding: EdgeInsets.only(top: 32.0), + child: Text("Você não tem projetos!"), + ), + ); + } - return ListView.builder( - primary: false, - shrinkWrap: true, - itemCount: snapshot.data['projetos'].length, - itemBuilder: (context, index) { - var item = ProjetoModel.fromJson( - snapshot.data['projetos'][index], - ); + return ListView.builder( + primary: false, + shrinkWrap: true, + itemCount: snapshot.data['projetos'].length, + itemBuilder: (context, index) { + var item = ProjetoModel.fromJson( + snapshot.data['projetos'][index], + ); - return cardItem( - cor: Color(int.tryParse( - item.cor ?? '0xFF6385C3') ?? - 0), - nome: item.nome, - horario: '', - abrirDialog: () { - return visualizarProjeto( - context, - projeto: item, - fecharDialog: () { - setState(() {}); - }, - ); - }); - }); - }), - ]), - ) - ], - ), - ], + return cardItem( + cor: Color(int.tryParse( + item.cor ?? '0xFF6385C3') ?? + 0), + nome: item.nome, + horario: '', + abrirDialog: () { + return visualizarProjeto( + context, + projeto: item, + fecharDialog: () { + setState(() {}); + }, + ); + }); + }); + }), + ]), + ) + ], + ), + ], + ), ), ), ),