From 7a239156861d21e7ffb59f6632d01158cd02eafa Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 31 Aug 2020 18:00:07 +0200 Subject: [PATCH] Clarify the the Monthly Purchase option text Clearly show how much they would need to pay in order for it to convert into a normal One Time Purchase. --- lib/screens/purchase_screen.dart | 29 ++++++++++++++++++++++++----- lib/widgets/purchase_widget.dart | 7 +++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/screens/purchase_screen.dart b/lib/screens/purchase_screen.dart index cbcc719b..13c855f1 100644 --- a/lib/screens/purchase_screen.dart +++ b/lib/screens/purchase_screen.dart @@ -3,12 +3,20 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:function_types/function_types.dart'; import 'package:gitjournal/analytics.dart'; import 'package:gitjournal/screens/feature_timeline_screen.dart'; import 'package:gitjournal/widgets/purchase_widget.dart'; -class PurchaseScreen extends StatelessWidget { +class PurchaseScreen extends StatefulWidget { + @override + _PurchaseScreenState createState() => _PurchaseScreenState(); +} + +class _PurchaseScreenState extends State { + String minYearlyPurchase = ""; + @override Widget build(BuildContext context) { return WillPopScope( @@ -36,9 +44,13 @@ class PurchaseScreen extends StatelessWidget { PurchaseCards( children: [ const SizedBox(width: 16.0), - const YearlyPurchaseWidget(), + YearlyPurchaseWidget(minPurchaseOptionCallback: (val) { + setState(() { + minYearlyPurchase = val; + }); + }), const SizedBox(width: 16.0), - const MonthlyRentalWidget(), + MonthlyRentalWidget(minYearlyPurchase: minYearlyPurchase), const SizedBox(width: 16.0), ], ), @@ -84,8 +96,11 @@ class PurchaseScreen extends StatelessWidget { } class MonthlyRentalWidget extends StatelessWidget { + final String minYearlyPurchase; + const MonthlyRentalWidget({ Key key, + @required this.minYearlyPurchase, }) : super(key: key); @override @@ -107,8 +122,8 @@ class MonthlyRentalWidget extends StatelessWidget { isSubscription: true, ), const SizedBox(height: 32.0), - const Text( - "After 12 months or after paying the minimum 'One Time Purchase' amount, you will get all the benefits of a standard 'One Time Purchase'"), + Text( + "After 12 months or after paying $minYearlyPurchase, you will get all the benefits of a standard 'One Time Purchase'"), ], mainAxisAlignment: MainAxisAlignment.start, ), @@ -125,8 +140,11 @@ class MonthlyRentalWidget extends StatelessWidget { } class YearlyPurchaseWidget extends StatelessWidget { + final Func1 minPurchaseOptionCallback; + const YearlyPurchaseWidget({ Key key, + @required this.minPurchaseOptionCallback, }) : super(key: key); @override @@ -144,6 +162,7 @@ class YearlyPurchaseWidget extends StatelessWidget { defaultSku: "sku_yearly_1", timePeriod: "Year", isSubscription: false, + minPurchaseOptionCallback: minPurchaseOptionCallback, ), const SizedBox(height: 32.0), const Text( diff --git a/lib/widgets/purchase_widget.dart b/lib/widgets/purchase_widget.dart index 05ffa481..c985ca91 100644 --- a/lib/widgets/purchase_widget.dart +++ b/lib/widgets/purchase_widget.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:function_types/function_types.dart'; import 'package:in_app_purchase/in_app_purchase.dart'; import 'package:provider/provider.dart'; @@ -55,12 +56,14 @@ class PurchaseWidget extends StatefulWidget { final String defaultSku; final String timePeriod; final bool isSubscription; + final Func1 minPurchaseOptionCallback; PurchaseWidget({ @required this.skus, @required this.defaultSku, @required this.timePeriod, @required this.isSubscription, + this.minPurchaseOptionCallback, }); @override @@ -107,6 +110,10 @@ class _PurchaseWidgetState extends State { for (var p in products) { Log.i("Product ${p.id} -> ${p.price}"); } + if (widget.minPurchaseOptionCallback != null && products.isNotEmpty) { + Log.i("Calling minPurchaseOptionCallback with ${products.first.price}"); + widget.minPurchaseOptionCallback(products.first.price); + } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling