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

76 lines
2.7 KiB
TypeScript
Raw Normal View History

2026-07-27 11:26:19 +00:00
// Module ID: 14551
// Function ID: 111122
2026-07-20 16:05:17 +00:00
// Name: calculateTotalGaps
2026-07-25 08:10:48 +00:00
// Dependencies: [8592, 1450, 2]
2026-07-20 16:05:17 +00:00
// Exports: useCardLayout
2026-07-27 11:26:19 +00:00
// Module 14551 (calculateTotalGaps)
2026-07-20 16:05:17 +00:00
function calculateTotalGaps(arg0, arg1) {
2026-07-25 08:10:48 +00:00
return arg1 + require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_GAP * (arg0 - 1);
2026-07-20 16:05:17 +00:00
}
function calculateCardWidth(arg0, arg1, arg2) {
return (arg1 - calculateTotalGaps(arg0, arg2)) / arg0;
}
2026-07-23 10:11:24 +00:00
let result = require("set").fileFinishedImporting("modules/collectibles/native/hooks/useCardLayout.tsx");
2026-07-20 16:05:17 +00:00
export const useCardLayout = function useCardLayout() {
2026-07-23 10:11:24 +00:00
const width = importDefault(1450)().width;
2026-07-20 16:05:17 +00:00
let num = 1;
if (width >= 320) {
num = 2;
}
if (num < 2) {
let obj = { columns: num, cardWidth: undefined, rowWidth: undefined };
return obj;
} else {
let num2 = 2;
if (width >= 768) {
num2 = 4;
}
2026-07-25 08:10:48 +00:00
const result = require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_WIDTH * num;
const diff = width - (result + require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_GAP * (num - 1));
if (diff < 2 * require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_GAP) {
2026-07-20 16:05:17 +00:00
const _Math = Math;
let bound = Math.max(4, diff);
} else {
2026-07-25 08:10:48 +00:00
bound = 2 * require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_GAP;
2026-07-20 16:05:17 +00:00
}
const tmp10 = calculateCardWidth(num, width, bound);
let tmp14 = num;
let tmp15 = tmp10;
2026-07-25 08:10:48 +00:00
if (tmp10 > require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_MAX_WIDTH) {
2026-07-20 16:05:17 +00:00
let tmp16 = num;
tmp15 = tmp10;
tmp14 = num;
if (num < num2) {
const sum = tmp16 + 1;
const tmp19 = calculateCardWidth(sum, width, bound);
tmp14 = sum;
tmp15 = tmp19;
2026-07-25 08:10:48 +00:00
while (tmp19 > require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_MAX_WIDTH) {
2026-07-20 16:05:17 +00:00
tmp16 = sum;
tmp15 = tmp19;
tmp14 = sum;
if (sum >= num2) {
break;
}
}
}
}
const _Math2 = Math;
const _Math3 = Math;
2026-07-25 08:10:48 +00:00
const bound1 = Math.max(tmp15, require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_WIDTH);
const bound2 = Math.min(bound1, require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_MAX_WIDTH);
2026-07-20 16:05:17 +00:00
const result1 = bound2 * tmp14;
if (result1 + calculateTotalGaps(tmp14, bound) > width) {
if (tmp14 > 1) {
obj = { columns: 1, cardWidth: undefined, rowWidth: undefined };
}
return obj;
}
obj = { columns: tmp14, cardWidth: bound2 };
const result2 = bound2 * tmp14;
2026-07-25 08:10:48 +00:00
obj.rowWidth = result2 + require(8592) /* CollectiblesShopCardInternalV2 */.COLLECTIBLES_SHOP_CARD_GAP * (tmp14 - 1) + bound;
2026-07-20 16:05:17 +00:00
}
};