Browse Source

修复擂台切换盒子显示不全

zbb 3 months ago
parent
commit
4abc1f0100
2 changed files with 10 additions and 9 deletions
  1. 3 1
      app/boxInBox/components/BoxPopup.tsx
  2. 7 8
      app/boxInBox/index.tsx

+ 3 - 1
app/boxInBox/components/BoxPopup.tsx

@@ -27,7 +27,8 @@ export const BoxPopup = forwardRef<BoxPopupRef, BoxPopupProps>(({ onSelect }, re
 
   useImperativeHandle(ref, () => ({
     open: (data: BoxItem[]) => {
-      setList(data);
+      console.log('BoxPopup open with data:', data?.length);
+      setList(data || []);
       setActiveBucket(0); // Reset to first bucket
       setVisible(true);
     },
@@ -123,6 +124,7 @@ const styles = StyleSheet.create({
     borderTopLeftRadius: 10,
     borderTopRightRadius: 10,
     maxHeight: '85%', // Increased slightly
+    minHeight: 400, // Ensure popup has height even if list is empty
     paddingBottom: 20,
   },
   titleSection: {

+ 7 - 8
app/boxInBox/index.tsx

@@ -188,14 +188,13 @@ export default function BoxInBoxScreen() {
 
   // 打开换盒弹窗
   const openBoxPopup = useCallback(async () => {
-    if (!poolId) return;
-    try {
-      const res = await getBoxHistory(poolId);
-      if (res && res.length > 0) {
-        boxPopupRef.current?.open(res);
-      }
-    } catch {}
-  }, [poolId]);
+    console.log('Opening Box Popup, history len:', boxHistory?.length);
+    if (!boxHistory || boxHistory.length === 0) {
+      Alert.alert('提示', '暂无盒子数据');
+      return;
+    }
+    boxPopupRef.current?.open(boxHistory);
+  }, [boxHistory]);
 
   // 选择盒子
   const handleSelectBox = useCallback((item: any) => {