From 0420796660bb431bc594a46986218f4b3e6e436f Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Mon, 1 Feb 2021 14:18:13 +0530 Subject: [PATCH] Add deep link to manage payments --- lib/ui/subscription_page.dart | 80 ++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/lib/ui/subscription_page.dart b/lib/ui/subscription_page.dart index fdf4e320e..2432ef1a5 100644 --- a/lib/ui/subscription_page.dart +++ b/lib/ui/subscription_page.dart @@ -17,6 +17,7 @@ import 'package:photos/utils/date_time_util.dart'; import 'package:photos/utils/dialog_util.dart'; import 'package:photos/utils/toast_util.dart'; import 'package:progress_dialog/progress_dialog.dart'; +import 'package:url_launcher/url_launcher.dart'; class SubscriptionPage extends StatefulWidget { const SubscriptionPage({Key key}) : super(key: key); @@ -218,36 +219,65 @@ class _SubscriptionPageState extends State { ), ), ), - ]); - } - widgets.addAll([ - Expanded(child: Container()), - Align( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - showDialog( - context: context, - builder: (builder) { - return LearnMoreWidget(); - }, - ); - }, - child: Container( - padding: EdgeInsets.all(80), - child: RichText( - text: TextSpan( - text: "learn more", - style: TextStyle( - color: Colors.blue, - fontFamily: 'Ubuntu', + Expanded(child: Container()), + Align( + alignment: Alignment.center, + child: GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (builder) { + return LearnMoreWidget(); + }, + ); + }, + child: Container( + padding: EdgeInsets.all(80), + child: RichText( + text: TextSpan( + text: "learn more", + style: TextStyle( + color: Colors.blue, + fontFamily: 'Ubuntu', + ), ), ), ), ), ), - ), - ]); + ]); + } else { + widgets.addAll([ + Expanded(child: Container()), + Align( + alignment: Alignment.center, + child: GestureDetector( + onTap: () { + if (Platform.isAndroid) { + launch( + "https://play.google.com/store/account/subscriptions?sku=" + + _currentSubscription.productID + + "&package=io.ente.photos"); + } else { + launch("https://apps.apple.com/account/billing"); + } + }, + child: Container( + padding: EdgeInsets.all(80), + child: RichText( + text: TextSpan( + text: "payment details", + style: TextStyle( + color: Colors.blue, + fontFamily: 'Ubuntu', + ), + ), + ), + ), + ), + ), + ]); + } return SingleChildScrollView( child: Container( height: pageSize - (appBarSize + notifySize),