Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #15

Merged
merged 9 commits into from
May 10, 2023
Merged

Dev #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
base_url=http://192.168.0.123:8080/
URL_LOGIN=https://qacademico.ifce.edu.br/qacademico/index.asp?t=1001
URL_SCHEDULE=https://qacademico.ifce.edu.br/qacademico/index.asp?t=2010
base_url=http://192.168.0.123:3000/
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# academico_mobile


Link do Figma: https://www.figma.com/file/tFLY9uOoiAXYoHrqj7uHiI/Untitled?node-id=0%3A1&t=LloEngcQkWGb6Bna-1

Atividade 01:
- [ ] Instalar Assets (Imagens e Fonts)
- [ ] ThemeData
- [ ] Estilos diferentes de Fonts
- [ ] Preparando Extensions de UI
- [ ] Dotenv
- [ ] RestClient - Dio

- [ ] senha: cddbdabqeujfjluo
- [ ] lembrar do delay na requisição de 2s.
=======
Binary file added assets/images/images_cards/report-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/images_cards/schedule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/images_cards/timetable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logos/logo_academico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/academico_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:academico_mobile/app/core/provider/application_binding.dart';
import 'package:academico_mobile/app/core/ui/theme/theme_config.dart';
import 'package:academico_mobile/app/pages/daily/daily_router.dart';
import 'package:academico_mobile/app/pages/home/home_router.dart';
import 'package:academico_mobile/app/pages/login/login_page.dart';
import 'package:academico_mobile/app/pages/login/login_router.dart';
import 'package:academico_mobile/app/pages/recover_password/recover_password_page.dart';
import 'package:academico_mobile/app/pages/schedule/schedule_router.dart';
import 'package:academico_mobile/app/pages/splash/splash_page.dart';
Expand All @@ -20,7 +20,7 @@ class AcademicoMobile extends StatelessWidget {
debugShowCheckedModeBanner: false,
routes: {
'/': (context) => const SplashPage(),
'/login': (context) => const LoginPage(),
'/login': (context) => LoginRouter.page,
'/schedule': (context) => ScheduleRouter.page,
'/daily': (context) => DailyRouter.page,
'/home': (context) => HomeRouter.page,
Expand Down
1 change: 1 addition & 0 deletions lib/app/core/exceptions/unauthorized_exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class UnauthorizedException implements Exception {}
9 changes: 8 additions & 1 deletion lib/app/core/provider/application_binding.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:academico_mobile/app/core/rest_client/custom_dio.dart';
import 'package:academico_mobile/app/repositories/auth/auth_repository.dart';
import 'package:academico_mobile/app/repositories/auth/auth_repository_impl.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand All @@ -16,7 +18,12 @@ class ApplicationBinding extends StatelessWidget {
providers: [
Provider(
create: (context) => CustomDio(),
)
),
Provider<AuthRepository>(
create: (context) => AuthRepositoryImpl(
dio: context.read(),
),
),
],
child: child,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/app/core/rest_client/custom_dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class CustomDio extends DioForNative {
: super(
BaseOptions(
baseUrl: Env.instance['base_url'] ?? '',
connectTimeout: const Duration(milliseconds: 5000),
receiveTimeout: const Duration(milliseconds: 60000),
connectTimeout: const Duration(milliseconds: 10000),
receiveTimeout: const Duration(milliseconds: 180000),
),
) {
interceptors.add(LogInterceptor(
Expand Down
32 changes: 29 additions & 3 deletions lib/app/core/ui/widgets/my_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,33 @@ class MyAppbar extends AppBar {
required final VoidCallback onPressed,
}) : super(
elevation: elevation,
title: Text(title, style: TextStyles.instance.labelPage),
title: Text(
title,
style: TextStyles.instance.labelPage.copyWith(
fontSize: 15,
),
),
centerTitle: true,
backgroundColor: ColorsApp.instance.background,
leading: IconButton(
icon: Icon(icon),
onPressed: onPressed,
),
);

MyAppbar.normal({
super.key,
double elevation = 0,
required String title,
String subtitle = '',
IconData icon = Icons.arrow_back_ios,
required final VoidCallback onPressed,
}) : super(
elevation: elevation,
title: Text(
title,
style: TextStyles.instance.labelPage
),
centerTitle: true,
backgroundColor: ColorsApp.instance.background,
leading: IconButton(
Expand Down Expand Up @@ -43,7 +69,7 @@ class MyAppbar extends AppBar {
return Container(
alignment: Alignment.center,
padding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
margin:
const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
Expand All @@ -58,7 +84,7 @@ class MyAppbar extends AppBar {
color: state.isOn
? ColorsApp.instance.cardwhite
: ColorsApp.instance.cardwhite,
fontSize: 15,
fontSize: 12,
fontWeight:
TextStyles.instance.textButtonLabel.fontWeight,
),
Expand Down
7 changes: 6 additions & 1 deletion lib/app/core/ui/widgets/my_input_button.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:academico_mobile/app/core/ui/styles/app_styles.dart';
import 'package:academico_mobile/app/core/ui/styles/colors_app.dart';
import 'package:flutter/material.dart';

class MyInputButton extends StatelessWidget {
Expand All @@ -21,7 +22,11 @@ class MyInputButton extends StatelessWidget {
width: width,
height: height,
child: ElevatedButton(
style: context.appStyles.buttonStyle,
style: context.appStyles.buttonStyle.copyWith(
backgroundColor: MaterialStateProperty.all<Color>(
ColorsApp.instance.cardblue,
),
),
onPressed: onPressed,
child: Text(label),
),
Expand Down
25 changes: 25 additions & 0 deletions lib/app/models/auth_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';

class AuthModel {
final String accessToken;

AuthModel({required this.accessToken});

Map<String, dynamic> toMap() {
return <String, dynamic>{
'access_token': accessToken,
};
}

factory AuthModel.fromMap(Map<String, dynamic> map) {
return AuthModel(
accessToken: map['access_token'] ?? '',
);
}

String toJson() => json.encode(toMap());

factory AuthModel.fromJson(String source) =>
AuthModel.fromMap(json.decode(source) as Map<String, dynamic>);
}
15 changes: 6 additions & 9 deletions lib/app/models/daily_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SemestreModel {
}

class DisciplinaModel {
int id;
String id;
String nome;
String professor;
Resumo resumo;
Expand All @@ -37,8 +37,8 @@ class DisciplinaModel {
List<String> avaliacoes =
List<String>.from(json["avaliacoes"].map((x) => x.toString()));
return DisciplinaModel(
id: json["id"],
nome: json["nome"],
id: json["id"] ?? '0',
nome: json["nome"] ?? '',
professor: json["professor"],
resumo: Resumo.fromJson(json["resumo"]),
avaliacoes: avaliacoes);
Expand All @@ -56,7 +56,7 @@ class DisciplinaModel {
class Resumo {
String cargaHoraria;
String faltas;
List<String> aulasFuturas;
String aulasFuturas;
List<String> presencas;
List<String> ausencias;
List<String> pendentes;
Expand All @@ -80,13 +80,10 @@ class Resumo {
List<String> pendentes = List<String>.from(
json["pendentes"].map((x) => x.toString()),
);
List<String> aulasFuturas = List<String>.from(
json["aulas_futuras"].map((x) => x.toString()),
);
return Resumo(
cargaHoraria: json["carga_horaria"],
faltas: json["faltas"],
aulasFuturas: aulasFuturas,
aulasFuturas: json["aulas_futuras"],
presencas: presencas,
ausencias: ausencias,
pendentes: pendentes);
Expand All @@ -95,7 +92,7 @@ class Resumo {
Map<String, dynamic> toJson() => {
"carga_horaria": cargaHoraria,
"faltas": faltas,
"aulas_futuras": List<dynamic>.from(aulasFuturas.map((x) => x)),
"aulas_futuras": aulasFuturas,
"presencas": List<dynamic>.from(presencas.map((x) => x)),
"ausencias": List<dynamic>.from(ausencias.map((x) => x)),
"pendentes": List<dynamic>.from(pendentes.map((x) => x)),
Expand Down
20 changes: 15 additions & 5 deletions lib/app/pages/daily/daily_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ class DailyController extends Cubit<DailyState> {
Future<void> loadSemestre() async {
emit(state.copyWith(status: DailyStateSatus.loading));
try {
await Future.delayed(const Duration(seconds: 2));
final semestres = await _dailyRepository.findDaily();
emit(
state.copyWith(status: DailyStateSatus.loaded, semestres: semestres));
state.copyWith(status: DailyStateSatus.loaded, semestres: semestres),
);
} catch (e, s) {
log('Erro ao buscar semestres', error: e, stackTrace: s);
emit(state.copyWith(
emit(
state.copyWith(
status: DailyStateSatus.error,
errorMessage: 'Erro ao buscar semestres'));
errorMessage: 'Erro ao buscar semestres',
),
);
}
}

Expand All @@ -32,12 +35,19 @@ class DailyController extends Cubit<DailyState> {
await Future.delayed(
const Duration(seconds: 2),
);
emit(state.copyWith(status: DailyStateSatus.loaded, isNow: !state.isNow));
emit(
state.copyWith(
status: DailyStateSatus.loaded,
isNow: !state.isNow,

),
);
}

Future<void> selectedDay(int index) async {
emit(state.copyWith(status: DailyStateSatus.loading));
await Future.delayed(const Duration(seconds: 1));
emit(state.copyWith(status: DailyStateSatus.loaded, selected: index));
}

}
64 changes: 45 additions & 19 deletions lib/app/pages/daily/daily_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class DailyPage extends StatefulWidget {
}

class _DailyPageState extends BaseState<DailyPage, DailyController> {
late List<DisciplinaModel> list = [];
@override
void onReady() {
super.onReady();
controller.loadSemestre();
list = controller.state.semestres[0].disciplinas;
void onReady() async {
await controller.loadSemestre();
if (controller.state.isNow) {
list = controller.state.semestres[0].disciplinas;
}
}

List<DisciplinaModel> list = [];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppbar(
appBar: MyAppbar.normal(
title: 'Meus Diários',
onPressed: () => Navigator.pop(context),
),
Expand Down Expand Up @@ -79,7 +79,12 @@ class _DailyPageState extends BaseState<DailyPage, DailyController> {
borderRadius: BorderRadius.circular(5),
),
child: TextButton(
onPressed: () => controller.selectedDay(index),
onPressed: () {
setState(() {
controller.selectedDay(index);
list = state.semestres[index].disciplinas;
});
},
child: Text(
state.semestres[index].semestre,
style: TextStyles.instance.texLabelH2.copyWith(
Expand All @@ -102,20 +107,41 @@ class _DailyPageState extends BaseState<DailyPage, DailyController> {
padding: EdgeInsets.only(left: context.percentWidth(0.03)),
child: const LabelSubtitle(title: 'Disciplinas'),
),
BlocListener<DailyController, DailyState>(
BlocConsumer<DailyController, DailyState>(
listener: (context, state) {
list = state.semestres[state.selected].disciplinas;
},
child: Expanded(
child: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return ListaCardDisciplina(
disciplina: list[index],
);
state.status.matchAny(
any: () => hideLoader(),
loading: () => showLoader(),
error: () {
hideLoader();
showError(state.errorMessage ??
'Erro ao carregar o cronograma');
},
),
);
},
buildWhen: (previous, current) => current.status.matchAny(
any: () => false,
initial: () => true,
loaded: () => true,
),
builder: (context, state) {
if (state.isNow) {
list = state.semestres[0].disciplinas;
} else {
list = state.semestres[state.selected].disciplinas;
}
return Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: list.length,
itemBuilder: (BuildContext context, int index) {
return ListaCardDisciplina(
disciplina: list[index],
);
},
),
);
},
),
SizedBox(height: context.percentHeight(0.02))
],
Expand Down
3 changes: 2 additions & 1 deletion lib/app/pages/daily/daily_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DailyState extends Equatable {
final String? errorMessage;
final bool isNow;
final int selected;


const DailyState({
required this.status,
Expand All @@ -33,7 +34,7 @@ class DailyState extends Equatable {

DailyState.initial()
: status = DailyStateSatus.initial,
semestres = [],
semestres = <SemestreModel>[],
errorMessage = null,
isNow = true,
selected = 0;
Expand Down
Loading