km away fixed.

wala_plus
FaizHashmi 18 hours ago
parent c3afbdc55b
commit f05aafbd52

@ -779,5 +779,6 @@
"allCities": "الكل",
"noBranchesFound": "لم يتم العثور على فروع مطابقة",
"browseAllBranches": "تصفح جميع الفروع ({}) في مختلف المدن",
"branchesCount": "{} فرع"
"branchesCount": "{} فرع",
"kmAway": "على بعد {} كم"
}

@ -779,5 +779,6 @@
"allCities": "All",
"noBranchesFound": "No branches found",
"browseAllBranches": "Browse all {} branches across cities",
"branchesCount": "{} Branches"
"branchesCount": "{} Branches",
"kmAway": "{} KM Away"
}

@ -795,7 +795,8 @@ class CodegenLoader extends AssetLoader{
"allCities": "الكل",
"noBranchesFound": "لم يتم العثور على فروع مطابقة",
"browseAllBranches": "تصفح جميع الفروع ({}) في مختلف المدن",
"branchesCount": "{} فرع"
"branchesCount": "{} فرع",
"kmAway": "على بعد {} كم"
};
static const Map<String,dynamic> _en_US = {
"mohemm": "Mohemm",
@ -1578,7 +1579,8 @@ static const Map<String,dynamic> _en_US = {
"allCities": "All",
"noBranchesFound": "No branches found",
"browseAllBranches": "Browse all {} branches across cities",
"branchesCount": "{} Branches"
"branchesCount": "{} Branches",
"kmAway": "{} KM Away"
};
static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": _ar_SA, "en_US": _en_US};
}

@ -768,6 +768,7 @@ abstract class LocaleKeys {
static const noBranchesFound = 'noBranchesFound';
static const browseAllBranches = 'browseAllBranches';
static const branchesCount = 'branchesCount';
static const kmAway = 'kmAway';
}

@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:developer';
import 'package:easy_localization/easy_localization.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart';
@ -749,6 +750,17 @@ class WalaPlusRetailerLocation {
return data;
}
// distance comes from the API as a raw numeric string (e.g. "14.729670498669968") -
// round to max 2 decimal places and append the localized "KM Away" label.
String? getDisplayDistance() {
if (distance == null) return null;
double? km = double.tryParse(distance!.trim());
if (km == null) return null;
String formatted = km.toStringAsFixed(2);
log("formatted: ${[formatted]}");
return LocaleKeys.kmAway.tr(args: [formatted]);
}
String getLocalizedCity(bool isAr) {
if (isAr) {
if (cityNameAr != null && cityNameAr!.trim().isNotEmpty && cityNameAr != "null") {

@ -839,7 +839,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
}
Widget _buildLocationCard(WalaPlusRetailerLocation loc, bool isAr) {
String distanceText = (loc.distance != null && loc.distance!.trim().isNotEmpty && loc.distance != "null") ? loc.distance!.trim() : "";
String distanceText = loc.getDisplayDistance() ?? "";
String cityText = loc.getLocalizedCity(isAr);
if (cityText.isEmpty) {
cityText = loc.city ?? "";

Loading…
Cancel
Save