-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dependabot/pub/packages/smooth_app/webvie…
…w_flutter_wkwebview-3.15.0
- Loading branch information
Showing
24 changed files
with
692 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-31.1 KB
packages/smooth_app/assets/app/release_icon_transparent_1152x1152.png
Binary file not shown.
Binary file removed
BIN
-25.1 KB
packages/smooth_app/assets/app/release_icon_transparent_70pct_1152x1152.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
packages/smooth_app/lib/background/background_task_add_other_price.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:smooth_app/background/background_task.dart'; | ||
import 'package:smooth_app/background/background_task_price.dart'; | ||
import 'package:smooth_app/background/operation_type.dart'; | ||
import 'package:smooth_app/database/local_database.dart'; | ||
|
||
/// Background task about adding prices to an existing proof. | ||
class BackgroundTaskAddOtherPrice extends BackgroundTaskPrice { | ||
BackgroundTaskAddOtherPrice._({ | ||
required super.processName, | ||
required super.uniqueId, | ||
required super.stamp, | ||
// single | ||
required this.proofId, | ||
required super.date, | ||
required super.currency, | ||
required super.locationOSMId, | ||
required super.locationOSMType, | ||
// multi | ||
required super.barcodes, | ||
required super.pricesAreDiscounted, | ||
required super.prices, | ||
required super.pricesWithoutDiscount, | ||
}); | ||
|
||
BackgroundTaskAddOtherPrice.fromJson(super.json) | ||
: proofId = json[_jsonTagProofId] as int, | ||
super.fromJson(); | ||
|
||
static const String _jsonTagProofId = 'proofId'; | ||
|
||
static const OperationType _operationType = OperationType.addOtherPrice; | ||
|
||
final int proofId; | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> result = super.toJson(); | ||
result[_jsonTagProofId] = proofId; | ||
return result; | ||
} | ||
|
||
/// Adds the background task about uploading a product image. | ||
static Future<void> addTask({ | ||
required final BuildContext context, | ||
required final int proofId, | ||
required final DateTime date, | ||
required final Currency currency, | ||
required final int locationOSMId, | ||
required final LocationOSMType locationOSMType, | ||
required final List<String> barcodes, | ||
required final List<bool> pricesAreDiscounted, | ||
required final List<double> prices, | ||
required final List<double?> pricesWithoutDiscount, | ||
}) async { | ||
final LocalDatabase localDatabase = context.read<LocalDatabase>(); | ||
final String uniqueId = await _operationType.getNewKey(localDatabase); | ||
final BackgroundTask task = _getNewTask( | ||
uniqueId: uniqueId, | ||
proofId: proofId, | ||
date: date, | ||
currency: currency, | ||
locationOSMId: locationOSMId, | ||
locationOSMType: locationOSMType, | ||
barcodes: barcodes, | ||
pricesAreDiscounted: pricesAreDiscounted, | ||
prices: prices, | ||
pricesWithoutDiscount: pricesWithoutDiscount, | ||
); | ||
if (!context.mounted) { | ||
return; | ||
} | ||
await task.addToManager(localDatabase, context: context); | ||
} | ||
|
||
/// Returns a new background task about changing a product. | ||
static BackgroundTaskAddOtherPrice _getNewTask({ | ||
required final String uniqueId, | ||
required final int proofId, | ||
required final DateTime date, | ||
required final Currency currency, | ||
required final int locationOSMId, | ||
required final LocationOSMType locationOSMType, | ||
required final List<String> barcodes, | ||
required final List<bool> pricesAreDiscounted, | ||
required final List<double> prices, | ||
required final List<double?> pricesWithoutDiscount, | ||
}) => | ||
BackgroundTaskAddOtherPrice._( | ||
uniqueId: uniqueId, | ||
processName: _operationType.processName, | ||
proofId: proofId, | ||
date: date, | ||
currency: currency, | ||
locationOSMId: locationOSMId, | ||
locationOSMType: locationOSMType, | ||
barcodes: barcodes, | ||
pricesAreDiscounted: pricesAreDiscounted, | ||
prices: prices, | ||
pricesWithoutDiscount: pricesWithoutDiscount, | ||
stamp: BackgroundTaskPrice.getStamp( | ||
date: date, | ||
locationOSMId: locationOSMId, | ||
locationOSMType: locationOSMType, | ||
), | ||
); | ||
|
||
@override | ||
Future<void> execute(final LocalDatabase localDatabase) async { | ||
final String bearerToken = await getBearerToken(); | ||
|
||
await addPrices( | ||
bearerToken: bearerToken, | ||
proofId: proofId, | ||
); | ||
|
||
await closeSession(bearerToken: bearerToken); | ||
} | ||
} |
Oops, something went wrong.