Skip to content

fix: Removed the option to add an item through barcode from Add a Price page #6525

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class UserPreferencesPrices extends AbstractUserPreferences {
() async => ProductPriceAddPage.showProductPage(
context: context,
proofType: ProofType.receipt,
multiProduct: true,
),
Icons.add_shopping_cart,
),
Expand All @@ -83,6 +84,7 @@ class UserPreferencesPrices extends AbstractUserPreferences {
() async => ProductPriceAddPage.showProductPage(
context: context,
proofType: ProofType.priceTag,
multiProduct: true,
),
Icons.add_shopping_cart,
),
Expand Down
10 changes: 10 additions & 0 deletions packages/smooth_app/lib/pages/prices/price_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class PriceModel with ChangeNotifier {
required final List<OsmLocation>? locations,
required final Currency currency,
final PriceMetaProduct? initialProduct,
final bool? multipleProducts,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final bool? multipleProducts,
required this.multipleProducts,

}) : _proof = null,
existingPrices = null,
_proofType = proofType,
_date = DateTime.now(),
_currency = currency,
_locations = locations,
_multipleProducts = multipleProducts ?? false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_multipleProducts = multipleProducts ?? false,

_priceAmountModels = <PriceAmountModel>[
if (initialProduct != null) PriceAmountModel(product: initialProduct),
];
Expand All @@ -50,6 +52,14 @@ class PriceModel with ChangeNotifier {
return false;
}

late bool _multipleProducts;
bool showAddProductCard() {
if (_multipleProducts == true) {
return true;
}
return false;
}

Comment on lines +55 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
late bool _multipleProducts;
bool showAddProductCard() {
if (_multipleProducts == true) {
return true;
}
return false;
}
/// "Should we support multiple products?" (instead of a single)
final bool multipleProducts;

For the record, your previous syntax was a bit heavy:

  bool showAddProductCard() {
    if (_multipleProducts == true) {
      return true;
    }
    return false;
  }

The following would have been better:

  bool get showAddProductCard => _multipleProducts;

void setProof(final Proof proof, {final bool init = false}) {
if (!init) {
_hasChanged = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ProductPriceAddPage extends StatefulWidget {
required final BuildContext context,
final PriceMetaProduct? product,
required final ProofType proofType,
final bool? multiProduct,
}) async {
if (!await ProductRefresher().checkIfLoggedIn(
context,
Expand Down Expand Up @@ -65,6 +66,7 @@ class ProductPriceAddPage extends StatefulWidget {
locations: osmLocations,
initialProduct: product,
currency: currency,
multipleProducts: multiProduct,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
multipleProducts: multiProduct,
multipleProducts: multipleProducts,

Please try to keep consistency between classes.

),
),
),
Expand Down Expand Up @@ -152,7 +154,7 @@ class _ProductPriceAddPageState extends State<ProductPriceAddPage>
index: i,
),
const SizedBox(height: LARGE_SPACE),
const PriceAddProductCard(),
if (model.showAddProductCard()) const PriceAddProductCard(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (model.showAddProductCard()) const PriceAddProductCard(),
if (model.multipleProducts) const PriceAddProductCard(),

// so that the last items don't get hidden by the FAB
const SizedBox(height: MINIMUM_TOUCH_SIZE * 2),
],
Expand Down