mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 08:08:39 +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) {
|
||||
await iapConnection.completePurchase(purchaseDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,12 +65,9 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var plusInvites = <Response_AddAccountsInvite>[];
|
||||
var freeInvites = <Response_AddAccountsInvite>[];
|
||||
if (additionalInvites != null) {
|
||||
plusInvites =
|
||||
additionalInvites!.where((x) => x.planId == 'Plus').toList();
|
||||
freeInvites =
|
||||
additionalInvites!.where((x) => x.planId == 'Free').toList();
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
|
@ -95,11 +92,10 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
|||
),
|
||||
),
|
||||
if (plusInvites.isNotEmpty)
|
||||
ListTile(
|
||||
title: Text(
|
||||
context.lang.additionalUsersPlusTokens,
|
||||
style: const TextStyle(fontSize: 13),
|
||||
),
|
||||
Text(
|
||||
context.lang.additionalUsersPlusTokens,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
|
|
@ -111,23 +107,6 @@ class _AdditionalUsersViewState extends State<AdditionalUsersView> {
|
|||
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(
|
||||
context,
|
||||
'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) {
|
||||
final res = await apiService
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ class _SubscriptionViewState extends State<SubscriptionView> {
|
|||
plan: SubscriptionPlan.Family,
|
||||
onPurchase: initAsync,
|
||||
),
|
||||
],
|
||||
if (currentPlan == SubscriptionPlan.Free) ...[
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: Padding(
|
||||
|
|
@ -174,6 +176,13 @@ class PlanCard extends StatefulWidget {
|
|||
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> {
|
||||
Future<void> onButtonPressed(PurchasableProduct? product) async {
|
||||
if (widget.onPurchase == null) return;
|
||||
|
|
@ -261,7 +270,7 @@ class _PlanCardState extends State<PlanCard> {
|
|||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'${yearlyProduct.price}/${context.lang.year}',
|
||||
'${getFormattedPrice(yearlyProduct)}/${context.lang.year}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
|
|
@ -270,7 +279,7 @@ class _PlanCardState extends State<PlanCard> {
|
|||
),
|
||||
if (monthlyProduct != null)
|
||||
Text(
|
||||
'${monthlyProduct.price}/${context.lang.month}',
|
||||
'${getFormattedPrice(monthlyProduct)}/${context.lang.month}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
|
|
@ -282,8 +291,8 @@ class _PlanCardState extends State<PlanCard> {
|
|||
if (widget.paidMonthly != null)
|
||||
Text(
|
||||
(widget.paidMonthly!)
|
||||
? '${monthlyProduct?.price}/${context.lang.month}'
|
||||
: '${yearlyProduct?.price}/${context.lang.year}',
|
||||
? '${getFormattedPrice(monthlyProduct!)}/${context.lang.month}'
|
||||
: '${getFormattedPrice(yearlyProduct!)}/${context.lang.year}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
|
|
@ -319,22 +328,21 @@ class _PlanCardState extends State<PlanCard> {
|
|||
label: const Text('Manage subscription'),
|
||||
),
|
||||
if (widget.onPurchase != null && monthlyProduct != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => onButtonPressed(monthlyProduct),
|
||||
label: (widget.plan == SubscriptionPlan.Free ||
|
||||
widget.plan == SubscriptionPlan.Plus)
|
||||
? Text(context.lang.redeemUserInviteCodeTitle)
|
||||
: Text(
|
||||
context.lang.upgradeToPaidPlanButton(
|
||||
widget.plan.name,
|
||||
' (${context.lang.monthly})',
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => onButtonPressed(monthlyProduct),
|
||||
label: (widget.plan == SubscriptionPlan.Free ||
|
||||
widget.plan == SubscriptionPlan.Plus)
|
||||
? Text(context.lang.redeemUserInviteCodeTitle)
|
||||
: Text(
|
||||
context.lang.upgradeToPaidPlanButton(
|
||||
widget.plan.name,
|
||||
' (${context.lang.monthly})',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.onPurchase != null && yearlyProduct != null)
|
||||
if (widget.onPurchase != null &&
|
||||
(yearlyProduct != null ||
|
||||
currentPlan == SubscriptionPlan.Free))
|
||||
FilledButton.icon(
|
||||
onPressed: () => onButtonPressed(yearlyProduct),
|
||||
label: (widget.plan == SubscriptionPlan.Free ||
|
||||
|
|
|
|||
Loading…
Reference in a new issue