update subcription portal
This commit is contained in:
@@ -6,7 +6,12 @@ import '../constant.dart';
|
|||||||
import '../generated/l10n.dart' as lang;
|
import '../generated/l10n.dart' as lang;
|
||||||
import '../model/business_info_model.dart';
|
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(
|
return AlertDialog(
|
||||||
backgroundColor: kWhite,
|
backgroundColor: kWhite,
|
||||||
surfaceTintColor: kWhite,
|
surfaceTintColor: kWhite,
|
||||||
@@ -24,7 +29,11 @@ Widget goToPackagePagePopup({required BuildContext context, required EnrolledPla
|
|||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
|
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
if (onCancel != null) {
|
||||||
|
onCancel();
|
||||||
|
} else {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.close,
|
Icons.close,
|
||||||
@@ -56,11 +65,55 @@ Widget goToPackagePagePopup({required BuildContext context, required EnrolledPla
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
ElevatedButton(
|
Row(
|
||||||
child: Text(lang.S.of(context).upgradeNow),
|
children: [
|
||||||
onPressed: () {
|
Expanded(
|
||||||
Navigator.pop(context);
|
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),
|
const SizedBox(height: 5),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import '../barcode/gererate_barcode.dart';
|
|||||||
import '../cash and bank/cheques/cheques_list_screen.dart';
|
import '../cash and bank/cheques/cheques_list_screen.dart';
|
||||||
import '../language/language.dart';
|
import '../language/language.dart';
|
||||||
import '../subscription/package_screen.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';
|
import 'delete_acount_allart_dialog.dart';
|
||||||
|
|
||||||
class SettingScreen extends ConsumerStatefulWidget {
|
class SettingScreen extends ConsumerStatefulWidget {
|
||||||
@@ -131,6 +133,19 @@ class SettingScreenState extends ConsumerState<SettingScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
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;
|
final _previousCurrency = currency;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:mobile_pos/currency.dart';
|
|||||||
|
|
||||||
import '../../Const/api_config.dart';
|
import '../../Const/api_config.dart';
|
||||||
import '../../GlobalComponents/bar_code_scaner_widget.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 '../Sales/provider/sales_cart_provider.dart';
|
||||||
import '../../Provider/product_provider.dart';
|
import '../../Provider/product_provider.dart';
|
||||||
import '../../model/add_to_cart_model.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/model/category_model.dart';
|
||||||
import '../product_category/provider/product_category_provider/product_unit_provider.dart';
|
import '../product_category/provider/product_category_provider/product_unit_provider.dart';
|
||||||
import 'package:mobile_pos/generated/l10n.dart' as lang;
|
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 {
|
class PosSaleScreen extends ConsumerStatefulWidget {
|
||||||
const PosSaleScreen({super.key});
|
const PosSaleScreen({super.key});
|
||||||
@@ -60,6 +66,47 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
|||||||
ref.refresh(cartNotifier);
|
ref.refresh(cartNotifier);
|
||||||
filteredProducts = ref.read(productProvider).value ?? [];
|
filteredProducts = ref.read(productProvider).value ?? [];
|
||||||
productController.addListener(_applyFilters);
|
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
|
@override
|
||||||
|
|||||||
@@ -481,11 +481,13 @@ class PurchasePremiumPlanScreen extends ConsumerStatefulWidget {
|
|||||||
this.isExpired,
|
this.isExpired,
|
||||||
this.enrolledPlan,
|
this.enrolledPlan,
|
||||||
this.willExpire,
|
this.willExpire,
|
||||||
|
this.initiallyShowDialog = true,
|
||||||
});
|
});
|
||||||
final bool isCameBack;
|
final bool isCameBack;
|
||||||
final bool? isExpired;
|
final bool? isExpired;
|
||||||
final bInfo.EnrolledPlan? enrolledPlan;
|
final bInfo.EnrolledPlan? enrolledPlan;
|
||||||
final String? willExpire;
|
final String? willExpire;
|
||||||
|
final bool initiallyShowDialog;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<PurchasePremiumPlanScreen> createState() => _SubscriptionPlanScreenState();
|
ConsumerState<PurchasePremiumPlanScreen> createState() => _SubscriptionPlanScreenState();
|
||||||
@@ -576,7 +578,7 @@ class _SubscriptionPlanScreenState extends ConsumerState<PurchasePremiumPlanScre
|
|||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (widget.isExpired == true) {
|
if (widget.isExpired == true && widget.initiallyShowDialog) {
|
||||||
getUpgradeDialog();
|
getUpgradeDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user