update subcription portal
This commit is contained in:
@@ -6,7 +6,12 @@ import '../constant.dart';
|
||||
import '../generated/l10n.dart' as lang;
|
||||
import '../model/business_info_model.dart';
|
||||
|
||||
Widget goToPackagePagePopup({required BuildContext context, required EnrolledPlan? enrolledPlan}) {
|
||||
Widget goToPackagePagePopup({
|
||||
required BuildContext context,
|
||||
required EnrolledPlan? enrolledPlan,
|
||||
VoidCallback? onCancel,
|
||||
VoidCallback? onUpgrade,
|
||||
}) {
|
||||
return AlertDialog(
|
||||
backgroundColor: kWhite,
|
||||
surfaceTintColor: kWhite,
|
||||
@@ -24,7 +29,11 @@ Widget goToPackagePagePopup({required BuildContext context, required EnrolledPla
|
||||
padding: EdgeInsets.zero,
|
||||
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
|
||||
onPressed: () {
|
||||
if (onCancel != null) {
|
||||
onCancel();
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
@@ -56,11 +65,55 @@ Widget goToPackagePagePopup({required BuildContext context, required EnrolledPla
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
child: Text(lang.S.of(context).upgradeNow),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||
side: const BorderSide(color: Colors.red),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (onCancel != null) {
|
||||
onCancel();
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
lang.S.of(context).cancel,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||
backgroundColor: kMainColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
lang.S.of(context).upgradeNow,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () {
|
||||
if (onUpgrade != null) {
|
||||
onUpgrade();
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -24,6 +24,8 @@ import '../barcode/gererate_barcode.dart';
|
||||
import '../cash and bank/cheques/cheques_list_screen.dart';
|
||||
import '../language/language.dart';
|
||||
import '../subscription/package_screen.dart';
|
||||
import '../subscription/purchase_premium_plan_screen.dart';
|
||||
import '../../http_client/subscription_expire_provider.dart';
|
||||
import 'delete_acount_allart_dialog.dart';
|
||||
|
||||
class SettingScreen extends ConsumerStatefulWidget {
|
||||
@@ -131,6 +133,19 @@ class SettingScreenState extends ConsumerState<SettingScreen> {
|
||||
),
|
||||
);
|
||||
return;
|
||||
} else if (value.route is PackageScreen) {
|
||||
final subscriptionState = ref.read(subscriptionProvider);
|
||||
if (subscriptionState.isExpired) {
|
||||
PurchasePremiumPlanScreen(
|
||||
isCameBack: true,
|
||||
isExpired: true,
|
||||
enrolledPlan: businessInfo.value?.data?.enrolledPlan,
|
||||
willExpire: businessInfo.value?.data?.willExpire,
|
||||
).launch(context);
|
||||
} else {
|
||||
const PackageScreen().launch(context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final _previousCurrency = currency;
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:mobile_pos/currency.dart';
|
||||
|
||||
import '../../Const/api_config.dart';
|
||||
import '../../GlobalComponents/bar_code_scaner_widget.dart';
|
||||
import '../../GlobalComponents/go_to_subscription-package_page_popup_widget.dart';
|
||||
import '../Sales/provider/sales_cart_provider.dart';
|
||||
import '../../Provider/product_provider.dart';
|
||||
import '../../model/add_to_cart_model.dart';
|
||||
@@ -25,6 +26,11 @@ import '../../service/check_user_role_permission_provider.dart';
|
||||
import '../product_category/model/category_model.dart';
|
||||
import '../product_category/provider/product_category_provider/product_unit_provider.dart';
|
||||
import 'package:mobile_pos/generated/l10n.dart' as lang;
|
||||
import '../../http_client/subscription_expire_provider.dart';
|
||||
import '../subscription/purchase_premium_plan_screen.dart';
|
||||
import '../../model/business_info_model.dart';
|
||||
import '../Home/home.dart';
|
||||
import '../../Provider/profile_provider.dart';
|
||||
|
||||
class PosSaleScreen extends ConsumerStatefulWidget {
|
||||
const PosSaleScreen({super.key});
|
||||
@@ -60,6 +66,47 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
ref.refresh(cartNotifier);
|
||||
filteredProducts = ref.read(productProvider).value ?? [];
|
||||
productController.addListener(_applyFilters);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final subscriptionState = ref.read(subscriptionProvider);
|
||||
if (subscriptionState.isExpired) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: goToPackagePagePopup(
|
||||
context: context,
|
||||
enrolledPlan: ref.read(businessInfoProvider).value?.data?.enrolledPlan,
|
||||
onCancel: () {
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const Home()),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
},
|
||||
onUpgrade: () {
|
||||
final businessInfo = ref.read(businessInfoProvider);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PurchasePremiumPlanScreen(
|
||||
isCameBack: true,
|
||||
isExpired: true,
|
||||
initiallyShowDialog: false,
|
||||
enrolledPlan: businessInfo.value?.data?.enrolledPlan,
|
||||
willExpire: businessInfo.value?.data?.willExpire,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -481,11 +481,13 @@ class PurchasePremiumPlanScreen extends ConsumerStatefulWidget {
|
||||
this.isExpired,
|
||||
this.enrolledPlan,
|
||||
this.willExpire,
|
||||
this.initiallyShowDialog = true,
|
||||
});
|
||||
final bool isCameBack;
|
||||
final bool? isExpired;
|
||||
final bInfo.EnrolledPlan? enrolledPlan;
|
||||
final String? willExpire;
|
||||
final bool initiallyShowDialog;
|
||||
|
||||
@override
|
||||
ConsumerState<PurchasePremiumPlanScreen> createState() => _SubscriptionPlanScreenState();
|
||||
@@ -576,7 +578,7 @@ class _SubscriptionPlanScreenState extends ConsumerState<PurchasePremiumPlanScre
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.isExpired == true) {
|
||||
if (widget.isExpired == true && widget.initiallyShowDialog) {
|
||||
getUpgradeDialog();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user