mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
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.
This commit is contained in:
@ -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<PurchaseScreen> {
|
||||
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<String, void> 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(
|
||||
|
@ -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<String, void> 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<PurchaseWidget> {
|
||||
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
|
||||
|
Reference in New Issue
Block a user