Fetch the latest subscription status and refresh the header widget if subscription has expired

This commit is contained in:
Vishnu Mohandas 2021-01-31 13:26:18 +05:30
parent fe9d6fc308
commit 37472726b0

View file

@ -43,7 +43,26 @@ class _SignInHeaderState extends State<SignInHeader> {
var hasSubscribed = BillingService.instance.hasActiveSubscription();
if (hasConfiguredAccount && hasSubscribed) {
return Container();
} else if (!hasConfiguredAccount) {
return _getBody(context);
} else {
return FutureBuilder(
future: BillingService.instance.fetchSubscription(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
if (BillingService.instance.hasActiveSubscription()) {
return Container();
}
return _getBody(context);
} else {
return Container();
}
},
);
}
}
SingleChildScrollView _getBody(BuildContext context) {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.fromLTRB(8, 24, 8, 8),
@ -179,6 +198,7 @@ class _SignInHeaderState extends State<SignInHeader> {
// Yet to decrypt the key
page = PasswordReentryPage();
} else {
// All is well, user just has not subscribed
page = SubscriptionPage();
}
}