mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +08:00
Add a 'Restore Purchase' button
Instead of doing it automatically, Fixes #211
This commit is contained in:
@ -221,3 +221,4 @@ purchase_screen:
|
||||
Paying a monthly subscription helps you support development and gives you access to
|
||||
a number of "Pro" only features. We operate on a "pay what you want model". No matter what you pay
|
||||
you will get access to all the Pro features.'
|
||||
restore: Restore Purchase
|
||||
|
@ -23,7 +23,6 @@ class PurchaseScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget buildBody(BuildContext context) {
|
||||
|
||||
Widget w = Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
@ -43,6 +42,8 @@ class PurchaseScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 64.0),
|
||||
PurchaseWidget(),
|
||||
const SizedBox(height: 32.0),
|
||||
RestorePurchaseButton(),
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
@ -74,13 +75,6 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
||||
}
|
||||
|
||||
Future<void> initPlatformState() async {
|
||||
// In parallel check if the purchase has been made
|
||||
InAppPurchases.confirmProPurchase().then((void _) {
|
||||
if (Settings.instance.proMode) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
|
||||
final iapCon = InAppPurchaseConnection.instance;
|
||||
|
||||
final bool available = await iapCon.isAvailable();
|
||||
@ -335,3 +329,30 @@ class PurchaseFailedDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RestorePurchaseButton extends StatefulWidget {
|
||||
@override
|
||||
_RestorePurchaseButtonState createState() => _RestorePurchaseButtonState();
|
||||
}
|
||||
|
||||
class _RestorePurchaseButtonState extends State<RestorePurchaseButton> {
|
||||
bool computing = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var text = computing ? '...' : tr('purchase_screen.restore');
|
||||
|
||||
return OutlineButton(
|
||||
child: Text(text),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
computing = true;
|
||||
});
|
||||
await InAppPurchases.confirmProPurchase();
|
||||
if (Settings.instance.proMode) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user