Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonel Garcia committed Apr 25, 2021
2 parents 670584d + 4ed9db4 commit 4fff47e
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 62 deletions.
101 changes: 55 additions & 46 deletions lib/src/presentation/pages/home_page/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class HomePage extends StatelessWidget {
child: Scaffold(
appBar: _buildAppBar(),
drawer: _buildDrawer(context),
bottomSheet: const GestionUHBottomSheet(),
body: _buildBody(context),
),
);
Expand Down Expand Up @@ -58,53 +57,63 @@ class HomePage extends StatelessWidget {

Drawer _buildDrawer(BuildContext context) {
return Drawer(
child: BlocBuilder<HomeBloc, HomeState>(
builder: (_, state) {
return ListView(
children: [
DrawerHeader(
child: Image.asset(
'assets/images/logo-uh.png',
color: Theme.of(context).primaryColor,
),
),
...state.when<List<Widget>>(
loading: () => [
ListTile(
leading: const GestionUhLoadingIndicator(),
title: Text(
'Cargando ...',
style: Theme.of(context).textTheme.subtitle2,
),
),
],
error: (error) => [
ListTile(
leading: const Icon(Icons.error),
title: Text(
'Error',
style: Theme.of(context).textTheme.subtitle2,
child: Column(
children: [
Expanded(
child: BlocBuilder<HomeBloc, HomeState>(
builder: (_, state) {
return ListView(
children: [
DrawerHeader(
child: Image.asset(
'assets/images/logo-uh.png',
color: Theme.of(context).primaryColor,
),
),
),
],
profile: (p, x) => _getDrawerItems(context, p, x),
quota: (p, x) => _getDrawerItems(context, p, x),
mailQuota: (p, x) => _getDrawerItems(context, p, x),
resetPassword: (p, x) => _getDrawerItems(context, p, x),
aboutUs: (p, x) => _getDrawerItems(context, p, x),
logout: () => [
ListTile(
leading: const GestionUhLoadingIndicator(),
title: Text(
'Cerrando Sesión ...',
style: Theme.of(context).textTheme.subtitle2,
...state.when<List<Widget>>(
loading: () => [
ListTile(
leading: const GestionUhLoadingIndicator(),
title: Text(
'Cargando ...',
style: Theme.of(context).textTheme.subtitle2,
),
),
],
error: (error) => [
ListTile(
leading: const Icon(Icons.error),
title: Text(
'Error',
style: Theme.of(context).textTheme.subtitle2,
),
),
],
profile: (p, x) => _getDrawerItems(context, p, x),
quota: (p, x) => _getDrawerItems(context, p, x),
mailQuota: (p, x) => _getDrawerItems(context, p, x),
resetPassword: (p, x) => _getDrawerItems(context, p, x),
aboutUs: (p, x) => _getDrawerItems(context, p, x),
logout: () => [
ListTile(
leading: const GestionUhLoadingIndicator(),
title: Text(
'Cerrando Sesión ...',
style: Theme.of(context).textTheme.subtitle2,
),
),
],
),
),
],
),
],
);
},
],
);
},
),
),
const Align(
alignment: Alignment.bottomCenter,
child: GestionUHBottomSheet(),
),
],
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gestionuh/src/presentation/widgets/flash_helper.dart';
import 'package:gestionuh/src/presentation/widgets/widgets.dart';
import 'package:gestionuh/src/utils/constants/constants.dart';
import 'package:responsive_builder/responsive_builder.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/presentation/blocs/reset_password_bloc/resetpassword_bloc.dart';
import 'package:gestionuh/src/presentation/widgets/flash_helper.dart';
import 'package:gestionuh/src/presentation/widgets/widgets.dart';
import 'package:gestionuh/src/utils/validators.dart';
import 'package:responsive_builder/responsive_builder.dart';
Expand Down
9 changes: 5 additions & 4 deletions lib/src/presentation/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/data/local/local_storage.dart';
import 'package:gestionuh/src/data/repositories/repositories.dart';
import 'package:gestionuh/src/presentation/blocs/blocs.dart';
import 'package:gestionuh/src/presentation/widgets/bottom_sheet.dart';
import 'package:gestionuh/src/presentation/widgets/flash_helper.dart';
import 'package:gestionuh/src/presentation/widgets/widgets.dart';
import 'package:gestionuh/src/utils/constants/routes.dart';
import 'package:gestionuh/src/utils/constants/constants.dart';
import 'package:gestionuh/src/utils/validators.dart';
import 'package:get_it/get_it.dart';
import 'package:responsive_builder/responsive_builder.dart';
Expand Down Expand Up @@ -56,7 +54,7 @@ class _LoginPageState extends State<LoginPage> {
final authRepo = GetIt.I<AuthRepository>();
return Scaffold(
appBar: AppBar(
title: const Text('Iniciar Sesión'),
title: const Text(Constants.appName),
centerTitle: true,
),
bottomSheet: const GestionUHBottomSheet(),
Expand Down Expand Up @@ -193,6 +191,9 @@ class _LoginPageState extends State<LoginPage> {
text: 'Registrarse',
onPressed: () => _registerAction(context),
),
const SizedBox(
height: 30,
),
],
),
),
Expand Down
6 changes: 4 additions & 2 deletions lib/src/presentation/pages/recover_password_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/presentation/blocs/blocs.dart';
import 'package:gestionuh/src/presentation/widgets/flash_helper.dart';
import 'package:gestionuh/src/presentation/widgets/widgets.dart';
import 'package:gestionuh/src/utils/validators.dart';
import 'package:responsive_builder/responsive_builder.dart';
Expand Down Expand Up @@ -244,7 +243,10 @@ class RecoverPasswordPage extends StatelessWidget {
),
],
),
)
),
const SizedBox(
height: 30,
),
],
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/src/presentation/pages/register_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/presentation/blocs/blocs.dart';
import 'package:gestionuh/src/presentation/widgets/bottom_sheet.dart';
import 'package:gestionuh/src/presentation/widgets/flash_helper.dart';
import 'package:gestionuh/src/presentation/widgets/widgets.dart';
import 'package:gestionuh/src/utils/constants/constants.dart';
import 'package:gestionuh/src/utils/pair.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/src/presentation/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export 'bottom_sheet.dart';
export 'buttons/buttons.dart';
export 'flash_helper.dart';
export 'loading_indicators/loading_indicators.dart';
export 'mail_quota_graph.dart';
export 'quota_graph.dart';
Expand Down
16 changes: 9 additions & 7 deletions lib/src/utils/constants/errors.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
class Errors {
static const Messages = {1: 'Datos inválidos.', 2: 'Credenciales inválidas.'};
static const Messages = {
1: 'Datos inválidos.',
2: 'Credenciales inválidas.',
20: 'Datos inválidos.',
};

static const DefaultError = 'Ha ocurrido un error.';

static const ConnectionError = 'Conexión fallida. Verifique su conectividad.';

static String? retrieveError(String message) {
try {
final index = int.parse(message);
return Messages[index];
} catch (_) {}

return DefaultError;
final index = int.tryParse(message);
return index != null && Messages.containsKey(index)
? Messages[index]
: DefaultError;
}
}

0 comments on commit 4fff47e

Please sign in to comment.