From 81895849dfb069df7c0bb6f44d140404a7254e4f Mon Sep 17 00:00:00 2001 From: Abdusalom G'ayratov Date: Mon, 8 Dec 2025 13:51:09 +0500 Subject: [PATCH] BASE: Implement Localization In Home Screen. --- assets/translations/en.json | 12 +- lib/constant/const_texts.dart | 22 +-- .../home_screen/home_screen.dart | 42 +++--- .../service_list_screen.dart | 137 +++++++++++++++--- 4 files changed, 157 insertions(+), 56 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index f841b8b..d4e1498 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -129,6 +129,16 @@ "newArrival": "New Arrivals", "topBrands": "Top Brands", "styleUp": "Style up with the latest fits, now at unbeatable prices.", - "additionlOffers": "Additional Offers" + "additionlOffers": "Additional Offers", + "largestDiscounts": "Largest Discounts", + "newArrivals": "New Arrivals", + "popularStores": "Popular Stores", + "allStores": "All Stores", + "alert": "Alert", + "cancel": "Cancel", + "ok": "Ok", + "doYouWantChangeTheDeliverOption": "Do you really want to change the delivery option? Your cart will be empty.", + "freeDelivery": "Free Delivery", + "upto": "Upto" } \ No newline at end of file diff --git a/lib/constant/const_texts.dart b/lib/constant/const_texts.dart index beb1fbf..0216b5c 100644 --- a/lib/constant/const_texts.dart +++ b/lib/constant/const_texts.dart @@ -130,15 +130,15 @@ class ConstTexts { static String topBrands = "topBrands"; static String styleUp = "styleUp"; static String additionlOffers = "additionlOffers"; - // static String enableLocation = "enableLocation"; - // static String allowLocation = "allowLocation"; - // static String useCurrentLocation = "useCurrentLocation"; - // static String setFromMap = "setFromMap"; - // static String enterManuallyLocation = "enterManuallyLocation"; - // static String changeLanguage = "changeLanguage"; - // static String aroundTheCity = "aroundTheCity"; - // static String rideDetails = "rideDetails"; - // static String youDoNothaveSufficientwalletBalance = "youDoNothaveSufficientwalletBalance"; - // static String somethingWentWrong = "somethingWentWrong"; - // static String cash = "cash"; + static String largestDiscounts = "largestDiscounts"; + static String newArrivals = "newArrivals"; + static String popularStores = "popularStores"; + static String allStores = "allStores"; + static String alert = "alert"; + static String cancel = "cancel"; + static String ok = "ok"; + static String freeDelivery = "freeDelivery"; + static String upto = "upto"; + static String doYouWantChangeTheDeliverOption = "doYouWantChangeTheDeliverOption"; + static String cash = "cash"; } diff --git a/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart index a321769..346d662 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart @@ -654,7 +654,7 @@ class HomeScreen extends StatelessWidget { children: [ titleView( isDark, - "Largest Discounts", + ConstTexts.largestDiscounts.tr, () { Get.to( const DiscountRestaurantListScreen(), @@ -709,7 +709,7 @@ class HomeScreen extends StatelessWidget { children: [ Expanded( child: Text( - "New Arrivals".tr, + ConstTexts.newArrival.tr, textAlign: TextAlign .start, @@ -744,7 +744,7 @@ class HomeScreen extends StatelessWidget { }); }, child: Text( - "View all".tr, + ConstTexts.viewAll.tr, textAlign: TextAlign .center, @@ -825,7 +825,7 @@ class HomeScreen extends StatelessWidget { children: [ Expanded( child: Text( - "Highlights for you" + ConstTexts.highlightsForU .tr, textAlign: TextAlign @@ -855,7 +855,7 @@ class HomeScreen extends StatelessWidget { }); }, child: Text( - "View all" + ConstTexts.viewAll .tr, textAlign: TextAlign @@ -971,7 +971,7 @@ class HomeScreen extends StatelessWidget { vertical: 10, ), child: Text( - "Popular Stores" + ConstTexts.popularStores .tr, textAlign: TextAlign @@ -1025,7 +1025,7 @@ class HomeScreen extends StatelessWidget { vertical: 10, ), child: Text( - "All Stores".tr, + ConstTexts.allStores.tr, textAlign: TextAlign .center, @@ -1247,12 +1247,12 @@ class HomeScreen extends StatelessWidget { context: context, builder: (BuildContext context) { return CustomDialogBox( - title: "Alert".tr, + title: ConstTexts.alert.tr, descriptions: - "Do you really want to change the delivery option? Your cart will be empty." + ConstTexts.doYouWantChangeTheDeliverOption .tr, - positiveString: "Ok".tr, - negativeString: "Cancel".tr, + positiveString: ConstTexts.ok.tr, + negativeString: ConstTexts.cancel.tr, positiveClick: () async { await Preferences.setString( Preferences.foodDeliveryType, @@ -1305,7 +1305,7 @@ class HomeScreen extends StatelessWidget { onPress!(); }, child: Text( - "View all".tr, + ConstTexts.viewAll.tr, textAlign: TextAlign.center, style: TextStyle( fontFamily: AppThemeData.regular, @@ -1479,7 +1479,7 @@ class PopularRestaurant extends StatelessWidget { ), const SizedBox(width: 5), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, style: TextStyle( fontSize: 14, color: AppThemeData.carRent600, @@ -1685,7 +1685,7 @@ class AllRestaurant extends StatelessWidget { begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [ - Colors.black.withOpacity(0), + Colors.black.withValues(alpha: 0), const Color(0xFF111827), ], ), @@ -1784,7 +1784,7 @@ class AllRestaurant extends StatelessWidget { ), const SizedBox(width: 5), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, style: TextStyle( fontSize: 14, color: AppThemeData.carRent600, @@ -2081,7 +2081,7 @@ class NewArrival extends StatelessWidget { ), const SizedBox(width: 4), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -2491,7 +2491,7 @@ class OfferView extends StatelessWidget { begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [ - Colors.black.withOpacity(0), + Colors.black.withValues(alpha: 0), AppThemeData.grey900, ], ), @@ -2504,7 +2504,7 @@ class OfferView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Upto".tr, + ConstTexts.upto.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -2568,7 +2568,7 @@ class OfferView extends StatelessWidget { ), const SizedBox(width: 5), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, style: TextStyle( fontSize: 12, overflow: TextOverflow.ellipsis, @@ -3268,7 +3268,7 @@ class MapView extends StatelessWidget { ), colors: [ Colors.black - .withOpacity(0), + .withValues(alpha: 0), const Color( 0xFF111827, ), @@ -3403,7 +3403,7 @@ class MapView extends StatelessWidget { width: 5, ), Text( - "Free Delivery" + ConstTexts.freeDelivery .tr, style: TextStyle( fontSize: diff --git a/lib/screen_ui/service_home_screen/service_list_screen.dart b/lib/screen_ui/service_home_screen/service_list_screen.dart index ec76d86..81faa14 100644 --- a/lib/screen_ui/service_home_screen/service_list_screen.dart +++ b/lib/screen_ui/service_home_screen/service_list_screen.dart @@ -80,26 +80,118 @@ class ServiceListScreen extends StatelessWidget { SizedBox(height: 10.h), // Other Services Section - _otherServicesCardMaker( - image: "assets/images/garderob_img.png", - title: ConstTexts.updateYourWardrobe.tr, - subtitle: ConstTexts.weDeliverSafely.tr, - ), - _otherServicesCardMaker( - image: "assets/images/keys_img.png", - title: ConstTexts.rent.tr, - subtitle: ConstTexts.hugeSelectionOfAds.tr, - ), - _otherServicesCardMaker( - image: "assets/images/cosmetics_img.png", - title: ConstTexts.cosmetics.tr, - subtitle: ConstTexts.moreThan1000Products.tr, - ), - _otherServicesCardMaker( - image: "assets/images/products_img.png", - title: ConstTexts.foodProducts.tr, - subtitle: ConstTexts.moreThan1000Products.tr, - ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/garderob_img.png", + title: ConstTexts.updateYourWardrobe.tr, + subtitle: ConstTexts.weDeliverSafely.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "rental-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/keys_img.png", + title: ConstTexts.rent.tr, + subtitle: ConstTexts.hugeSelectionOfAds.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "rental-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ecommerce-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/cosmetics_img.png", + title: ConstTexts.cosmetics.tr, + subtitle: ConstTexts.moreThan1000Products.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ecommerce-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/products_img.png", + title: ConstTexts.foodProducts.tr, + subtitle: ConstTexts.moreThan1000Products.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), SizedBox(height: 45.h), ], ), @@ -113,11 +205,10 @@ class ServiceListScreen extends StatelessWidget { required String image, required String title, required String subtitle, + required VoidCallback onTap, }) { return InkWell( - onTap: () { - log("Other Service Card Tapped: $title"); - }, + onTap: onTap, child: Container( width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 16.r).copyWith(bottom: 10.r),