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 { class IAPProduct {
final String storeId; final String storeId;
final IAPProductStatus status; final IAPProductStatus status;
final String price;
const IAPProduct({ const IAPProduct({
required this.storeId, required this.storeId,
this.status = IAPProductStatus.purchasable, this.status = IAPProductStatus.purchasable,
required this.price,
}); });
IAPProduct copyWith({IAPProductStatus? status}) => IAPProduct( IAPProduct copyWith({IAPProductStatus? status}) => IAPProduct(
storeId: storeId, storeId: storeId,
status: status ?? this.status, status: status ?? this.status,
price: price,
); );
} }

View file

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

View file

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

View file

@ -107,6 +107,15 @@
"unlockProFeatures": "Unlock Pro features", "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.", "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", "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", "tooltipAdd": "Add",
"tooltipClose": "Close", "tooltipClose": "Close",
"tooltipExpand": "Expand", "tooltipExpand": "Expand",

View file

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

View file

@ -52,7 +52,7 @@ class ProFeaturesDialog extends StatelessWidget {
IAPProductsProvider.maybeOf(context)?.buy(IAPProductType.paidFeatures); 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( IAPProduct(
storeId: IAPProductType.paidFeatures.storeId, storeId: IAPProductType.paidFeatures.storeId,
status: widget.productStatus, status: widget.productStatus,
price: '0.0\$',
), ),
], ],
child: ApplicationWrapper( child: ApplicationWrapper(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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