getSubscriptionAlert static method
Future<bool?>
getSubscriptionAlert(
- SubscriptionService? drawerController,
- BuildContext context,
- String fromRoute
Implementation
static Future<bool?> getSubscriptionAlert(SubscriptionService? drawerController, BuildContext context, String fromRoute) async {
AppConfig.logger.d("getSubscriptionAlert");
List<ProfileType> profileTypes = AppFlavour.getProfileTypes();
if(drawerController == null) return null;
if(drawerController.subscriptionPlans.isEmpty) await drawerController.initializeSubscriptions();
return Alert(
context: context,
style: AlertStyle(
backgroundColor: AppColor.main50,
titleStyle: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
titleTextAlign: TextAlign.justify
),
content: Obx(() => drawerController.isLoading ? const Center(child: CircularProgressIndicator()) : Column(
children: <Widget>[
AppTheme.heightSpace20,
Text(('${drawerController.selectedPlanName}Msg').tr,
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),textAlign: TextAlign.justify,),
AppTheme.heightSpace20,
HandledCachedNetworkImage(drawerController.selectedPlanImgUrl),
AppTheme.heightSpace20,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${AppTranslationConstants.profileType.tr}: ",
style: const TextStyle(fontSize: 15),
),
DropdownButton<ProfileType>(
items: profileTypes.map((ProfileType type) {
return DropdownMenuItem<ProfileType>(
value: type,
child: Text(type.value.tr.capitalize),
);
}).toList(),
onChanged: (ProfileType? selectedType) {
if (selectedType == null) return;
drawerController.selectProfileType(selectedType);
},
value: drawerController.profileType,
alignment: Alignment.center,
icon: const Icon(Icons.arrow_downward),
iconSize: 20,
elevation: 16,
style: const TextStyle(color: Colors.white),
dropdownColor: AppColor.getMain(),
underline: Container(
height: 1,
color: Colors.grey,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${AppTranslationConstants.subscription.tr}: ",
style: const TextStyle(fontSize: 15),
),
DropdownButton<String>(
items: drawerController.profilePlans.values.map((SubscriptionPlan plan) {
return DropdownMenuItem<String>(
value: plan.id,
child: Text(plan.name.tr),
);
}).toList(),
onChanged: (String? plan) {
if(plan != null) {
drawerController.changeSubscriptionPlan(plan);
}
},
value: drawerController.selectedPlan.id,
alignment: Alignment.center,
icon: const Icon(Icons.arrow_downward),
iconSize: 20,
elevation: 16,
style: const TextStyle(color: Colors.white),
dropdownColor: AppColor.getMain(),
underline: Container(
height: 1,
color: Colors.grey,
),
),
],
),
AppTheme.heightSpace20,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${CommonTranslationConstants.totalToPay.tr.capitalizeFirst}:",
style: const TextStyle(fontSize: 15),
),
Row(
children: [
Text("${CoreUtilities.getCurrencySymbol(drawerController.selectedPrice.currency)} ${drawerController.selectedPrice.amount} ${drawerController.selectedPrice.currency.name.tr.toUpperCase()}",
style: const TextStyle(fontSize: 15),
),
AppTheme.widthSpace5,
],
),
],
),
],),
),
buttons: [
DialogButton(
color: AppColor.bondiBlue75,
onPressed: () async {
await drawerController.paySubscription(drawerController.selectedPlan, fromRoute);
},
child: Text(CommonTranslationConstants.confirmAndProceed.tr,
style: const TextStyle(fontSize: 15),
),
),
]
).show();
}