Skip to content

Commit 5e1f164

Browse files
committed
Update
- Corrección de bug al descargar el mapa - Cambiar idioma del título de la actividad seleccionada en el mapa - Agregar traducción de "error" y "sin conexión" - Agregar instrucciones al README
1 parent d600d6f commit 5e1f164

File tree

12 files changed

+70
-75
lines changed

12 files changed

+70
-75
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ El proyecto “EcoZonas: Piloto para diseñar, escalar y replicar la acción cli
1515

1616
Este proyecto se centra en la implementación de proyectos piloto en dos barrios vulnerables de ciudades mexicanas de tamaño medio con el objetivo de desarrollar, apoyar y fortalecer procesos y métodos participativos de acción climática inclusiva y replicable a nivel comunitario, enmarcados en planes de acción climática municipales y nacionales. Los principales beneficiarios son las comunidades locales, sociedad civil organizada, los municipios y los gobiernos estatales y nacionales.
1717

18+
## Obtener api de Mapbox
19+
1. Visitar la página de Mapbox
20+
2. ___
21+
22+
## Como compilar la aplicación
23+
1. Clonar proyecto desde: ___
24+
2. Instalar Visual Studio Code para abrir el proyecto
25+
3. En Visual Studio Code y abrir el proyecto utiilzando Open Folder
26+
4. En la terminal de Visual Studio Code, ejecutar el comando “flutter pub get” para descargar las librerías del proyecto
27+
5. Una vez terminado el proceso, ejecutar “flutter run apk --dart-define=ACCESS_TOKEN=[API_DE_MAPBOX]” para compilar el proyecto. Se debe reemplazar [API_DE_MAPBOX] con el obtenido en la página oficial de Mapbox
28+
29+
## Versiones utilizadas
30+
1. Flutter (Channel stable, 3.22.3, on macOS 15.0.1)
31+
1. Flutter version 3.22.3 on channel stable
32+
2. Dart version 3.4.4
33+
3. DevTools version 2.34.3
34+
2. Android toolchain - develop for Android devices (Android SDK version 33.0.1)
35+
1. Platform android-34, build-tools 33.0.1
36+
2. Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
37+
3. Xcode - develop for iOS and macOS (Xcode 16.1)
38+
1. CocoaPods version 1.14.3
39+
4. Android Studio (version 2023.2)
40+
1. Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
41+
5. VS Code (version 1.94.2)
42+
1. Flutter extension version 3.98.0
43+
1844
## Cómo contribuir al proyecto
1945

2046
De momento el proyecto no está abierto a contribuciones, pero está planeado abrirlo a futuro.

lib/l10n/app_en.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,7 @@
118118
"example": "s"
119119
}
120120
}
121-
}
121+
},
122+
"errorFound": "An error was found",
123+
"noConnection": "No connection"
122124
}

lib/l10n/app_es.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,7 @@
118118
"example": "s"
119119
}
120120
}
121-
}
121+
},
122+
"errorFound": "Se encontró un error",
123+
"noConnection": "Sin conexión"
122124
}

lib/src/data/apis/base_api.dart

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ class BaseApi {
2020
"Accept" : "application/json"
2121
};
2222

23-
// static Map<String, String> _authHeaders() {
24-
// final prefs = UserPreferences();
25-
// return {
26-
// ..._headers,
27-
// "Authorization" : "Bearer ${prefs.getLoginData!.token}"
28-
// };
29-
// }
30-
3123
/*
3224
* FUTURES
3325
*/
@@ -36,7 +28,6 @@ class BaseApi {
3628
if (connectionAvailable) {
3729
final http.Response response = await http.get(
3830
Uri.parse('${basePath}api/$endpoint'),
39-
// headers : _authHeaders()
4031
);
4132
if (response.ok) {
4233
return ApiResponseModel(
@@ -46,13 +37,11 @@ class BaseApi {
4637
} else {
4738
return ApiResponseModel(
4839
isSuccess: false,
49-
error: 'No se pudo descargar la información'
5040
);
5141
}
5242
} else {
5343
return ApiResponseModel(
5444
isSuccess: false,
55-
error: 'No hay conexión a internet'
5645
);
5746
}
5847
}
@@ -77,42 +66,11 @@ class BaseApi {
7766
} else {
7867
return ApiResponseModel(
7968
isSuccess: false,
80-
error: 'No se pudo enviar la información'
81-
);
82-
}
83-
} else {
84-
return ApiResponseModel(
85-
isSuccess: false,
86-
error: 'No hay conexión a internet'
87-
);
88-
}
89-
}
90-
91-
static Future<ApiResponseModel> postTest({
92-
required String endpoint,
93-
required Map<String, dynamic> body
94-
}) async {
95-
final connectionAvailable = await Connectivity.connectionAvailable();
96-
if (connectionAvailable) {
97-
final http.Response response = await http.post(
98-
Uri.parse(endpoint),
99-
body: json.encode(body),
100-
);
101-
if (response.ok) {
102-
return ApiResponseModel(
103-
isSuccess: true,
104-
result: json.decode(response.body),
105-
);
106-
} else {
107-
return ApiResponseModel(
108-
isSuccess: false,
109-
error: 'No se pudo enviar la información'
11069
);
11170
}
11271
} else {
11372
return ApiResponseModel(
11473
isSuccess: false,
115-
error: 'No hay conexión a internet'
11674
);
11775
}
11876
}
@@ -153,7 +111,6 @@ class BaseApi {
153111
} else {
154112
return ApiResponseModel(
155113
isSuccess: false,
156-
error: 'No hay conexión a internet'
157114
);
158115
}
159116
}

lib/src/domain/models/api_response_model.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ class ApiResponseModel {
88
ApiResponseModel({
99
required this.isSuccess,
1010
this.result,
11-
this.error,
1211
});
1312

1413
bool isSuccess;
15-
// Map<String, dynamic>? result;
1614
dynamic result;
17-
String? error;
1815

1916
factory ApiResponseModel.fromJson(Map<String, dynamic> json) => ApiResponseModel(
2017
isSuccess: json['isSuccess'],
2118
result: json['result'],
22-
error: json['error'],
2319
);
2420

2521
Map<String, dynamic> toJson() => {
2622
'isSuccess': isSuccess,
2723
'result': result,
28-
'error': error,
2924
};
3025
}

lib/src/ui/pages/form_module/form_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class FormPage extends StatelessWidget {
216216

217217
try {
218218
final prefs = UserPreferences();
219+
final title = utils.showEnglish(context) ? activity.titleEn : activity.title;
219220

220221
final useCase = MapatonUseCase(MapatonRepositoryImpl());
221222
final m = await useCase.getMapatonsByUuidAndMapper(activity.mapatonUuid!, prefs.getMapper!.id.toString());
@@ -227,7 +228,7 @@ class FormPage extends StatelessWidget {
227228
final a = ActivityDbModel(
228229
mapatonId: m!.id!,
229230
uuid: activity.uuid,
230-
name: activity.title,
231+
name: title,
231232
color: activity.category.color,
232233
borderColor: activity.category.borderColor!,
233234
latitude: lat,

lib/src/ui/pages/mapaton_list_module/tabs_container/mapaton_tabs_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class MapatonTabsPage extends StatelessWidget implements BottomNavigationBarStat
199199
}
200200
} else {
201201
if (context.mounted) {
202-
utils.showSnackBarError(context, mapatonResponse.error!);
202+
utils.showSnackBarError(context, AppLocalizations.of(context)!.errorFound);
203203
}
204204
}
205205

@@ -224,7 +224,7 @@ class MapatonTabsPage extends StatelessWidget implements BottomNavigationBarStat
224224
}
225225
} else {
226226
if (context.mounted) {
227-
utils.showSnackBarError(context, surveyResponse.error!);
227+
utils.showSnackBarError(context, AppLocalizations.of(context)!.errorFound);
228228
}
229229
}
230230

lib/src/ui/pages/mapaton_map_module/bloc/mapaton_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class MapatonBloc extends Bloc<MapatonEvent, MapatonState> {
114114
void _mapDownloadRegionToState(Emitter<MapatonState> emit, String name, LatLngBounds bounds) async {
115115
emit(DownloadingRegion());
116116
try {
117-
await _downloadRegion(bounds, name);
117+
await _downloadRegion(bounds, name);
118118
emit(RegionDownloaded());
119119
} catch (err) {
120120
emit(ErrorDownloadingRegion());

lib/src/ui/pages/mapaton_map_module/mapaton_map_content.dart

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:mapbox_gl/mapbox_gl.dart';
99
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
1010

1111
import '../../../../main.dart';
12+
import '../../../data/device/connectivity.dart';
1213
import '../../../data/preferences/user_preferences.dart';
1314
import '../../../domain/models/current_activity_model.dart';
1415
import '../../../domain/models/db/activity_db_model.dart';
@@ -397,15 +398,19 @@ class _MapatonMapContentState extends State<MapatonMapContent> {
397398
}
398399

399400
Future<void> addMyLocation(LatLng coordinates) async {
400-
if (_controller != null) {
401-
_currentPositionSymbol = await _controller!.addSymbol(
402-
SymbolOptions(
403-
geometry: coordinates,
404-
iconImage: 'my_location',
405-
iconSize: 0.7,
406-
iconColor: '#FF0000',
407-
),
408-
);
401+
try {
402+
if (_controller != null) {
403+
_currentPositionSymbol = await _controller!.addSymbol(
404+
SymbolOptions(
405+
geometry: coordinates,
406+
iconImage: 'my_location',
407+
iconSize: 0.7,
408+
iconColor: '#FF0000',
409+
),
410+
);
411+
}
412+
} catch (err) {
413+
debugPrint(err.toString());
409414
}
410415
}
411416

@@ -505,15 +510,22 @@ class _MapatonMapContentState extends State<MapatonMapContent> {
505510
Future<void> _downloadRegion(MapatonModel mapaton) async {
506511
LatLngBounds bounds = await _controller!.getVisibleRegion();
507512

508-
if (mounted) {
509-
showConfirmationDialog(
510-
context,
511-
text: AppLocalizations.of(context)!.downloadRegion,
512-
acceptButtonText: AppLocalizations.of(context)!.download,
513-
acceptCallback: () {
514-
BlocProvider.of<MapatonBloc>(context).add(DownloadRegion(name: mapaton.uuid, bounds: bounds));
515-
}
516-
);
513+
final connectionAvailable = await Connectivity.connectionAvailable();
514+
if (connectionAvailable) {
515+
if (mounted) {
516+
showConfirmationDialog(
517+
context,
518+
text: AppLocalizations.of(context)!.downloadRegion,
519+
acceptButtonText: AppLocalizations.of(context)!.download,
520+
acceptCallback: () {
521+
BlocProvider.of<MapatonBloc>(context).add(DownloadRegion(name: mapaton.uuid, bounds: bounds));
522+
}
523+
);
524+
}
525+
} else {
526+
if (mounted) {
527+
utils.showSnackBarError(context, AppLocalizations.of(context)!.noConnection);
528+
}
517529
}
518530
}
519531
}

lib/src/ui/pages/update_map_module/bloc/update_map_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class UpdateMapBloc extends Bloc<UpdateMapEvent, UpdateMapState> {
6363
await _updateSentActivities(mapaton);
6464
emit(MapatonSent());
6565
} else {
66-
emit(ErrorSendingMapaton(response.error!));
66+
emit(ErrorSendingMapaton(null));
6767
}
6868
} catch (err) {
6969
emit(ErrorSendingMapaton(err.toString()));

lib/src/ui/pages/update_map_module/bloc/update_map_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SendingMapaton extends UpdateMapState {}
1818
class MapatonSent extends UpdateMapState {}
1919

2020
class ErrorSendingMapaton extends UpdateMapState {
21-
final String error;
21+
final String? error;
2222

2323
ErrorSendingMapaton(this.error);
2424

lib/src/ui/pages/update_map_module/update_map_content.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class UpdateMapContent extends StatelessWidget {
4444
BlocProvider.of<UpdateMapBloc>(context).add(GetMapatonById());
4545
}
4646
if (state is ErrorSendingMapaton) {
47-
utils.showSnackBarError(context, state.error);
47+
utils.showSnackBarError(context, state.error ?? AppLocalizations.of(context)!.errorFound);
4848
}
4949
},
5050
child: _sendButton(context, bloc),

0 commit comments

Comments
 (0)