Skip to content

Commit

Permalink
Merge pull request #2 from NODO-UH/feature/improve-code
Browse files Browse the repository at this point in the history
Setup config for signing in CodeMagic
  • Loading branch information
rmarticedeno authored Apr 17, 2021
2 parents bde6622 + c148c9c commit 57eb63c
Show file tree
Hide file tree
Showing 47 changed files with 731 additions and 447 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GestiónUH
# Gestión UH

A UH managment app.

[![tests](https://github.com/rmarticedeno/gestionapp/actions/workflows/tests.yml/badge.svg)](https://github.com/rmarticedeno/gestionapp/actions/workflows/tests.yml)
[![tests](https://github.com/NODO-UH/gestionapp/actions/workflows/tests.yml/badge.svg)](https://github.com/NODO-UH/gestionapp/actions/workflows/tests.yml) [![Codemagic build status](https://api.codemagic.io/apps/607a1a18d35b7a12ffb6c7dc/607a1a18d35b7a12ffb6c7db/status_badge.svg)](https://codemagic.io/apps/607a1a18d35b7a12ffb6c7dc/607a1a18d35b7a12ffb6c7db/latest_build)
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include: package:lint/analysis_options.yaml

linter:
rules:
always_use_package_imports: true
avoid_classes_with_only_static_members: false
avoid_positional_boolean_parameters: false
constant_identifier_names: false
Expand Down
28 changes: 20 additions & 8 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 29

Expand All @@ -37,21 +43,27 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "cu.uh.gestionuh"
minSdkVersion 18
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}
}

flutter {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="gestionuh"
android:label="Gestión UH"
android:icon="@mipmap/launcher_icon">
<activity

Expand Down
Binary file modified android/app/src/main/res/drawable-v21/background.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 modified android/app/src/main/res/drawable/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>gestionuh</string>
<string>Gestión UH</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
32 changes: 18 additions & 14 deletions lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'deps_injector.dart';
import 'src/data/repository/auth_repository/auth_repository.dart';
import 'src/presentation/blocs.dart';
import 'src/presentation/blocs/reset_password_bloc/resetpassword_bloc.dart';
import 'src/presentation/pages.dart';
import 'src/presentation/pages/about_page.dart';
import 'src/presentation/pages/register_page.dart';
import 'src/presentation/theme.dart';
import 'src/utils/constants.dart';
import 'src/utils/constants/routes.dart';
import 'package:gestionuh/deps_injector.dart';
import 'package:gestionuh/src/data/repository/auth_repository/auth_repository.dart';
import 'package:gestionuh/src/presentation/blocs.dart';
import 'package:gestionuh/src/presentation/pages.dart';
import 'package:gestionuh/src/presentation/pages/about_page.dart';
import 'package:gestionuh/src/presentation/pages/register_page.dart';
import 'package:gestionuh/src/presentation/theme.dart';
import 'package:gestionuh/src/utils/constants.dart';
import 'package:gestionuh/src/utils/constants/routes.dart';

class GestionUhApp extends StatelessWidget {
@override
Expand Down Expand Up @@ -67,9 +65,15 @@ class GestionUhApp extends StatelessWidget {
);
case REGISTER_ROUTE_NAME:
return MaterialPageRoute(
builder: (_) => BlocProvider<RegisterBloc>(
create: (_) => di()..add(QuestionsRequestedRegister()),
child: const RegisterPage(),
builder: (_) => Overlay(
initialEntries: [
OverlayEntry(builder: (context) {
return BlocProvider<RegisterBloc>(
create: (_) => di()..add(QuestionsRequestedRegister()),
child: const RegisterPage(),
);
}),
],
),
);
case ABOUT_ROUTE_NAME:
Expand Down
10 changes: 4 additions & 6 deletions lib/deps_injector.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:gestionuh/src/data/api/api.dart';
import 'package:gestionuh/src/data/local.dart';
import 'package:gestionuh/src/data/repository.dart';
import 'package:gestionuh/src/presentation/blocs.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'src/data/api/api.dart';
import 'src/data/local.dart';
import 'src/data/repository.dart';
import 'src/presentation/blocs.dart';
import 'src/presentation/blocs/reset_password_bloc/resetpassword_bloc.dart';

final di = GetIt.instance;

Future<void> init() async {
Expand Down
7 changes: 3 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';

import 'app.dart';
import 'deps_injector.dart';
import 'src/data/repository/auth_repository/auth_repository.dart';
import 'package:gestionuh/app.dart';
import 'package:gestionuh/deps_injector.dart';
import 'package:gestionuh/src/data/repository/auth_repository/auth_repository.dart';

Future<void> main() async {
await initialize();
Expand Down
17 changes: 10 additions & 7 deletions lib/src/data/api/api.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:convert';

import 'package:dio/dio.dart';

import '../../utils/constants.dart';
import '../models.dart';
import 'package:gestionuh/src/data/models.dart';
import 'package:gestionuh/src/utils/constants.dart';

typedef ClassBuilder<T extends BaseModel> = T Function(
Map<String, dynamic> json);
Expand Down Expand Up @@ -88,7 +87,7 @@ class GestionApi {
);
}

UserData response = await apiRequest<UserData, UserData>(
final UserData response = await apiRequest<UserData, UserData>(
Constants.userDataUrl,
() => UserData(),
null,
Expand Down Expand Up @@ -252,16 +251,16 @@ class GestionApi {
queryParameters: queryParams,
);
} catch (error) {
target.error = error.toString();
target.error = Errors.retrieveError(error.toString());
return target;
}

if (builder != null) {
try {
if (response.statusCode! >= 300) {
Error error = Error.fromJson(
final Error error = Error.fromJson(
jsonDecode(response.data!) as Map<String, dynamic>);
target.error = error.message;
target.error = error.code.toString();
} else {
target = builder(jsonDecode(response.data!) as Map<String, dynamic>);
}
Expand All @@ -270,6 +269,10 @@ class GestionApi {
}
}

if (target.error != null) {
target.error = Errors.retrieveError(target.error!);
}

return target;
}
}
1 change: 1 addition & 0 deletions lib/src/data/models/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class Auth extends BaseModel {

static Auth fromJson(Map<String, dynamic> json) => _$AuthFromJson(json);

@override
Map<String, dynamic> toJson() => _$AuthToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class Error extends BaseModel {

static Error fromJson(Map<String, dynamic> json) => _$ErrorFromJson(json);

@override
Map<String, dynamic> toJson() => _$ErrorToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class Login extends BaseModel {

static Login fromJson(Map<String, dynamic> json) => _$LoginFromJson(json);

@override
Map<String, dynamic> toJson() => _$LoginToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/mail_quota.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class MailQuota extends BaseModel {
static MailQuota fromJson(Map<String, dynamic> json) =>
_$MailQuotaFromJson(json);

@override
Map<String, dynamic> toJson() => _$MailQuotaToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/pass_reset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class PassReset extends BaseModel {
static PassReset fromJson(Map<String, dynamic> json) =>
_$PassResetFromJson(json);

@override
Map<String, dynamic> toJson() => _$PassResetToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/password_edit_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class PasswordEditData extends BaseModel {
static PasswordEditData fromJson(Map<String, dynamic> json) =>
_$PasswordEditDataFromJson(json);

@override
Map<String, dynamic> toJson() => _$PasswordEditDataToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/password_reset_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class PasswordResetData extends BaseModel {
static PasswordResetData fromJson(Map<String, dynamic> json) =>
_$PasswordResetDataFromJson(json);

@override
Map<String, dynamic> toJson() => _$PasswordResetDataToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/password_reset_user_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class PasswordResetUserId extends BaseModel {
static PasswordResetUserId fromJson(Map<String, dynamic> json) =>
_$PasswordResetUserIdFromJson(json);

@override
Map<String, dynamic> toJson() => _$PasswordResetUserIdToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/quota.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class Quota extends BaseModel {

static Quota fromJson(Map<String, dynamic> json) => _$QuotaFromJson(json);

@override
Map<String, dynamic> toJson() => _$QuotaToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/security_questions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class SecurityQuestions extends BaseModel {
static SecurityQuestions fromJson(Map<String, dynamic> json) =>
_$SecurityQuestionsFromJson(json);

@override
Map<String, dynamic> toJson() => _$SecurityQuestionsToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/user_ci.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ class UserCi extends BaseModel {

static UserCi fromJson(Map<String, dynamic> json) => _$UserCiFromJson(json);

@override
Map<String, dynamic> toJson() => _$UserCiToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/user_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ class UserData extends BaseModel {
static UserData fromJson(Map<String, dynamic> json) =>
_$UserDataFromJson(json);

@override
Map<String, dynamic> toJson() => _$UserDataToJson(this);
}
1 change: 1 addition & 0 deletions lib/src/data/models/user_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ class UserId extends BaseModel {

static UserId fromJson(Map<String, dynamic> json) => _$UserIdFromJson(json);

@override
Map<String, dynamic> toJson() => _$UserIdToJson(this);
}
10 changes: 5 additions & 5 deletions lib/src/data/repository/auth_repository/auth_repository.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:developer';

import '../../../utils/constants/storage_keys.dart';
import '../../api/api.dart';
import '../../local/local_storage.dart';
import '../../models.dart';
import '../../models/status.dart';
import 'package:gestionuh/src/data/api/api.dart';
import 'package:gestionuh/src/data/local/local_storage.dart';
import 'package:gestionuh/src/data/models.dart';
import 'package:gestionuh/src/data/models/status.dart';
import 'package:gestionuh/src/utils/constants/storage_keys.dart';

class AuthRepository {
final GestionApi api;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/presentation/blocs/login_bloc/login_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../data/repository.dart';
import 'package:gestionuh/src/data/repository.dart';
import 'package:gestionuh/src/utils/constants.dart';

part 'login_event.dart';
part 'login_state.dart';
Expand Down Expand Up @@ -28,7 +28,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
);
if (result == null) {
yield LoginAttemptInitial(
error: 'Ha ocurrido un error inesperado.',
error: Errors.DefaultError,
);
} else if (result.error != null) {
yield LoginAttemptInitial(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/data/models.dart';
import 'package:gestionuh/src/data/repository.dart';
import 'package:gestionuh/src/utils/constants.dart';

part 'mail_quota_event.dart';
part 'mail_quota_state.dart';
Expand All @@ -25,7 +26,7 @@ class MailQuotaBloc extends Bloc<MailQuotaEvent, MailQuotaState> {
final result = await mailQuotasRepository.getQuota();
if (result == null) {
yield MailQuotaLoadedFailure(
error: 'Ha ocurrido un error inesperado.',
error: Errors.DefaultError,
);
} else if (result.error != null) {
yield MailQuotaLoadedFailure(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/presentation/blocs/profile_bloc/profile_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/data/models.dart';
import 'package:gestionuh/src/data/repository.dart';
import 'package:gestionuh/src/utils/constants.dart';

part 'profile_event.dart';
part 'profile_state.dart';
Expand All @@ -25,7 +26,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
final result = await profileRepository.getUserData();
if (result == null) {
yield ProfileLoadedFailure(
error: 'Ha ocurrido un error inesperado.',
error: Errors.DefaultError,
);
} else if (result.error != null) {
yield ProfileLoadedFailure(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/presentation/blocs/quota_bloc/quota_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gestionuh/src/data/models.dart';
import 'package:gestionuh/src/data/repository.dart';
import 'package:gestionuh/src/utils/constants.dart';

part 'quota_event.dart';
part 'quota_state.dart';
Expand All @@ -24,7 +25,7 @@ class QuotaBloc extends Bloc<QuotaEvent, QuotaState> {
final result = await quotasRepository.getQuota();
if (result == null) {
yield QuotaLoadedFailure(
error: 'Ha ocurrido un error inesperado.',
error: Errors.DefaultError,
);
} else if (result.error != null) {
yield QuotaLoadedFailure(
Expand Down
Loading

0 comments on commit 57eb63c

Please sign in to comment.