mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 20:43:20 +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:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:function_types/function_types.dart';
|
||||||
|
|
||||||
import 'package:gitjournal/analytics.dart';
|
import 'package:gitjournal/analytics.dart';
|
||||||
import 'package:gitjournal/screens/feature_timeline_screen.dart';
|
import 'package:gitjournal/screens/feature_timeline_screen.dart';
|
||||||
import 'package:gitjournal/widgets/purchase_widget.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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
@ -36,9 +44,13 @@ class PurchaseScreen extends StatelessWidget {
|
|||||||
PurchaseCards(
|
PurchaseCards(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 16.0),
|
const SizedBox(width: 16.0),
|
||||||
const YearlyPurchaseWidget(),
|
YearlyPurchaseWidget(minPurchaseOptionCallback: (val) {
|
||||||
|
setState(() {
|
||||||
|
minYearlyPurchase = val;
|
||||||
|
});
|
||||||
|
}),
|
||||||
const SizedBox(width: 16.0),
|
const SizedBox(width: 16.0),
|
||||||
const MonthlyRentalWidget(),
|
MonthlyRentalWidget(minYearlyPurchase: minYearlyPurchase),
|
||||||
const SizedBox(width: 16.0),
|
const SizedBox(width: 16.0),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -84,8 +96,11 @@ class PurchaseScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MonthlyRentalWidget extends StatelessWidget {
|
class MonthlyRentalWidget extends StatelessWidget {
|
||||||
|
final String minYearlyPurchase;
|
||||||
|
|
||||||
const MonthlyRentalWidget({
|
const MonthlyRentalWidget({
|
||||||
Key key,
|
Key key,
|
||||||
|
@required this.minYearlyPurchase,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -107,8 +122,8 @@ class MonthlyRentalWidget extends StatelessWidget {
|
|||||||
isSubscription: true,
|
isSubscription: true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32.0),
|
const SizedBox(height: 32.0),
|
||||||
const Text(
|
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'"),
|
"After 12 months or after paying $minYearlyPurchase, you will get all the benefits of a standard 'One Time Purchase'"),
|
||||||
],
|
],
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
),
|
),
|
||||||
@ -125,8 +140,11 @@ class MonthlyRentalWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YearlyPurchaseWidget extends StatelessWidget {
|
class YearlyPurchaseWidget extends StatelessWidget {
|
||||||
|
final Func1<String, void> minPurchaseOptionCallback;
|
||||||
|
|
||||||
const YearlyPurchaseWidget({
|
const YearlyPurchaseWidget({
|
||||||
Key key,
|
Key key,
|
||||||
|
@required this.minPurchaseOptionCallback,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -144,6 +162,7 @@ class YearlyPurchaseWidget extends StatelessWidget {
|
|||||||
defaultSku: "sku_yearly_1",
|
defaultSku: "sku_yearly_1",
|
||||||
timePeriod: "Year",
|
timePeriod: "Year",
|
||||||
isSubscription: false,
|
isSubscription: false,
|
||||||
|
minPurchaseOptionCallback: minPurchaseOptionCallback,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32.0),
|
const SizedBox(height: 32.0),
|
||||||
const Text(
|
const Text(
|
||||||
|
@ -4,6 +4,7 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.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:in_app_purchase/in_app_purchase.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@ -55,12 +56,14 @@ class PurchaseWidget extends StatefulWidget {
|
|||||||
final String defaultSku;
|
final String defaultSku;
|
||||||
final String timePeriod;
|
final String timePeriod;
|
||||||
final bool isSubscription;
|
final bool isSubscription;
|
||||||
|
final Func1<String, void> minPurchaseOptionCallback;
|
||||||
|
|
||||||
PurchaseWidget({
|
PurchaseWidget({
|
||||||
@required this.skus,
|
@required this.skus,
|
||||||
@required this.defaultSku,
|
@required this.defaultSku,
|
||||||
@required this.timePeriod,
|
@required this.timePeriod,
|
||||||
@required this.isSubscription,
|
@required this.isSubscription,
|
||||||
|
this.minPurchaseOptionCallback,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -107,6 +110,10 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
|||||||
for (var p in products) {
|
for (var p in products) {
|
||||||
Log.i("Product ${p.id} -> ${p.price}");
|
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
|
// 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
|
// message was in flight, we want to discard the reply rather than calling
|
||||||
|
Reference in New Issue
Block a user