decord/source/modules/collectibles/native/hooks/useCardLayout.tsx

89 lines
2.9 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 15031
// Function ID: 15032
2026-07-29 08:29:29 +00:00
// Name: useCardLayout
2026-08-24 06:08:38 +00:00
// Dependencies: [9209, 1494, 2]
2026-07-20 16:05:17 +00:00
// Exports: useCardLayout
2026-08-24 06:08:38 +00:00
// Module 15031 (useCardLayout)
import set from "set" /* 2 */;
import useWindowDimensionsDefault from "useWindowDimensions" /* 1494 */;
import CollectiblesShopCardInternalV2 from "CollectiblesShopCardInternalV2" /* 9209 */;
let result = set.fileFinishedImporting("modules/collectibles/native/hooks/useCardLayout.tsx");
2026-07-20 16:05:17 +00:00
export const useCardLayout = function useCardLayout() {
2026-08-24 06:08:38 +00:00
const width = useWindowDimensionsDefault().width;
2026-07-20 16:05:17 +00:00
let num = 1;
if (width >= 320) {
num = 2;
}
if (num < 2) {
2026-08-24 06:08:38 +00:00
let obj = { columns: null, cardWidth: "Array", rowWidth: "applicationId" };
2026-07-29 08:29:29 +00:00
obj[0] = num;
2026-07-20 16:05:17 +00:00
return obj;
} else {
let num2 = 2;
if (width >= 768) {
num2 = 4;
}
2026-08-24 06:08:38 +00:00
const result = CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_WIDTH * num;
2026-07-29 08:29:29 +00:00
const diff = num - 1;
2026-08-24 06:08:38 +00:00
const diff1 = width - (result + CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_GAP * diff);
if (diff1 < 2 * CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_GAP) {
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-07-29 08:29:29 +00:00
let bound = Math.max(4, diff1);
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
bound = 2 * tmp2(9209).COLLECTIBLES_SHOP_CARD_GAP;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const result1 = (width - (bound + tmp2(9209).COLLECTIBLES_SHOP_CARD_GAP * diff)) / num;
2026-07-29 08:29:29 +00:00
let tmp10 = tmp2;
let tmp11 = result1;
let tmp12 = num;
let tmp14 = tmp2;
2026-08-24 06:08:38 +00:00
if (result1 > CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_MAX_WIDTH) {
2026-07-29 08:29:29 +00:00
let tmp19 = num;
tmp10 = tmp2;
tmp11 = result1;
tmp14 = tmp2;
tmp12 = num;
2026-07-20 16:05:17 +00:00
if (num < num2) {
2026-07-29 08:29:29 +00:00
const sum = tmp19 + 1;
2026-08-24 06:08:38 +00:00
const result2 = (width - (bound + CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_GAP * (sum - 1))) / sum;
2026-07-29 08:29:29 +00:00
tmp10 = require;
tmp11 = result2;
tmp12 = sum;
tmp14 = require;
2026-08-24 06:08:38 +00:00
while (result2 > CollectiblesShopCardInternalV2.COLLECTIBLES_SHOP_CARD_MAX_WIDTH) {
2026-07-29 08:29:29 +00:00
tmp19 = sum;
let tmp9 = tmp17;
tmp10 = tmp16;
tmp11 = result2;
let tmp13 = tmp17;
tmp14 = tmp16;
tmp12 = sum;
2026-07-20 16:05:17 +00:00
if (sum >= num2) {
break;
}
}
}
}
const _Math2 = Math;
const _Math3 = Math;
2026-08-24 06:08:38 +00:00
const bound1 = Math.max(tmp11, tmp14(9209).COLLECTIBLES_SHOP_CARD_WIDTH);
const bound2 = Math.min(bound1, tmp14(9209).COLLECTIBLES_SHOP_CARD_MAX_WIDTH);
2026-07-29 08:29:29 +00:00
const result3 = bound2 * tmp12;
const diff2 = tmp12 - 1;
2026-08-24 06:08:38 +00:00
if (result3 + (bound + tmp10(9209).COLLECTIBLES_SHOP_CARD_GAP * diff2) > width) {
2026-07-29 08:29:29 +00:00
if (1 < tmp12) {
2026-08-24 06:08:38 +00:00
obj = { columns: 1, cardWidth: "Array", rowWidth: "accessibilityLabel" };
2026-07-20 16:05:17 +00:00
}
return obj;
}
2026-07-29 08:29:29 +00:00
obj = { columns: null, cardWidth: null, rowWidth: null };
obj[0] = tmp12;
obj[1] = bound2;
const result4 = bound2 * tmp12;
2026-08-24 06:08:38 +00:00
obj[2] = result4 + tmp14(9209).COLLECTIBLES_SHOP_CARD_GAP * diff2 + bound;
2026-07-20 16:05:17 +00:00
}
};