diff --git a/lib/models/user_details.dart b/lib/models/user_details.dart index de1ba3a82..02f5048c4 100644 --- a/lib/models/user_details.dart +++ b/lib/models/user_details.dart @@ -54,8 +54,8 @@ class UserDetails { return UserDetails( map['email'] as String, map['usage'] as int, - map['fileCount'] as int, - map['sharedCollectionsCount'] as int, + map['fileCount'] as int ?? 0, + map['sharedCollectionsCount'] as int ?? 0, Subscription.fromMap(map['subscription']), FamilyData.fromMap(map['familyData']), ); diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index 7f1d642f4..7b86c9a51 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -210,37 +210,37 @@ class _StripeSubscriptionPageState extends State { ), ), ]); + } - if (!widget.isOnboarding) { - widgets.addAll([ - Align( - alignment: Alignment.topCenter, - child: GestureDetector( - onTap: () async { - await _launchFamilyPortal(); - }, - child: Container( - padding: EdgeInsets.fromLTRB(40, 0, 40, 80), - child: Column( - children: [ - RichText( - text: TextSpan( - text: "manage family", - style: TextStyle( - color: Colors.blue, - fontFamily: 'Ubuntu', - fontSize: 15, - ), + if (!widget.isOnboarding) { + widgets.addAll([ + Align( + alignment: Alignment.topCenter, + child: GestureDetector( + onTap: () async { + await _launchFamilyPortal(); + }, + child: Container( + padding: EdgeInsets.fromLTRB(40, 0, 40, 80), + child: Column( + children: [ + RichText( + text: TextSpan( + text: "manage family", + style: TextStyle( + color: Colors.blue, + fontFamily: 'Ubuntu', + fontSize: 15, ), - textAlign: TextAlign.center, ), - ], - ), + textAlign: TextAlign.center, + ), + ], ), ), ), - ]); - } + ), + ]); } return SingleChildScrollView( @@ -270,6 +270,13 @@ class _StripeSubscriptionPageState extends State { } Future _launchFamilyPortal() async { + if (_userDetails.subscription.productID == kFreeProductID) { + await showErrorDialog( + context, + "Now you can share your storage plan with your family members!", + "Customers on paid plans can add up to 5 family members without paying extra. Each member gets their own private space."); + return; + } await _dialog.show(); try { final String jwtToken = await _userService.getFamiliesToken(); diff --git a/lib/ui/payment/subscription_page.dart b/lib/ui/payment/subscription_page.dart index 247e9c36b..3152b1cd9 100644 --- a/lib/ui/payment/subscription_page.dart +++ b/lib/ui/payment/subscription_page.dart @@ -237,6 +237,8 @@ class _SubscriptionPageState extends State { ), ), ]); + } + if (!widget.isOnboarding) { widgets.addAll([ Align( alignment: Alignment.topCenter, @@ -434,7 +436,15 @@ class _SubscriptionPageState extends State { ); } + // todo: refactor manage family in common widget Future _launchFamilyPortal() async { + if (_userDetails.subscription.productID == kFreeProductID) { + await showErrorDialog( + context, + "Now you can share your storage plan with your family members!", + "Customers on paid plans can add up to 5 family members without paying extra. Each member gets their own private space."); + return; + } await _dialog.show(); try { final String jwtToken = await _userService.getFamiliesToken(); diff --git a/pubspec.yaml b/pubspec.yaml index 1c19608ab..fbf01a745 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: ente photos application # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.5.20+300 +version: 0.5.21+301 environment: sdk: ">=2.10.0 <3.0.0"