From bd3f25ad57b32eb4c0c3353403458136b8fbecaf Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" <> Date: Wed, 17 Jul 2024 11:27:59 +0300 Subject: [PATCH] Localization --- lib/views/dashboard/dashboard_page.dart | 29 +++++++++-------- .../subscriptions/my_subscritions_page.dart | 4 ++- .../sheet/degrage_package_sheet.dart | 2 +- .../subscriptions/subscriptions_page.dart | 31 +++++++++++++------ 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/lib/views/dashboard/dashboard_page.dart b/lib/views/dashboard/dashboard_page.dart index 7d54a94..023abf9 100644 --- a/lib/views/dashboard/dashboard_page.dart +++ b/lib/views/dashboard/dashboard_page.dart @@ -129,19 +129,22 @@ class _DashboardPageState extends State { ), ]; - return Scaffold( - key: _scaffoldKey, - // drawer: CustomDrawer(dashboardVM: dashboardVM), - // body: Consumer(builder: (context, model, _) { - // return fragments[dashboardVM.selectedNavbarBarIndex]; - // }), - body: fragments[context.watch().selectedNavbarBarIndex], - bottomNavigationBar: CustomBottomNavbar( - onSelected: (i) { - dashboardVM.updateIndex(i); - }, - isProvider: true, - selectedNavbarBarIndex: dashboardVM.selectedNavbarBarIndex, + return PopScope( + canPop: false, + child: Scaffold( + key: _scaffoldKey, + // drawer: CustomDrawer(dashboardVM: dashboardVM), + // body: Consumer(builder: (context, model, _) { + // return fragments[dashboardVM.selectedNavbarBarIndex]; + // }), + body: fragments[context.watch().selectedNavbarBarIndex], + bottomNavigationBar: CustomBottomNavbar( + onSelected: (i) { + dashboardVM.updateIndex(i); + }, + isProvider: true, + selectedNavbarBarIndex: dashboardVM.selectedNavbarBarIndex, + ), ), ); } diff --git a/lib/views/subscriptions/my_subscritions_page.dart b/lib/views/subscriptions/my_subscritions_page.dart index ed0a0ca..92fa299 100644 --- a/lib/views/subscriptions/my_subscritions_page.dart +++ b/lib/views/subscriptions/my_subscritions_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; +import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; @@ -15,6 +16,7 @@ import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:provider/provider.dart'; +import 'package:easy_localization/easy_localization.dart'; class MySubscriptionsPage extends StatelessWidget { const MySubscriptionsPage({Key? key}) : super(key: key); @@ -84,7 +86,7 @@ class MySubscriptionsPage extends StatelessWidget { ), 21.height, ShowFillButton( - title: "Modify Package", + title: LocaleKeys.modifyPackage.tr(), maxWidth: double.infinity, margin: const EdgeInsets.symmetric(horizontal: 21), onPressed: () { diff --git a/lib/views/subscriptions/sheet/degrage_package_sheet.dart b/lib/views/subscriptions/sheet/degrage_package_sheet.dart index f6ceaf0..c480ee1 100644 --- a/lib/views/subscriptions/sheet/degrage_package_sheet.dart +++ b/lib/views/subscriptions/sheet/degrage_package_sheet.dart @@ -16,7 +16,7 @@ class DegradePackageSheet extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - "Deactivate the branches & users".toText( + "Deactivate the branches & users ".toText( fontSize: 18, isBold: true, ), diff --git a/lib/views/subscriptions/subscriptions_page.dart b/lib/views/subscriptions/subscriptions_page.dart index 2426a92..48d4b45 100644 --- a/lib/views/subscriptions/subscriptions_page.dart +++ b/lib/views/subscriptions/subscriptions_page.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:car_provider_app/views/subscriptions/sheet/downgrade_data_sheet.dart'; import 'package:car_provider_app/views/subscriptions/sheet/upgrade_package_sheet.dart'; @@ -17,15 +18,28 @@ import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart'; import 'package:mc_common_app/widgets/tab/menu_tabs.dart'; import 'package:provider/provider.dart'; -class SubscriptionsPage extends StatelessWidget { +class SubscriptionsPage extends StatefulWidget { const SubscriptionsPage({Key? key}) : super(key: key); + @override + State createState() => _SubscriptionsPageState(); +} + +class _SubscriptionsPageState extends State { + @override + void initState() { + // TODO: implement initState + super.initState(); + scheduleMicrotask(() { + context.read().getSubscriptionBySP( + AppState().getUser.data?.userInfo?.providerId.toString() ?? "", + true, + ); + }); + } + @override Widget build(BuildContext context) { - context.read().getSubscriptionBySP( - AppState().getUser.data?.userInfo?.providerId.toString() ?? "", - true, - ); return Scaffold( appBar: const CustomAppBar( title: "Subscriptions", @@ -65,12 +79,11 @@ class SubscriptionsPage extends StatelessWidget { // AppRoutes.paymentMethodsView, // arguments: PaymentTypes.subscription, // ); - if(model.tempSubscriptions[index].subscriptionTypeEnum==SubscriptionTypeEnum.upgrade){ - showMyBottomSheet(context, child: UpgradePackageSheet(model.tempSubscriptions[index])); - }else{ + if (model.tempSubscriptions[index].subscriptionTypeEnum == SubscriptionTypeEnum.upgrade) { + showMyBottomSheet(context, child: UpgradePackageSheet(model.tempSubscriptions[index])); + } else { showMyBottomSheet(context, child: DowngradeDataSheet(model.tempSubscriptions[index])); } - }, ); },