mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:28:41 +00:00
fix additional users
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
fa953b8928
commit
049507cd25
3 changed files with 35 additions and 44 deletions
|
|
@ -187,6 +187,10 @@ class PurchasesProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (purchaseDetails.status == PurchaseStatus.error) {
|
||||||
|
await iapConnection.restorePurchases();
|
||||||
|
}
|
||||||
|
|
||||||
if (purchaseDetails.pendingCompletePurchase) {
|
if (purchaseDetails.pendingCompletePurchase) {
|
||||||
await iapConnection.completePurchase(purchaseDetails);
|
await iapConnection.completePurchase(purchaseDetails);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,9 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var plusInvites = <Response_AddAccountsInvite>[];
|
var plusInvites = <Response_AddAccountsInvite>[];
|
||||||
var freeInvites = <Response_AddAccountsInvite>[];
|
|
||||||
if (additionalInvites != null) {
|
if (additionalInvites != null) {
|
||||||
plusInvites =
|
plusInvites =
|
||||||
additionalInvites!.where((x) => x.planId == 'Plus').toList();
|
additionalInvites!.where((x) => x.planId == 'Plus').toList();
|
||||||
freeInvites =
|
|
||||||
additionalInvites!.where((x) => x.planId == 'Free').toList();
|
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
|
@ -95,11 +92,10 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (plusInvites.isNotEmpty)
|
if (plusInvites.isNotEmpty)
|
||||||
ListTile(
|
Text(
|
||||||
title: Text(
|
|
||||||
context.lang.additionalUsersPlusTokens,
|
context.lang.additionalUsersPlusTokens,
|
||||||
style: const TextStyle(fontSize: 13),
|
textAlign: TextAlign.center,
|
||||||
),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
|
|
@ -111,23 +107,6 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
||||||
children: plusInvites.map(AdditionalUserInvite.new).toList(),
|
children: plusInvites.map(AdditionalUserInvite.new).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (freeInvites.isNotEmpty)
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
context.lang.additionalUsersFreeTokens,
|
|
||||||
style: const TextStyle(fontSize: 13),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: GridView.count(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
childAspectRatio: 16 / 5,
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: freeInvites.map(AdditionalUserInvite.new).toList(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -200,7 +179,7 @@ class _AdditionalAccountState extends State<AdditionalAccount> {
|
||||||
final remove = await showAlertDialog(
|
final remove = await showAlertDialog(
|
||||||
context,
|
context,
|
||||||
'Remove this additional user',
|
'Remove this additional user',
|
||||||
'The additional user will automatically be downgraded to the preview plan after removal and you will receive a new invitation code to give to another person.',
|
'The additional user will automatically be downgraded to the free plan after removal and you will receive a new invitation code to give to another person.',
|
||||||
);
|
);
|
||||||
if (remove) {
|
if (remove) {
|
||||||
final res = await apiService
|
final res = await apiService
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,8 @@ class _SubscriptionViewState extends State<SubscriptionView> {
|
||||||
plan: SubscriptionPlan.Family,
|
plan: SubscriptionPlan.Family,
|
||||||
onPurchase: initAsync,
|
onPurchase: initAsync,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
if (currentPlan == SubscriptionPlan.Free) ...[
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Center(
|
Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
@ -174,6 +176,13 @@ class PlanCard extends StatefulWidget {
|
||||||
State<PlanCard> createState() => _PlanCardState();
|
State<PlanCard> createState() => _PlanCardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getFormattedPrice(PurchasableProduct product) {
|
||||||
|
if (product.price.contains('€')) {
|
||||||
|
return product.price.replaceAll(',00', '').replaceAll('.00', '');
|
||||||
|
}
|
||||||
|
return product.price;
|
||||||
|
}
|
||||||
|
|
||||||
class _PlanCardState extends State<PlanCard> {
|
class _PlanCardState extends State<PlanCard> {
|
||||||
Future<void> onButtonPressed(PurchasableProduct? product) async {
|
Future<void> onButtonPressed(PurchasableProduct? product) async {
|
||||||
if (widget.onPurchase == null) return;
|
if (widget.onPurchase == null) return;
|
||||||
|
|
@ -261,7 +270,7 @@ class _PlanCardState extends State<PlanCard> {
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'${yearlyProduct.price}/${context.lang.year}',
|
'${getFormattedPrice(yearlyProduct)}/${context.lang.year}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
|
@ -270,7 +279,7 @@ class _PlanCardState extends State<PlanCard> {
|
||||||
),
|
),
|
||||||
if (monthlyProduct != null)
|
if (monthlyProduct != null)
|
||||||
Text(
|
Text(
|
||||||
'${monthlyProduct.price}/${context.lang.month}',
|
'${getFormattedPrice(monthlyProduct)}/${context.lang.month}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
|
@ -282,8 +291,8 @@ class _PlanCardState extends State<PlanCard> {
|
||||||
if (widget.paidMonthly != null)
|
if (widget.paidMonthly != null)
|
||||||
Text(
|
Text(
|
||||||
(widget.paidMonthly!)
|
(widget.paidMonthly!)
|
||||||
? '${monthlyProduct?.price}/${context.lang.month}'
|
? '${getFormattedPrice(monthlyProduct!)}/${context.lang.month}'
|
||||||
: '${yearlyProduct?.price}/${context.lang.year}',
|
: '${getFormattedPrice(yearlyProduct!)}/${context.lang.year}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
|
@ -319,9 +328,7 @@ class _PlanCardState extends State<PlanCard> {
|
||||||
label: const Text('Manage subscription'),
|
label: const Text('Manage subscription'),
|
||||||
),
|
),
|
||||||
if (widget.onPurchase != null && monthlyProduct != null)
|
if (widget.onPurchase != null && monthlyProduct != null)
|
||||||
Padding(
|
OutlinedButton.icon(
|
||||||
padding: const EdgeInsets.only(right: 10),
|
|
||||||
child: OutlinedButton.icon(
|
|
||||||
onPressed: () => onButtonPressed(monthlyProduct),
|
onPressed: () => onButtonPressed(monthlyProduct),
|
||||||
label: (widget.plan == SubscriptionPlan.Free ||
|
label: (widget.plan == SubscriptionPlan.Free ||
|
||||||
widget.plan == SubscriptionPlan.Plus)
|
widget.plan == SubscriptionPlan.Plus)
|
||||||
|
|
@ -333,8 +340,9 @@ class _PlanCardState extends State<PlanCard> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (widget.onPurchase != null &&
|
||||||
if (widget.onPurchase != null && yearlyProduct != null)
|
(yearlyProduct != null ||
|
||||||
|
currentPlan == SubscriptionPlan.Free))
|
||||||
FilledButton.icon(
|
FilledButton.icon(
|
||||||
onPressed: () => onButtonPressed(yearlyProduct),
|
onPressed: () => onButtonPressed(yearlyProduct),
|
||||||
label: (widget.plan == SubscriptionPlan.Free ||
|
label: (widget.plan == SubscriptionPlan.Free ||
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue