Skip to content

Commit

Permalink
fix: #2841 - from "AddNewProductPage", no need to be logged in to add…
Browse files Browse the repository at this point in the history
… data (#2844)

* fix: #2841 - from "AddNewProductPage", no need to be logged in to add data

Impacted files:
* `add_basic_details_page.dart`: added parameter `bool isLoggedInMandatory`
* `add_new_product_page.dart`: explicitly calls both pages `AddBasicDetailsPage` and `NutritionPageLoaded` with `isLoggedInMandatory: false`
* `nutrition_page_loaded.dart`: added parameter `bool isLoggedInMandatory`

* Update presubmit.yml

Co-authored-by: Pierre Slamich <pierre.slamich@gmail.com>
  • Loading branch information
monsieurtanuki and teolemon committed Aug 26, 2022
1 parent 45764d9 commit 474b3d8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/presubmit.yml
@@ -1,9 +1,7 @@
name: SmoothApp Pre-Submit Tests

on:
push:
branches-ignore:
- develop
pull_request


env:
Expand Down Expand Up @@ -51,4 +49,4 @@ jobs:
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
fail_ci_if_error: false
Expand Up @@ -11,9 +11,13 @@ import 'package:smooth_app/pages/product/common/product_refresher.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';

class AddBasicDetailsPage extends StatefulWidget {
const AddBasicDetailsPage(this.product);
const AddBasicDetailsPage(
this.product, {
this.isLoggedInMandatory = true,
});

final Product product;
final bool isLoggedInMandatory;

@override
State<AddBasicDetailsPage> createState() => _AddBasicDetailsPageState();
Expand Down Expand Up @@ -135,6 +139,7 @@ class _AddBasicDetailsPageState extends State<AddBasicDetailsPage> {
brands: _brandNameController.text,
barcode: _product.barcode,
),
isLoggedInMandatory: widget.isLoggedInMandatory,
);
if (!savedAndRefreshed) {
return;
Expand Down
Expand Up @@ -277,6 +277,7 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
builder: (BuildContext context) => NutritionPageLoaded(
Product(barcode: widget.barcode),
cache.orderedNutrients,
isLoggedInMandatory: false,
),
fullscreenDialog: true,
),
Expand Down Expand Up @@ -329,6 +330,7 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
MaterialPageRoute<Product>(
builder: (BuildContext context) => AddBasicDetailsPage(
Product(barcode: widget.barcode),
isLoggedInMandatory: false,
),
),
);
Expand Down
Expand Up @@ -22,11 +22,13 @@ import 'package:smooth_app/widgets/smooth_scaffold.dart';
class NutritionPageLoaded extends StatefulWidget {
const NutritionPageLoaded(
this.product,
this.orderedNutrients,
);
this.orderedNutrients, {
this.isLoggedInMandatory = true,
});

final Product product;
final OrderedNutrients orderedNutrients;
final bool isLoggedInMandatory;

@override
State<NutritionPageLoaded> createState() => _NutritionPageLoadedState();
Expand Down Expand Up @@ -528,6 +530,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
context: context,
localDatabase: localDatabase,
product: changedProduct,
isLoggedInMandatory: widget.isLoggedInMandatory,
);
}
}

0 comments on commit 474b3d8

Please sign in to comment.