Skip to content

Commit

Permalink
Listas
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Oct 14, 2022
1 parent 0099dbd commit 63f2b18
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ListaController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ListaController extends Base {
}
}

Future<List<ListaModel>?> getListas() async {
Future<Map<String, dynamic>> getListas() async {
return await repository.getListas();
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Repository/ListaRepository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ class ListaRepository {
return ResponseAPIModel.fromJson(jsonDecode(response.body));
}

Future<List<ListaModel>> getListas() async {
Future<Map<String, dynamic>> getListas() async {
Uri _uriSearchProduto = Uri.parse(ApiModel.ApiUrl + '/listas');

var _url = Uri.parse(_uriSearchProduto.toString());
final response = await http.get(_url, headers: ApiModel.headers);

Map<String, dynamic> jsonMap = jsonDecode(response.body);
List<ListaModel> listaProdutos = (jsonMap['listas'] as List)
.map((item) => ListaModel.fromJson(item))
.toList();
// List<ListaModel> listaProdutos = (jsonMap['listas'] as List)
// .map((item) => ListaModel.fromJson(item))
// .toList();

return listaProdutos;
return jsonMap;
}
}
70 changes: 62 additions & 8 deletions lib/components/navigation/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:organizei/components/navigation/menu.dart';
import 'package:organizei/home_page.dart';
import 'package:organizei/listas_page.dart';

import '../box.dart';

Expand All @@ -16,6 +18,7 @@ class ButtonNavigatorBar extends StatefulWidget {
class _ButtonNavigatorBarState extends State<ButtonNavigatorBar>
with SingleTickerProviderStateMixin {
bool addIcone = false;
String iconSelected = 'home';

Offset offset = const Offset(0, 2);

Expand Down Expand Up @@ -65,12 +68,35 @@ class _ButtonNavigatorBarState extends State<ButtonNavigatorBar>
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.home_outlined),
onPressed: () {},
icon: Icon(
Icons.home_outlined,
color: iconSelected == 'home'
? const Color(0xFFF7BC36)
: Colors.black,
),
onPressed: () {
setState(() {
iconSelected = 'home';
});
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) => HomePage(),
),
);
},
),
IconButton(
icon: Icon(Icons.bar_chart_outlined),
onPressed: () {},
icon: Icon(
Icons.bar_chart_outlined,
color: iconSelected == 'dashboard'
? const Color(0xFFF7BC36)
: Colors.black,
),
onPressed: () {
setState(() {
iconSelected = 'dashboard';
});
},
),
Container(
child: IconButton(
Expand Down Expand Up @@ -99,12 +125,40 @@ class _ButtonNavigatorBarState extends State<ButtonNavigatorBar>
),
),
IconButton(
icon: Icon(Icons.list_outlined),
onPressed: () {},
icon: Icon(
Icons.list_outlined,
color: iconSelected == 'listas'
? const Color(0xFFF7BC36)
: Colors.black,
),
onPressed: () {
setState(() {
iconSelected = 'listas';
});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ListasPage()),
);
// Navigator.of(context).push<void>(
// MaterialPageRoute<void>(
// builder: (BuildContext context) => ListasPage(),
// ),
// );
},
),
IconButton(
icon: Icon(Icons.folder_outlined),
onPressed: () {},
icon: Icon(
Icons.folder_outlined,
color: iconSelected == 'projetos'
? const Color(0xFFF7BC36)
: Colors.black,
),
onPressed: () {
setState(() {
iconSelected = 'projetos';
});
},
),
],
),
Expand Down
163 changes: 163 additions & 0 deletions lib/listas_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import 'package:flutter/material.dart';
import 'package:http/retry.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:organizei/Controller/ListaController.dart';
import 'package:organizei/Controller/TarefaController.dart';
import 'package:organizei/Model/Habito/HabitoModel.dart';
import 'package:organizei/Model/Lista/ListaModel.dart';
import 'package:organizei/Model/Tarefa/TarefaModel.dart';
import 'package:organizei/Repository/ListaRepository.dart';
import 'package:organizei/Repository/TarefaRepository.dart';
import 'package:organizei/components/card_item.dart';
import 'package:intl/intl.dart';
import 'package:organizei/components/dialogs/habitos/habitoDialog.dart';
import 'package:organizei/components/dialogs/tarefas/tarefaDialog.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'components/box.dart';
import 'components/navigation/bottom_navigation_bar.dart';
import 'components/texto_contornado.dart';

String getSaudacao() {
int horaAtual = new DateTime.now().hour;

if (horaAtual > 4 && horaAtual < 13) {
return 'Bom dia,';
} else if (horaAtual > 12 && horaAtual < 19) {
return 'Boa tarde,';
} else {
return 'Boa Noite,';
}
}

String getDia() {
DateTime data = new DateTime.now();

Intl.defaultLocale = 'pt_BR';
initializeDateFormatting('pt_BR');

return DateFormat.MMMMd().format(data);
}

class ListasPage extends StatefulWidget {
const ListasPage({Key? key}) : super(key: key);

@override
State<ListasPage> createState() => _HomePageState();
}

class _HomePageState extends State<ListasPage> {
late String? apelido = '';

@override
initState() {
getApelido();
super.initState();
}

getApelido() async {
SharedPreferences prefs = await SharedPreferences.getInstance();

setState(() {
apelido = prefs.getString('UsuarioApelido');
});
}

@override
Widget build(BuildContext context) {
late ListaController listaController;
listaController = ListaController(ListaRepository(), context);

return Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
extendBody: true,
backgroundColor: const Color(0xFFE9E9E9),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextoContornado(
texto: 'Listas',
tamanho: 32,
cor: const Color(0xFF6385C3),
)
],
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0.0),
child: Column(children: <Widget>[
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.data.length == 0) {
return const Center(
child:
Text("Você não tem nada pra fazer hoje!"),
);
}

return ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: snapshot.data['listas'].length,
itemBuilder: (context, index) {
var item = ListaModel.fromJson(
snapshot.data['listas'][index]);

//var dialog;

return cardItem(
cor: Color(int.tryParse(
item.cor ?? '0xFF6385C3') ??
0),
nome: item.nome,
horario: '',
abrirDialog: () {});
});
}),
]),
)
],
),
],
),
),
),
floatingActionButton: ButtonNavigatorBar(
fecharDialog: () {
setState(() {});
},
)
//
);
}
}

0 comments on commit 63f2b18

Please sign in to comment.