IAP
This commit is contained in:
parent
dd812915de
commit
169e5b36b5
|
|
@ -2,6 +2,8 @@ import 'dart:async';
|
|||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/resources/cached_image.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
|
|
@ -426,6 +428,46 @@ class SidebarFooter extends StatelessWidget {
|
|||
final TextStyle linkStyle =
|
||||
themeData.textTheme.body2.copyWith(color: themeData.accentColor);
|
||||
|
||||
void showAbout() {
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
applicationName: 'Invoice Ninja',
|
||||
applicationIcon: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40.0,
|
||||
height: 40.0,
|
||||
),
|
||||
applicationVersion: 'Version: $kAppVersion',
|
||||
applicationLegalese: '© ${DateTime.now().year} Invoice Ninja',
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: localization.thankYouForUsingOurApp +
|
||||
'\n\n' +
|
||||
localization.ifYouLikeIt,
|
||||
),
|
||||
_LinkTextSpan(
|
||||
style: linkStyle,
|
||||
url: getAppURL(context),
|
||||
text: ' ' + localization.clickHere + ' ',
|
||||
),
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: localization.toRateIt,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).bottomAppBarColor,
|
||||
child: Row(
|
||||
|
|
@ -440,46 +482,20 @@ class SidebarFooter extends StatelessWidget {
|
|||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.info_outline),
|
||||
onPressed: () {
|
||||
showAboutDialog(
|
||||
onPressed: () => showAbout(),
|
||||
),
|
||||
/*
|
||||
Spacer(),
|
||||
FlatButton(
|
||||
child: Text(localization.upgrade.toUpperCase()),
|
||||
color: Colors.green,
|
||||
onPressed: () => showDialog<UpgradeDialog>(
|
||||
context: context,
|
||||
applicationName: 'Invoice Ninja',
|
||||
applicationIcon: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40.0,
|
||||
height: 40.0,
|
||||
),
|
||||
applicationVersion: 'Version: $kAppVersion',
|
||||
applicationLegalese: '© ${DateTime.now().year} Invoice Ninja',
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: localization.thankYouForUsingOurApp +
|
||||
'\n\n' +
|
||||
localization.ifYouLikeIt,
|
||||
),
|
||||
_LinkTextSpan(
|
||||
style: linkStyle,
|
||||
url: getAppURL(context),
|
||||
text: ' ' + localization.clickHere + ' ',
|
||||
),
|
||||
TextSpan(
|
||||
style: aboutTextStyle,
|
||||
text: localization.toRateIt,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
)
|
||||
builder: (BuildContext context) {
|
||||
return UpgradeDialog();
|
||||
}),
|
||||
),
|
||||
*/
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
@ -497,12 +513,24 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
print('initState...');
|
||||
final Stream purchaseUpdates =
|
||||
InAppPurchaseConnection.instance.purchaseUpdatedStream;
|
||||
|
||||
_subscription = purchaseUpdates.listen((dynamic purchases) {
|
||||
print('purchaseUpdates.listen: $purchases');
|
||||
showDialog<ErrorDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog('PURCHASE STREAM UPDATE: $purchases');
|
||||
});
|
||||
}, onDone: () {
|
||||
_subscription.cancel();
|
||||
_subscription = null;
|
||||
}, onError: (dynamic error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog('PURCHASE STREAM ERROR: $error');
|
||||
});
|
||||
});
|
||||
|
||||
initStore();
|
||||
|
|
@ -514,7 +542,11 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
|||
final bool available = await InAppPurchaseConnection.instance.isAvailable();
|
||||
|
||||
if (!available) {
|
||||
print('store not availble');
|
||||
showDialog<ErrorDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog('Store is not available');
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -550,13 +582,13 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
|||
final localization = AppLocalization.of(context);
|
||||
|
||||
if (products == null) {
|
||||
return CircularProgressIndicator();
|
||||
return LoadingIndicator(height: 50);
|
||||
}
|
||||
|
||||
return SimpleDialog(
|
||||
title: Text(localization.oneYearUpgrade),
|
||||
title: Text(localization.annualSubscription),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 15),
|
||||
children: products
|
||||
children: products.reversed
|
||||
.map((productDetails) => ListTile(
|
||||
title: Text(productDetails.title),
|
||||
subtitle: Text(productDetails.description),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ abstract class LocaleCodeAware {
|
|||
mixin LocalizationsProvider on LocaleCodeAware {
|
||||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
'one_year_upgrade': 'One Year Upgrade',
|
||||
'annual_subscription': 'Annual Subscription',
|
||||
'pro_plan': 'Pro Plan',
|
||||
'enterprise_plan': 'Enterprise Plan',
|
||||
'count_users': ':count users',
|
||||
|
|
@ -13867,8 +13867,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
String get countUsers =>
|
||||
_localizedValues[localeCode]['count_users'];
|
||||
|
||||
String get oneYearUpgrade =>
|
||||
_localizedValues[localeCode]['one_year_upgrade'];
|
||||
String get annualSubscription =>
|
||||
_localizedValues[localeCode]['annual_subscription'];
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue