Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Changes
- Fix: issue with no size found text

### 2.12.13
- Fix: External Link redirect issue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean? = null,
): String {
return when {
isAccessory() -> accessoryText(i18nLocalization, sizeComparisonRecommendedSize)
Expand All @@ -49,12 +50,14 @@ data class Product(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = sizeComparisonRecommendedSize,
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
bodyProfileWillFit = bodyProfileWillFit,
)
else ->
multiSizeText(
i18nLocalization,
sizeComparisonRecommendedSize,
bodyProfileRecommendedSizeName,
bodyProfileWillFit,
)
}
}
Expand Down Expand Up @@ -88,13 +91,27 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean?,
): String {
bodyProfileRecommendedSizeName?.let {
return i18nLocalization.oneSizeWillFitResultText
// Check if body data is provided (bodyProfileRecommendedSizeName is not null means body data was provided)
val hasBodyData = bodyProfileRecommendedSizeName != null

// For one-size products with body data provided
if (hasBodyData) {
// If willFit is true and we have a recommended size, show the will fit message
if (bodyProfileWillFit == true) {
return i18nLocalization.oneSizeWillFitResultText
}
// If willFit is false or no recommended size, show "Your size not found"
return i18nLocalization.willNotFitResultText
}

// No body data provided, check for product comparison
sizeComparisonRecommendedSize?.let {
return i18nLocalization.getOneSizeProductComparisonText(it)
}

// No data at all, show body data empty message
return i18nLocalization.bodyDataEmptyText
}

Expand All @@ -105,15 +122,29 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean?,
): String {
bodyProfileRecommendedSizeName?.let {
return i18nLocalization.getMultiSizeBodyProfileText(
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
)
// Check if body data is provided
val hasBodyData = bodyProfileRecommendedSizeName != null

// For multi-size products with body data provided
if (hasBodyData) {
// If willFit is true and we have a recommended size, show it
if (bodyProfileWillFit == true && bodyProfileRecommendedSizeName.isNotEmpty()) {
return i18nLocalization.getMultiSizeBodyProfileText(
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
)
}
// If willFit is false or no recommended size, show "Your size not found"
return i18nLocalization.willNotFitResultText
}

// No body data provided, check for product comparison
sizeComparisonRecommendedSize?.bestStoreProductSize?.name?.let {
return i18nLocalization.getMultiSizeProductComparisonText(it)
}

// No data at all, show body data empty message
return i18nLocalization.bodyDataEmptyText
}

Expand Down
2 changes: 1 addition & 1 deletion virtusize-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<string name="inpage_one_size_will_fit_result_text">This item should fit you</string>
<string name="inpage_multi_size_comparison_text">The closest size to your item is</string>
<string name="inpage_will_fit_result_text">Your recommended size is</string>
<string name="inpage_will_not_fit_result_text">Check how it fits you</string>
<string name="inpage_will_not_fit_result_text">Your size not found</string>
<string name="inpage_body_data_empty_text">Find your right size</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ internal class VirtusizeImpl(
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
) {
val storeProduct = virtusizeRepository.getProductBy(externalProductId)
virtusizeViews
Expand All @@ -266,6 +267,7 @@ internal class VirtusizeImpl(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = userProductRecommendedSize,
bodyProfileRecommendedSizeName = userBodyRecommendedSize,
bodyProfileWillFit = userBodyWillFit,
).trimI18nText(trimType)
virtusizeView.setRecommendationText(
externalProductId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal interface VirtusizePresenter {
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
)

fun hasInPageError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class VirtusizeRepository internal constructor(
private var userProducts: List<Product>? = null
private var userProductRecommendedSize: SizeComparisonRecommendedSize? = null
private var userBodyRecommendedSize: String? = null
private var userBodyWillFit: Boolean? = null

// This variable holds the list of product types from the Virtusize API
private var productTypes: List<ProductType>? = null
Expand Down Expand Up @@ -373,6 +374,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = userProductRecommendedSize,
userBodyRecommendedSize = null,
userBodyWillFit = null,
)
}

Expand All @@ -381,6 +383,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = null,
userBodyRecommendedSize = userBodyRecommendedSize,
userBodyWillFit = userBodyWillFit,
)
}

Expand All @@ -389,6 +392,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = userProductRecommendedSize,
userBodyRecommendedSize = userBodyRecommendedSize,
userBodyWillFit = userBodyWillFit,
)
}
}
Expand All @@ -406,6 +410,7 @@ class VirtusizeRepository internal constructor(
userProducts = null
userProductRecommendedSize = null
userBodyRecommendedSize = null
userBodyWillFit = null
}

/**
Expand All @@ -419,6 +424,7 @@ class VirtusizeRepository internal constructor(
productTypes: List<ProductType>?,
): String? {
if (storeProduct == null || productTypes == null || storeProduct.isAccessory()) {
userBodyWillFit = null
return null
}
val userBodyProfileResponse = virtusizeAPIService.getUserBodyProfile()
Expand All @@ -430,6 +436,7 @@ class VirtusizeRepository internal constructor(
storeProduct,
userBodyProfileResponse.successData!!,
)
userBodyWillFit = bodyProfileRecommendedSizeResponse.successData?.willFit
return bodyProfileRecommendedSizeResponse.successData?.sizeName
} else {
val bodyProfileRecommendedSizeResponse =
Expand All @@ -438,13 +445,15 @@ class VirtusizeRepository internal constructor(
storeProduct,
userBodyProfileResponse.successData!!,
)
userBodyWillFit = bodyProfileRecommendedSizeResponse.successData?.get(0)?.willFit
return bodyProfileRecommendedSizeResponse.successData?.get(0)?.sizeName
}
} else if (userBodyProfileResponse.failureData?.code != HttpURLConnection.HTTP_NOT_FOUND) {
userBodyProfileResponse.failureData?.let {
messageHandler.onError(it)
}
}
userBodyWillFit = null
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ internal class I18nLocalizationJsonParser(
),
)?.trim().orEmpty()

val willNotFitResultText =
inpageJSONObject?.optString(
FIELD_WILL_NOT_FIT_RESULT,
configuredContext.getString(
com.virtusize.android.core.R.string.inpage_will_not_fit_result_text,
),
)?.trim().orEmpty()
val willNotFitResultText = configuredContext.getString(
com.virtusize.android.core.R.string.inpage_will_not_fit_result_text,
)

val bodyDataEmptyText =
inpageJSONObject?.optString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ internal class VirtusizeFlutterImpl(
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
) {
val storeProduct = virtusizeRepository.getProductBy(externalProductId)
val i18nLocalization = virtusizeRepository.i18nLocalization
Expand All @@ -271,13 +272,15 @@ internal class VirtusizeFlutterImpl(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = userProductRecommendedSize,
bodyProfileRecommendedSizeName = userBodyRecommendedSize,
bodyProfileWillFit = userBodyWillFit,
).trimI18nText(I18nLocalization.TrimType.MULTIPLELINES)

virtusizeFlutterPresenter?.gotSizeRecommendations(
externalProductId,
storeProduct,
userProductRecommendedSize?.bestUserProduct,
recommendationText,
userBodyWillFit,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface VirtusizeFlutterPresenter {
storeProduct: Product?,
bestUserProduct: Product?,
recommendationText: String?,
willFit: Boolean?,
)

fun onLangugeClick(language: VirtusizeLanguage)
Expand Down
2 changes: 1 addition & 1 deletion virtusize/src/test/resources/i18n_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"errorTextShort": "Virtusize is not available at the moment.",
"oneSizeText": "There is only size %{value}",
"details": "Details",
"willNotFitResult": "Check how it fits you",
"willNotFitResult": "Your size not found",
"tryItOn": "Try it on",
"accessoriesEmpty": "See what fits inside",
"hasProductAccessoryText": "See the size difference from %{boldStart}your own item%{boldEnd}",
Expand Down
Loading