Skip to content

Commit

Permalink
sdah
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Oct 18, 2022
1 parent bbb0ae9 commit c59243b
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 185 deletions.
18 changes: 18 additions & 0 deletions lib/Controller/DashboardController.dart
Original file line number Diff line number Diff line change
@@ -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<FormState>();

Future<Map<String, dynamic>> getDashboard() async {
return await repository.getDashboard();
}
}
17 changes: 17 additions & 0 deletions lib/Repository/DashboardRepository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'dart:convert';
import 'package:organizei/Model/API/APIModel.dart';
import 'package:http/http.dart' as http;

class DashboardRepository {
Future<Map<String, dynamic>> 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<String, dynamic> jsonMap = jsonDecode(response.body);

return jsonMap;
}
}
83 changes: 54 additions & 29 deletions lib/components/card_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: <Widget>[
// GestureDetector(
Expand Down
1 change: 0 additions & 1 deletion lib/components/dialogs/login/entrarDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Future<dynamic> entrar(BuildContext context) {
await loginController.autentica();

if (succes) {
print('fkfjkl');
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
Expand Down
6 changes: 6 additions & 0 deletions lib/components/navigation/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -98,6 +99,11 @@ class _ButtonNavigatorBarState extends State<ButtonNavigatorBar>
setState(() {
widget.iconSelected = 'dashboard';
});
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) => DashboardPage(),
),
);
},
),
Container(
Expand Down
2 changes: 1 addition & 1 deletion lib/dashborad_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _HomePageState extends State<DashboardPage> {
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0),
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 110),
child: Column(children: <Widget>[
FutureBuilder(
future: dashboardController.getDashboard(),
Expand Down
158 changes: 81 additions & 77 deletions lib/listas_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,88 +30,92 @@ class _HomePageState extends State<ListasPage> {
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),
)
],
),
],
child: Padding(
padding: const EdgeInsets.only(bottom: 110.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.fromLTRB(24.0, 80.0, 24.0, 110),
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());
}
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.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(() {});
},
);
});
});
}),
]),
)
],
),
],
),
),
),
),
Expand Down
Loading

0 comments on commit c59243b

Please sign in to comment.