Skip to content

Commit

Permalink
Add the bug report button to the product info page near the barcode. (#…
Browse files Browse the repository at this point in the history
…14)

* Increment version to 0.1.0(10)

Signed-off-by: Dmytro Turskyi <[email protected]>

* Add commit activity in README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Fixed commit activity in README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Changed link to successful release Android build in README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Renamed "core" to "domain" and "components" to "core".

Signed-off-by: Dmytro Turskyi <[email protected]>

* fixed the path to the interface adapters layer in ci

Signed-off-by: Dmytro Turskyi <[email protected]>

* refactoring

Signed-off-by: Dmytro Turskyi <[email protected]>

* refactoring

Signed-off-by: Dmytro Turskyi <[email protected]>

* refactoring and adding more tests to code quality ci

Signed-off-by: Dmytro Turskyi <[email protected]>

* Add mockito.

Signed-off-by: Dmytro Turskyi <[email protected]>

* add timeout 40 seconds to remote data source test

Signed-off-by: Dmytro Turskyi <[email protected]>

* added tests

Signed-off-by: Dmytro Turskyi <[email protected]>

* lower coverage expectation

Signed-off-by: Dmytro Turskyi <[email protected]>

* lower coverage expectation

Signed-off-by: Dmytro Turskyi <[email protected]>

* Update README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Update README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Update README.md.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Renamed "core" to "components" to be even more closely to clean architecture.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Add codecov coverage.

Signed-off-by: Dmytro Turskyi <[email protected]>

* Updated dependencies in pubspec.yaml for flutter_bloc, dart_openai, dio, envied, feedback, flutter_bloc, logger, openfoodfacts, package_info_plus, shared_preferences, build_runner, envied_generator, flutter_lints, and package_info_plus. Also added error handling in the Resources class in components/interface_adapters.

Signed-off-by: Dmytro Turskyi <[email protected]>

* feat(ui): 🖥️ Update product info body method signature

- Updated the method signature of `_sendFeedback` in the `ProductInfoBody` widget to accept named parameters for `feedback` and `packageInfo`.
- This change enhances readability and maintainability of the code.

authored-by: Dmytro <[email protected]>
Signed-off-by: Dmytro Turskyi <[email protected]>

* Add bug report button.
:recycle: Update dependencies versions in android/app/build.gradle and pubspec.lock, refactor code in components/interface_adapters

In this commit, I updated the Firebase dependencies versions in android/app/build.gradle and pubspec.lock to the latest ones. Additionally, I refactored the code in components/interface_adapters to improve readability and maintainability.

Signed-off-by: Dmytro Turskyi <[email protected]>

---------

Signed-off-by: Dmytro Turskyi <[email protected]>
  • Loading branch information
Turskyi authored Apr 29, 2024
1 parent b2aa77c commit 0d64029
Show file tree
Hide file tree
Showing 88 changed files with 2,508 additions and 622 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/code-quality-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Code Quality
on: [ push ]

jobs:
check_lint_errors:
check-code-quality-and-tests:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -32,10 +32,22 @@ jobs:
- name: Get packages
run: flutter pub get

- name: Check format errors
run: dart format --set-exit-if-changed .

- name: Check lint errors
run: flutter analyze .

- name: Run tests with coverage and random order
run: flutter test --coverage --test-randomize-ordering-seed random

- name: Very Good Coverage
uses: VeryGoodOpenSource/[email protected]
with:
min_coverage: 35
min_coverage: 33.9

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Turskyi/ethical_scanner
338 changes: 193 additions & 145 deletions README.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ analyzer:

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# section below to disable rules from the
# `package: flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
Expand All @@ -27,7 +28,7 @@ linter:
rules:
# ------ Enabling individual rules -----#
# --- #
# These rules here are good but too #
# These rules here are good but too ----#
# opinionated to enable them by default.#
# ------------------------------------- #
require_trailing_commas: true
Expand Down
3 changes: 3 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ GeneratedPluginRegistrant.java
key.properties
**/*.keystore
**/*.jks
/keystore
/keystore/
/app/google-services.json
17 changes: 15 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def SIGNING_KEY_RELEASE_KEY_PASSWORD = keyProperties.getProperty('SIGNING_KEY_RE
android {
//noinspection GroovyAssignabilityCheck
namespace rootProject.application_id
//TODO: change to dynamic "flutter.compileSdkVersion" version, when the error is gone.
compileSdk 34
//TODO: change to dynamic "flutter.ndkVersion" version, when the error is gone.
ndkVersion "25.1.8937393"

compileOptions {
Expand All @@ -65,6 +67,7 @@ android {
applicationId rootProject.application_id
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
//TODO: change to dynamic "flutter.minSdkVersion" value, when it will be possible.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
Expand All @@ -73,10 +76,15 @@ android {
signingConfigs {
production {
// FCI_BUILD_ID is exported by Codemagic
//noinspection GroovyAssignabilityCheck
if (System.getenv()["FCI_BUILD_ID"] != null) {
//noinspection GroovyAssignabilityCheck
storeFile file(System.getenv()["CM_KEYSTORE_PATH"])
//noinspection GroovyAssignabilityCheck
storePassword System.getenv()["CM_KEYSTORE_PASSWORD"]
//noinspection GroovyAssignabilityCheck
keyAlias System.getenv()["CM_KEY_ALIAS"]
//noinspection GroovyAssignabilityCheck
keyPassword System.getenv()["CM_KEY_PASSWORD"]
} else {
storeFile file(SIGNING_KEY_RELEASE_PATH)
Expand All @@ -87,10 +95,15 @@ android {
}
dev {
// FCI_BUILD_ID is exported by Codemagic
//noinspection GroovyAssignabilityCheck
if (System.getenv()["FCI_BUILD_ID"] != null) {
//noinspection GroovyAssignabilityCheck
storeFile file(System.getenv()["CM_KEYSTORE_PATH"])
//noinspection GroovyAssignabilityCheck
storePassword System.getenv()["CM_KEYSTORE_PASSWORD"]
//noinspection GroovyAssignabilityCheck
keyAlias System.getenv()["CM_KEY_ALIAS"]
//noinspection GroovyAssignabilityCheck
keyPassword System.getenv()["CM_KEY_PASSWORD"]
} else {
storeFile file(SIGNING_KEY_DEBUG_PATH)
Expand Down Expand Up @@ -118,6 +131,6 @@ flutter {
}

dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.6.2'
implementation 'com.google.firebase:firebase-analytics:21.5.1'
implementation 'com.google.firebase:firebase-crashlytics:18.6.4'
implementation 'com.google.firebase:firebase-analytics:21.6.2'
}
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.turskyi.ethical_scanner"
android:versionCode="9"
android:versionName="0.0.9">
android:versionCode="10"
android:versionName="0.1.0">

<queries>
<intent>
Expand Down
3 changes: 0 additions & 3 deletions components/core/entities/example/entities_example.dart

This file was deleted.

3 changes: 0 additions & 3 deletions components/core/use_cases/example/use_cases_example.dart

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions components/domain/entities/example/entities_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/// Critical business data.
library entities;

export 'src/barcode/barcode.dart';
export 'src/enums/language.dart';
export 'src/enums/product_info_type.dart';
export 'src/enums/vegan.dart';
export 'src/enums/vegetarian.dart';
export 'src/exception/bad_request_error.dart';
export 'src/exception/internal_server_error.dart';
export 'src/exception/not_found_exception.dart';
export 'src/exceptions/bad_request_error.dart';
export 'src/exceptions/internal_server_error.dart';
export 'src/exceptions/not_found_exception.dart';
export 'src/localized_code/localized_code.dart';
export 'src/logging_interceptor/logging_interceptor.dart';
export 'src/product/product_info.dart';
export 'src/product/product_photo.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:entities/src/enums/language.dart';

class Barcode {
const Barcode({
class LocalizedCode {
const LocalizedCode({
required this.code,
this.language = Language.en,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:entities/src/terrorism_sponsor/terrorism_sponsor.dart';

abstract class RestClient {
abstract interface class RestClient {
const RestClient();

Future<List<TerrorismSponsor>> getTerrorismSponsors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ abstract class TerrorismSponsor {
}

extension TerrorismSponsorList on List<TerrorismSponsor> {
bool sponsoredBy(ProductInfo product) {
return _isSponsoredByOtherRussiaSponsors(product) ||
_isSponsoredByAnyTerrorismSponsor(product);
}
bool sponsoredBy(ProductInfo product) =>
_isSponsoredByOtherRussiaSponsors(product) ||
_isSponsoredByAnyTerrorismSponsor(product);

bool _isSponsoredByOtherRussiaSponsors(ProductInfo product) {
return _otherRussiaSponsors.contains(product.brand.toLowerCase());
}
bool _isSponsoredByOtherRussiaSponsors(ProductInfo product) =>
_otherTerrorismSponsors.contains(product.brand.toLowerCase());

bool _isSponsoredByAnyTerrorismSponsor(ProductInfo product) {
return any(
Expand All @@ -48,22 +46,20 @@ extension TerrorismSponsorList on List<TerrorismSponsor> {
bool _isSponsorNameNotEmptyAndMatchesProductBrandOrName(
TerrorismSponsor terrorismSponsor,
ProductInfo product,
) {
return terrorismSponsor.name.isNotEmpty &&
(product.brand.toLowerCase().trim() ==
terrorismSponsor.name.toLowerCase().trim() ||
product.name.toLowerCase().trim() ==
terrorismSponsor.name.toLowerCase().trim());
}
) =>
terrorismSponsor.name.isNotEmpty &&
(product.brand.toLowerCase().trim() ==
terrorismSponsor.name.toLowerCase().trim() ||
product.name.toLowerCase().trim() ==
terrorismSponsor.name.toLowerCase().trim());

bool _isSponsorBrandsNotEmptyAndContainsProductBrand(
TerrorismSponsor terrorismSponsor,
ProductInfo product,
) {
return terrorismSponsor.brands.isNotEmpty &&
product.brand.isNotEmpty &&
_doesSponsorBrandsContainProductBrand(terrorismSponsor, product);
}
) =>
terrorismSponsor.brands.isNotEmpty &&
product.brand.isNotEmpty &&
_doesSponsorBrandsContainProductBrand(terrorismSponsor, product);

bool _doesSponsorBrandsContainProductBrand(
TerrorismSponsor terrorismSponsor,
Expand All @@ -73,14 +69,13 @@ extension TerrorismSponsorList on List<TerrorismSponsor> {
return lowerCaseBrands.contains(product.brand.toLowerCase());
}

List<String> _getLowerCaseBrands(TerrorismSponsor terrorismSponsor) {
return terrorismSponsor.brands
.split(', ')
.map((String brand) => brand.toLowerCase())
.toList();
}
List<String> _getLowerCaseBrands(TerrorismSponsor terrorismSponsor) =>
terrorismSponsor.brands
.split(', ')
.map((String brand) => brand.toLowerCase())
.toList();

List<String> get _otherRussiaSponsors => <String>[
List<String> get _otherTerrorismSponsors => <String>[
'twix',
'quaker',
'nestlé',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: entities
description: An Entity is an object within our computer system that embodies a small set of
critical business rules operating on Critical Business Data.
version: 1.0.0
repository: https://github.com/Turskyi/ethical_scanner/tree/master/components/core/entities
repository: https://github.com/Turskyi/ethical_scanner/tree/master/components/domain/entities

environment:
sdk: '>=3.2.3 <4.0.0'

dev_dependencies:
lints: ^3.0.0
test: ^1.25.2
test: ^1.25.4
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions components/domain/use_cases/example/use_cases_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:entities/entities.dart';
abstract interface class ProductInfoGateway {
const ProductInfoGateway();

Future<ProductInfo> getProductInfoAsFuture(Barcode barcode);
Future<ProductInfo> getProductInfoAsFuture(LocalizedCode barcode);

Future<void> addProduct(ProductInfo productInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AddIngredientsUseCase implements UseCase<Future<void>, ProductPhoto> {

@override
Future<void> call([ProductPhoto productPhoto = const ProductPhoto()]) {
if(productPhoto.info.name.isEmpty){
if (productPhoto.info.name.isEmpty) {
return _productInfoGateway.addProduct(productPhoto.info).whenComplete(() {
_productInfoGateway.addIngredients(productPhoto);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ class GetPrecipitationStateUseCase implements UseCase<bool, Null> {
final SettingsGateway _settingsGateway;

@override
bool call([_]) =>
_settingsGateway.getPrecipitationState();
bool call([_]) => _settingsGateway.getPrecipitationState();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'package:entities/entities.dart';
import 'package:use_cases/use_cases.dart';

class GetProductInfoUseCase implements UseCase<Future<ProductInfo>, Barcode> {
class GetProductInfoUseCase
implements UseCase<Future<ProductInfo>, LocalizedCode> {
const GetProductInfoUseCase(this._productInfoGateway);

final ProductInfoGateway _productInfoGateway;

@override
Future<ProductInfo> call([Barcode barcode = const Barcode(code: '')]) =>
Future<ProductInfo> call([
LocalizedCode barcode = const LocalizedCode(code: ''),
]) =>
_productInfoGateway.getProductInfoAsFuture(barcode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 0.0.1
# This prevents the package from being accidentally published to pub.dev using pub publish. This is
# preferred for private packages.
publish_to: none
repository: https://github.com/Turskyi/ethical_scanner/tree/master/components/core/use_cases
repository: https://github.com/Turskyi/ethical_scanner/tree/master/components/domain/use_cases

environment:
sdk: '>=3.2.3 <4.0.0'
Expand All @@ -17,4 +17,4 @@ dependencies:

dev_dependencies:
lints: ^3.0.0
test: ^1.25.2
test: ^1.25.4
Empty file.
1 change: 0 additions & 1 deletion components/interface_adapters/lib/interface_adapters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export 'src/env/env.dart';
export 'src/gateways/product_info_gateway_impl.dart';
export 'src/gateways/settings_gateway_impl.dart';
export 'src/ui/app/app.dart';
export 'src/ui/modules/home/home_event.dart';
export 'src/ui/modules/home/home_presenter.dart';
export 'src/ui/modules/home/view/home_view.dart';
export 'src/ui/modules/photo/photo_presenter.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import 'package:entities/entities.dart';

abstract interface class RemoteDataSource {
const RemoteDataSource();
Future<ProductInfo> getProductInfoAsFuture(Barcode barcode);

Future<String> getIngredientsText(Barcode barcode);
Future<ProductInfo> getProductInfoAsFuture(LocalizedCode barcode);

Future<String> getIngredientsText(LocalizedCode barcode);

Future<String> getCountryFromAiAsFuture(String barcode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProductInfoGatewayImpl implements ProductInfoGateway {
final LocalDataSource _localDataSource;

@override
Future<ProductInfo> getProductInfoAsFuture(Barcode input) {
Future<ProductInfo> getProductInfoAsFuture(LocalizedCode input) {
return _remoteDataSource
.getProductInfoAsFuture(input)
.onError((Object? error, StackTrace stackTrace) {
Expand Down
4 changes: 2 additions & 2 deletions components/interface_adapters/lib/src/ui/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ abstract interface class App extends StatelessWidget {
const App({super.key});

factory App.factory(RouteFactory routeFactory) => EthicalScannerApp(
routeFactory: routeFactory,
);
routeFactory: routeFactory,
);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:entities/entities.dart';
part of 'home_presenter.dart';

sealed class HomeEvent {
@immutable
abstract class HomeEvent {
const HomeEvent();
}

class LoadHomeEvent extends HomeEvent{
class LoadHomeEvent extends HomeEvent {
const LoadHomeEvent();
}

Expand Down
Loading

0 comments on commit 0d64029

Please sign in to comment.