Skip to content

Commit

Permalink
Merge branch 'master' into #325-remove-template-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Van Zelst committed Oct 17, 2023
2 parents f9f6acb + fb186c0 commit 47c3315
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 59 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ jobs:
- uses: subosito/flutter-action@v2.8.0
with:
channel: 'stable'
- run: flutter packages get
- run: flutter analyze
- run: ./tool/install_fvm.sh
- run: fvm flutter packages get
- run: fvm flutter analyze
5 changes: 3 additions & 2 deletions .github/workflows/rename_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ jobs:
- uses: subosito/flutter-action@v2.8.0
with:
channel: 'stable'
- run: flutter packages get
- run: printf 'Test Project\ndescription\ntest_project\nTestProject\ncom.test.project\nn\ny\n' | flutter pub run ./tool/dart_tool/rename_project.dart
- run: ./tool/install_fvm.sh
- run: fvm flutter packages get
- run: printf 'Test Project\ndescription\ntest_project\nTestProject\ncom.test.project\nn\ny\n' | fvm flutter pub run ./tool/dart_tool/rename_project.dart
2 changes: 1 addition & 1 deletion .github/workflows/strip_boilerplate_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- uses: subosito/flutter-action@v2.8.0
with:
channel: 'stable'
- run: flutter packages get
- run: ./tool/install_fvm.sh
- run: fvm flutter packages get
- run: printf 'yes\n' | fvm flutter pub run ./tool/dart_tool/strip_boilerplate_project.dart
- run: fvm flutter analyze
- run: fvm flutter test --update-goldens test/screen/home/home_screen_test.dart
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/strip_boilerplate_project_remove_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: subosito/flutter-action@v2.8.0
with:
channel: 'stable'
- run: flutter packages get
- run: ./tool/install_fvm.sh
- run: printf 'no\n' | flutter pub run ./tool/dart_tool/strip_boilerplate_project.dart
- run: flutter analyze
- run: fvm flutter packages get
- run: printf 'no\n' | fvm flutter pub run ./tool/dart_tool/strip_boilerplate_project.dart
- run: fvm flutter analyze
61 changes: 33 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,56 +38,55 @@ flutter:

Command to run to update the translations
```
flutter packages pub run icapps_translations
fvm flutter packages pub run icapps_translations
```

## Json Serializable & Kiwi

```
flutter packages pub run build_runner build
flutter packages pub run build_runner build --delete-conflicting-outputs
flutter packages pub run build_runner watch
fvm flutter packages pub run build_runner build --delete-conflicting-outputs
fvm flutter packages pub run build_runner watch
```
## Environments

`--release` is not available for emulators. Performance will be better

### Dev, Debug
```
flutter run --flavor dev -t lib/main.dart
fvm flutter run --flavor dev -t lib/main.dart
flutter run --release --flavor dev -t lib/main.dart
fvm flutter run --release --flavor dev -t lib/main.dart
```

### Dummy

Note: a hot reload is required after launch to use the correct launch file.

```
flutter run --flavor dev -t lib/main_dummy.dart
fvm flutter run --flavor dev -t lib/main_dummy.dart
flutter run --release --flavor dev -t lib/main_dummy.dart
fvm flutter run --release --flavor dev -t lib/main_dummy.dart
```

### Alpha
```
flutter run --flavor alpha -t lib/main_alpha.dart
fvm flutter run --flavor alpha -t lib/main_alpha.dart
flutter run --release --flavor alpha -t lib/main_alpha.dart
fvm flutter run --release --flavor alpha -t lib/main_alpha.dart
```

### Beta
```
flutter run --flavor beta -t lib/main_beta.dart
fvm flutter run --flavor beta -t lib/main_beta.dart
flutter run --release --flavor beta -t lib/main_beta.dart
fvm flutter run --release --flavor beta -t lib/main_beta.dart
```

### Prod, Release
```
flutter run --flavor prod -t lib/main_prod.dart
fvm flutter run --flavor prod -t lib/main_prod.dart
flutter run --release --flavor prod -t lib/main_prod.dart
fvm flutter run --release --flavor prod -t lib/main_prod.dart
```

## Niddler
Expand All @@ -100,7 +99,7 @@ Niddler is also available for Android & Java (OkHttp: https://github.com/icapps/

## Linting

To check your code matches our linting. The analysis_options.yaml contains all our code checks.
To check your code matches our linting. The `analysis_options.yaml` contains all our code checks.

```
flutter analyze
Expand All @@ -111,13 +110,13 @@ flutter analyze
In order to run our test we need to run

```
flutter test
fvm flutter test
```

If we want to update our golden files we need to run

```
flutter test --update-goldens
fvm flutter test --update-goldens
```

## Fastlane
Expand All @@ -135,15 +134,21 @@ This script will run a dart script. The dart script itself will ask you some inp

#### Add provisioning files

```
place the provisioning profiles -> provision_profile/**
naming should be the same as provided in the iOS/Configuration/** files (underscore will be replaced with a space in the configuration files)
```
Add the provisioning profiles in the ios/provisioning/ folder. The naming of the files should be the same as provided in the `ios/Configuration/{flavor}.xcconfig` files (underscore will be replaced with a space in the configuration files)

#### Firebase

To setup firebase you will need to create a new firebase project with 8 new apps, 1 for each flavor on both iOS and Android.

When creating the iOS apps on firebase you will be able to download a `GoogleService-Info.plist` file which you will need to rename according to the flavor you just created an app for e.g.: You just created the iOS App for the Dev flavor so your file should be named `GoogleService-Info-dev.plist`.
Each `.plist` file you download from firebase needs to be placed in the ios/Configuration/GoogleService/ folder. Whenever the project is run with a different flavor from the currently active flavor, it will automatically copy the correct `GoogleService-Info-{flavor}.plist` file into the ios/Runner/ folder.

When creating the Android apps you will be able to download a `google-services.json` file, you only need to download this file once at the end of the last Android app setup on firebase. This `.json` file contains all the configurations for the 4 Android apps which you just created. Add the `.json` file in the android/app/src/ folder.

#### Languages

```
Configure the required languages in xCode
Configure the required languages in Xcode
```

### icapps Translations
Expand All @@ -157,34 +162,34 @@ Update the translations.py file (edit the todos)
Obfuscation is enabled by default when using fastlane for building. The symbol files are stored in
`./build/debug-info/#{options[:flavor]}`

**Important**: Add the following regex to jenking configuration to also archive the symbol files
**Important**: Add the following regex to jenkins configuration to also archive the symbol files
```
**/*.symbols
```

### Icons

Replace the files in assets_launcher_icons/
Replace the files in the `assets_launcher_icons/**` folder.

You can also change the adaptive_icon_background in the flutter_launcher_icons-{flavor}.yaml (currently "#CB2E63") (only available for Android 8.0 devices and above)
You can also change the adaptive_icon_background in the `flutter_launcher_icons-{flavor}.yaml` (currently "#CB2E63") (only available for Android 8.0 devices and above)

After this, run the following command

```
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-dev.yaml
fvm flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-dev.yaml
```

### Common issues

```
No Flavor provided
No flavor provided
```

Add a flavor to your configuration. Extra info can be found in this issue -> https://github.com/icapps/flutter-template/issues/3

### Questions?

For question contact Koen Van Looveren
For question contact William Verhaeghe

### Finish

Expand Down
4 changes: 2 additions & 2 deletions lib/model/exceptions/bad_request_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BadRequestError extends NetworkError {
static const statusCode = HttpStatus.badRequest;

BadRequestError(
super.dioError, {
super.dioException, {
super.statusCodeValue,
});

Expand All @@ -25,7 +25,7 @@ class BadRequestError extends NetworkError {
final dynamic data = err.response?.data;
if (data is! Map) return BadRequestError(err);
if (!data.containsKey('code')) return BadRequestError(err);
final code = data['code'] as String;
final code = data['code'] as String?;
switch (code) {
default:
return BadRequestError(err);
Expand Down
4 changes: 2 additions & 2 deletions lib/model/exceptions/forbidden_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ForbiddenError extends NetworkError {
static const statusCode = HttpStatus.forbidden;

ForbiddenError(
super.dioError, {
super.dioException, {
super.statusCodeValue,
});

Expand All @@ -25,7 +25,7 @@ class ForbiddenError extends NetworkError {
final dynamic data = err.response?.data;
if (data is! Map) return ForbiddenError(err);
if (!data.containsKey('code')) return ForbiddenError(err);
final code = data['code'] as String;
final code = data['code'] as String?;
switch (code) {
default:
return ForbiddenError(err);
Expand Down
7 changes: 2 additions & 5 deletions lib/model/exceptions/general_error.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import 'package:flutter_template/util/locale/localization_keys.dart';
import 'package:icapps_architecture/icapps_architecture.dart';

class GeneralNetworkError extends NetworkError {
GeneralNetworkError(super.dioError);
class GeneralError with LocalizedError {
GeneralError() : super();

@override
String getLocalizedKey() => LocalizationKeys.errorGeneral;

@override
String? get getErrorCode => null;
}
7 changes: 5 additions & 2 deletions lib/model/exceptions/general_network_error.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter_template/util/locale/localization_keys.dart';
import 'package:icapps_architecture/icapps_architecture.dart';

class GeneralError with LocalizedError {
GeneralError() : super();
class GeneralNetworkError extends NetworkError {
GeneralNetworkError(super.dioException);

@override
String getLocalizedKey() => LocalizationKeys.errorGeneral;

@override
String? get getErrorCode => null;
}
2 changes: 1 addition & 1 deletion lib/model/exceptions/internal_server_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class InternalServerError extends NetworkError {
static const statusCode = HttpStatus.internalServerError;

InternalServerError(
super.dioError, {
super.dioException, {
super.statusCodeValue,
});

Expand Down
2 changes: 1 addition & 1 deletion lib/model/exceptions/no_internet_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_template/util/locale/localization_keys.dart';
import 'package:icapps_architecture/icapps_architecture.dart';

class NoInternetError extends NetworkError {
NoInternetError(super.dioError);
NoInternetError(super.dioException);

@override
String getLocalizedKey() => LocalizationKeys.errorNoNetwork;
Expand Down
14 changes: 13 additions & 1 deletion lib/model/exceptions/un_authorized_error.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter_template/util/locale/localization_keys.dart';
import 'package:icapps_architecture/icapps_architecture.dart';

class UnAuthorizedError extends NetworkError {
static const statusCode = HttpStatus.unauthorized;

UnAuthorizedError(
super.dioError, {
super.dioException, {
super.statusCodeValue,
});

Expand All @@ -19,4 +20,15 @@ class UnAuthorizedError extends NetworkError {
if (statusCodeValue == null) return '$statusCode';
return '$statusCode [$statusCodeValue]';
}

static NetworkError parseError(DioException err) {
final dynamic data = err.response?.data;
if (data is! Map) return UnAuthorizedError(err);
if (!data.containsKey('code')) return UnAuthorizedError(err);
final code = data['code'] as String?;
switch (code) {
default:
return UnAuthorizedError(err);
}
}
}
4 changes: 2 additions & 2 deletions lib/util/interceptor/network_error_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dio/dio.dart';
import 'package:flutter_template/model/exceptions/bad_request_error.dart';
import 'package:flutter_template/model/exceptions/code_error.dart';
import 'package:flutter_template/model/exceptions/forbidden_error.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:flutter_template/model/exceptions/internal_server_error.dart';
import 'package:flutter_template/model/exceptions/no_internet_error.dart';
import 'package:flutter_template/model/exceptions/un_authorized_error.dart';
Expand Down Expand Up @@ -31,7 +31,7 @@ class NetworkErrorInterceptor extends SimpleInterceptor {
final statusCode = error.response?.statusCode;
switch (statusCode) {
case UnAuthorizedError.statusCode:
return UnAuthorizedError(error);
return UnAuthorizedError.parseError(error);
case BadRequestError.statusCode:
return BadRequestError.parseError(error);
case ForbiddenError.statusCode:
Expand Down
2 changes: 1 addition & 1 deletion lib/util/interceptor/network_log_interceptor.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:icapps_architecture/icapps_architecture.dart';
import 'package:injectable/injectable.dart';

Expand Down
2 changes: 1 addition & 1 deletion test/repository/refresh/refresh_repository_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:dio/dio.dart';
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/model/exceptions/un_authorized_error.dart';
import 'package:flutter_template/repository/refresh/refresh_repository.dart';
import 'package:flutter_template/repository/secure_storage/auth/auth_storage.dart';
Expand Down
2 changes: 1 addition & 1 deletion test/util/interceptor/network_error_interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_template/model/exceptions/bad_request_error.dart';
import 'package:flutter_template/model/exceptions/code_error.dart';
import 'package:flutter_template/model/exceptions/forbidden_error.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:flutter_template/model/exceptions/internal_server_error.dart';
import 'package:flutter_template/model/exceptions/un_authorized_error.dart';
import 'package:flutter_template/util/env/flavor_config.dart';
Expand Down
2 changes: 1 addition & 1 deletion test/viewmodel/login/login_viewmodel_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/navigator/main_navigator.dart';
import 'package:flutter_template/navigator/onboarding_navigator.dart';
import 'package:flutter_template/repository/login/login_repository.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter_template/model/exceptions/general_network_error.dart';
import 'package:flutter_template/model/exceptions/general_error.dart';
import 'package:flutter_template/model/webservice/todo/todo.dart';
import 'package:flutter_template/navigator/main_navigator.dart';
import 'package:flutter_template/repository/todo/todo_repository.dart';
Expand Down
2 changes: 1 addition & 1 deletion tool/rename_project.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

flutter pub run tool/dart_tool/rename_project.dart
fvm flutter pub run tool/dart_tool/rename_project.dart
2 changes: 1 addition & 1 deletion tool/strip_boilerplate_project.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

flutter pub run tool/dart_tool/strip_boilerplate_project.dart
fvm flutter pub run tool/dart_tool/strip_boilerplate_project.dart

0 comments on commit 47c3315

Please sign in to comment.