added price to IAPProduct

This commit is contained in:
Vadim 2024-07-15 22:00:38 +02:00
parent bae5ead8f0
commit 26a9dd05d3
13 changed files with 34 additions and 5 deletions

View file

@ -9,15 +9,18 @@ enum IAPProductType { paidFeatures }
class IAPProduct {
final String storeId;
final IAPProductStatus status;
final String price;
const IAPProduct({
required this.storeId,
this.status = IAPProductStatus.purchasable,
required this.price,
});
IAPProduct copyWith({IAPProductStatus? status}) => IAPProduct(
storeId: storeId,
status: status ?? this.status,
price: price,
);
}

View file

@ -25,6 +25,7 @@ class IAPProductsProviderState extends State<IAPProductsProvider> {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: IAPProductStatus.purchased,
price: '0.0\$',
)
],
child: widget.child,

View file

@ -27,6 +27,7 @@ class MockIAPProductsProviderState extends State<MockIAPProductsProvider> {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: _purchased ? IAPProductStatus.purchased : IAPProductStatus.purchasable,
price: '0.0\$',
),
]),
child: widget.child,

View file

@ -107,6 +107,15 @@
"unlockProFeatures": "Unlock Pro features",
"unlockProFeaturesDescription": "Unlock professional features:\n \u2022 Equipment profiles containing filters for aperture, shutter speed, and more\n \u2022 List of films with compensation for what's known as reciprocity failure\n \u2022 Spot metering & Histogram\n \u2022 And more!\n\nBy unlocking Pro features you support the development and make it possible to add new features to the app.",
"unlock": "Unlock",
"proFeaturesSupportText": "By purchasing you support the development and make it possible to add new features to the app.",
"unlockFor": "Unlock for {price}",
"@unlockFor": {
"price": {
"version": {
"type": "String"
}
}
},
"tooltipAdd": "Add",
"tooltipClose": "Close",
"tooltipExpand": "Expand",

View file

@ -25,7 +25,13 @@ Future<void> runLightmeterApp(Environment env) async {
runApp(
env.buildType == BuildType.dev
? IAPProducts(
products: [IAPProduct(storeId: IAPProductType.paidFeatures.storeId)],
products: [
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: IAPProductStatus.purchasable,
price: '0.0\$',
),
],
child: application,
)
: IAPProductsProvider(

View file

@ -52,7 +52,7 @@ class ProFeaturesDialog extends StatelessWidget {
IAPProductsProvider.maybeOf(context)?.buy(IAPProductType.paidFeatures);
});
},
child: Text(S.of(context).unlock),
child: Text(S.of(context).unlockFor(IAPProducts.productOf(context, IAPProductType.paidFeatures)!.price)),
),
],
);

View file

@ -91,6 +91,7 @@ class _GoldenTestApplicationMockState extends State<GoldenTestApplicationMock> {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: widget.productStatus,
price: '0.0\$',
),
],
child: ApplicationWrapper(

View file

@ -26,6 +26,7 @@ void main() {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: productStatus,
price: '0.0\$',
),
],
child: EquipmentProfileProvider(

View file

@ -26,6 +26,7 @@ void main() {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: productStatus,
price: '0.0\$',
),
],
child: FilmsProvider(

View file

@ -28,6 +28,7 @@ void main() {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: IAPProductStatus.purchased,
price: '0.0\$',
),
],
child: EquipmentProfileProvider(

View file

@ -27,6 +27,7 @@ void main() {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: IAPProductStatus.purchased,
price: '0.0\$',
),
],
child: FilmsProvider(

View file

@ -28,6 +28,7 @@ void main() {
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
status: IAPProductStatus.purchased,
price: '0.0\$',
),
],
child: EquipmentProfileProvider(

View file

@ -7,6 +7,8 @@ import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import '../../../application_mock.dart';
const _price = '0.0\$';
void main() {
Future<void> pumpApplication(WidgetTester tester) async {
await tester.pumpWidget(
@ -14,6 +16,7 @@ void main() {
products: [
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
price: _price,
),
],
child: const WidgetTestApplicationMock(
@ -33,9 +36,9 @@ void main() {
expect(find.byType(TransparentDialog), findsOneWidget);
expect(find.text(S.current.proFeatures), findsNWidgets(2));
expect(find.text(S.current.cancel), findsOneWidget);
expect(find.text(S.current.unlock), findsOneWidget);
expect(find.text(S.current.unlockFor(_price)), findsOneWidget);
await tester.tap(find.text(S.current.unlock));
await tester.tap(find.text(S.current.unlockFor(_price)));
await tester.pumpAndSettle();
expect(find.byType(TransparentDialog), findsNothing);
},
@ -50,7 +53,7 @@ void main() {
expect(find.byType(TransparentDialog), findsOneWidget);
expect(find.text(S.current.proFeatures), findsNWidgets(2));
expect(find.text(S.current.cancel), findsOneWidget);
expect(find.text(S.current.unlock), findsOneWidget);
expect(find.text(S.current.unlockFor(_price)), findsOneWidget);
await tester.tap(find.text(S.current.cancel));
await tester.pumpAndSettle();