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

Feature/map-and-localization #7

Merged
merged 17 commits into from
Oct 1, 2023
Merged
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
6 changes: 0 additions & 6 deletions .env/dev.json

This file was deleted.

6 changes: 0 additions & 6 deletions .env/prod.json

This file was deleted.

2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.13.1",
"flutterSdkVersion": "3.13.6",
"flavors": {}
}
12 changes: 9 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Configure enviroment
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v1
- name: Download flutter
uses: subosito/flutter-action@v2
Expand All @@ -17,6 +17,12 @@ jobs:
cache: true
cache-key: 'flutter-:os:-:version:'
cache-path: '${{ runner.tool_cache }}/flutter/:os:-:version:'
- name: Retrieve the secret and decode it to a file
env:
ENV_PROD_BASE64: ${{ secrets.ENV_PROD_BASE64 }}
run: |
mkdir .env
echo $ENV_PROD_BASE64 | base64 -di > .env/prod.json
- name: Setup project
run: sh setup.sh
- name: Verify formated files
Expand All @@ -38,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Configure enviroment
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: web-app
Expand All @@ -62,7 +68,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Configure enviroment
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: web-app
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
migrate_working_dir/
.fvm/flutter_sdk
.firebase/
.env/

# IntelliJ related
*.iml
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ A dog grooming website created for Peluquería canina Mimos.

The application has three environments and each one has its own configuration file:

- dev: `.env/dev.dart`
- prod: `.env/prod.dart`
- dev: `.env/dev.json`
- prod: `.env/prod.json`

If you want fork this repository, you have to create your own configuration files and replace the values with your own. Example

```json
{
"PACKAGE_NAME": "com.example.dev",
"APP_NAME": "App name Dev",
"ENVIRONMENT": "dev",
"GOOGLE_MAPS_API_KEY": "YOUR_API_KEY"
}
```

## Setup

You can use the following commands to setup the project fast:

- Flutter (recommended): `sh setup.sh`
- Flutter: `sh setup.sh`
- FVM: `sh setup.sh fvm`

### Generate code
Expand Down
1 change: 1 addition & 0 deletions assets/icons/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/tiktok.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/whatsapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@
"slogan": "We take care of your pet. As if it were ours",
"appointment": "Make an appointment",
"semantic_logo": "Logo of pet grooming salon Mimos",
"contact_number": "123456798",
"contact_number_tooltip": "Open dialer and call to {}",
"whatsapp_tooltip": "Open whatsapp and send a message to {}"
"whatsapp_tooltip": "Open whatsapp and send a message to {}",
"where": {
"title": "Localization",
"semantic_description": "Map of localization of pet grooming salon Mimos: Street Isaac Peral nº5, floor right, 4930, Quart de Poblet, Valencia"
},
"when": {
"title": "Opening hours",
"schedule": "Monday to Friday from 9:30 AM to 2:30 PM"
},
"contact": {
"title": "Contact",
"phone": "Phone: {}",
"email": "Email: {}",
"social_networks": "Social networks: "
}
},
"privacy_policy": {
"title": "Privacy policy",
Expand Down Expand Up @@ -68,6 +81,7 @@
"unauthorized": "No autorizado",
"forbidden": "No permitido",
"expired_session": "Sesión expirada",
"unknown": "Error desconocido"
"unknown": "Error desconocido",
"no_navigation": "The page you are trying to access does not exist. Please return to the home page."
}
}
20 changes: 17 additions & 3 deletions assets/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@
"slogan": "La peluquería que mima a tus mascotas. Donde cuidamos a tu peludet",
"appointment": "Marca tu cita",
"semantic_logo": "Logo de la peluquería canina Mimos",
"contact_number": "123456798",
"contact_number_tooltip": "Abrir marcador y llamar a {}",
"whatsapp_tooltip": "Abrir WhatsApp y enviar mensaje a {}"
"whatsapp_tooltip": "Abrir WhatsApp y enviar mensaje a {}",
"where": {
"title": "Localización",
"semantic_description": "Mapa de la localización de la peluquería canina Mimos: Calle Isaac Peral nº5, bajo derecha, 4930, Quart de Poblet, Valencia"
},
"when": {
"title": "Horario",
"schedule": "De lunes a viernes de 9:30 a 14:30"
},
"contact": {
"title": "Contacto",
"phone": "Teléfono: {}",
"email": "Correo electrónico: {}",
"social_networks": "Redes sociales: "
}
},
"privacy_policy": {
"title": "Política de privacidad",
Expand Down Expand Up @@ -68,6 +81,7 @@
"unauthorized": "No autorizado",
"forbidden": "No permitido",
"expired_session": "Sesión expirada",
"unknown": "Error desconocido"
"unknown": "Error desconocido",
"no_navigation": "La página que está intentando acceder no existe. Por favor, vuelva a la página de inicio."
}
}
20 changes: 17 additions & 3 deletions assets/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@
"slogan": "La peluquería que mima a tus mascotas. Donde cuidamos a tu peludet",
"appointment": "Marque um horário",
"semantic_logo": "Logo da peluquería canina Mimos",
"contact_number": "123456798",
"contact_number_tooltip": "Abrir discador e ligar a {}",
"whatsapp_tooltip": "Abrir WhatsApp e enviar mensagem a {}"
"whatsapp_tooltip": "Abrir WhatsApp e enviar mensagem a {}",
"where": {
"title": "Localizaçao",
"semantic_description": "Mapa da localizaçao da peluquería canina Mimos: Rua Isaac Peral nº5, terreo direita, 4930, Quart de Poblet, Valência"
},
"when": {
"title": "Horário",
"schedule": "De segunda a sexta de 9:30 a 14:30"
},
"contact": {
"title": "Contato",
"phone": "Telefone: {}",
"email": "Email: {}",
"social_networks": "Redes sociais: "
}
},
"privacy_policy": {
"title": "Politica de privacidade",
Expand Down Expand Up @@ -69,6 +82,7 @@
"unauthorized": "No autorizado",
"forbidden": "No permitido",
"expired_session": "Sesión expirada",
"unknown": "Error desconocido"
"unknown": "Error desconocido",
"no_navigation": "A página que você está tentando acessar não existe. Volte para a página inicial."
}
}
2 changes: 1 addition & 1 deletion lib/data/datasources/local/default_local_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DefaultLocalDataSource implements LocalDataSource {
try {
return Future.value(Right(env));
} catch (e) {
return Future.value(Left(UnknownError()));
return Future.value(const Left(UnknownError()));
}
}
}
18 changes: 13 additions & 5 deletions lib/data/datasources/remote/default_remote_datasource.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import 'package:dog_gromming_website/data/datasources/remote/remote_datasource.dart';
import 'package:dog_gromming_website/data/services/api_service.dart';
import 'package:dog_gromming_website/di/di.dart';
import 'package:dog_gromming_website/domain/models/errors.dart';
import 'package:dog_gromming_website/env/constants.dart';
import 'package:dog_gromming_website/env/env.dart';
import 'package:either_dart/either.dart';
import 'package:injectable/injectable.dart';

@Injectable(as: RemoteDatasource)
class DefaultRemoteDatasource implements RemoteDatasource {
final ApiService _apiService;
final _env = getIt<Env>();
final Env _env;

DefaultRemoteDatasource(this._apiService);
const DefaultRemoteDatasource(this._apiService, this._env);

@override
Future<Either<MainError, List<String>>> getExample() async {
final uri = Uri.parse(_env.urlRestService);
Future<Either<MainError, List<String>>> getPlaceDetails() async {
const mapsUrl = 'https://maps.googleapis.com/maps/api/place/details/json';

final uri = Uri.parse(mapsUrl)
..queryParameters.addAll({
'place_id': Constants.mapPlaceId,
'fields':
' current_opening_hours,opening_hours,secondary_opening_hours',
'key': _env.googleMapsApiKey,
});

final result = await _apiService.get<Map<String, dynamic>>(uri);
return result.either<MainError, List<String>>(
Expand Down
2 changes: 1 addition & 1 deletion lib/data/datasources/remote/remote_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import 'package:dog_gromming_website/domain/models/errors.dart';
import 'package:either_dart/either.dart';

abstract interface class RemoteDatasource {
Future<Either<MainError, List<String>>> getExample();
Future<Either<MainError, List<String>>> getPlaceDetails();
}
2 changes: 1 addition & 1 deletion lib/data/transformers/error_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MainError errorsHandler(DioException error) {
message: apiErrorMessage,
);
default:
return UnknownError();
return const UnknownError();
}
}

Expand Down
6 changes: 4 additions & 2 deletions lib/di/di.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions lib/domain/models/errors.dart
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
sealed class MainError {}
sealed class MainError {
const MainError();
}

class NoInternet extends MainError {}
class NoInternet extends MainError {
const NoInternet();
}

class UnknownError extends MainError {}
class UnknownError extends MainError {
const UnknownError();
}

sealed class ApiError extends MainError {
final String message;

ApiError({this.message = ''});
const ApiError({this.message = ''});
}

class BadRequestError extends ApiError {
BadRequestError({super.message = ''});
const BadRequestError({super.message = ''});
}

class ForbiddenError extends ApiError {
ForbiddenError({super.message = ''});
const ForbiddenError({super.message = ''});
}

class NotFoundError extends ApiError {
NotFoundError({super.message = ''});
const NotFoundError({super.message = ''});
}

class UnauthError extends ApiError {
UnauthError({super.message = ''});
const UnauthError({super.message = ''});
}

class ExpiredSessionError extends ApiError {
ExpiredSessionError({super.message = ''});
const ExpiredSessionError({super.message = ''});
}

class ServerError extends ApiError {
ServerError({super.message = ''});
const ServerError({super.message = ''});
}
7 changes: 6 additions & 1 deletion lib/env/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class Constants {
'https://www.facebook.com/people/Peluquer%C3%ADa-canina-Mimos/61550495769972/';
static const String tikTokProfile =
'https://www.tiktok.com/@peluqueriacaninamimos';
static const String phone = '+34666666666';
static const String shortPhone = '654477396';
static const String phone = '+34$shortPhone';
static const String email = 'contacto@peluqueriacaninamimos.com';
static const String privacyPolicy = 'assets/html/privacy-policy.html';
static const String maps =
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3079.483608944495!2d-0.4490531227623305!3d39.48099321205735!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd604fefe08b5739%3A0xa01d21f54d623da1!2sPeluqueria%20Canina%20Mimos!5e0!3m2!1sen!2ses!4v1695489287218!5m2!1sen!2ses';
static const String mapPlaceId = 'ChIJOVeL4O9PYA0RoT1iTfUhHaA';
}
7 changes: 4 additions & 3 deletions lib/env/env.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
abstract class Env {
final String urlRestService;
final String googleMapsApiKey;
final String packageName;
final String appName;

const Env({
required this.urlRestService,
required this.googleMapsApiKey,
required this.packageName,
required this.appName,
});
Expand All @@ -15,7 +15,8 @@ class EnvConfig implements Env {
String get packageName => const String.fromEnvironment('PACKAGE_NAME');

@override
String get urlRestService => const String.fromEnvironment('URL_REST_SERVICE');
String get googleMapsApiKey =>
const String.fromEnvironment('GOOGLE_MAPS_API_KEY');

@override
String get appName => const String.fromEnvironment('APP_NAME');
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/navigation/main_navigator.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dog_gromming_website/ui/navigation/menu_navigation.dart';
import 'package:dog_gromming_website/ui/navigation/routes.dart';
import 'package:dog_gromming_website/ui/widgets/screens/announcement/announcement_screen.dart';
import 'package:dog_gromming_website/ui/widgets/screens/error/no_navigation_error_screen.dart';
import 'package:dog_gromming_website/ui/widgets/screens/privacy-plicy/privacy_policy.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
Expand All @@ -17,6 +18,9 @@ class MainNavigator {
FlutterNativeSplash.remove();
return null;
},
errorBuilder: (context, state) {
return NoNavigationErrorScreen(path: state.fullPath ?? '');
},
routes: <RouteBase>[
GoRoute(
path: Routes.announcement,
Expand Down
Loading