             return CGRect.zero
         }
         if index == 0 {
-            mainItemSize = CGSize(width: photoCollectionView.bounds.width - spacing * 2,
+            mainSize = CGSize(width: photoCollectionView.bounds.width - spacing * 2,
                                   height: photoCollectionView.bounds.height - spacing * 2)
             contentSize = photoCollectionView.bounds.size
             isVertical = false

                let ratio = image.size.height / image.size.width
                isVertical = ratio >= 1.0
                if isVertical {
                    mainItemSize.width = (contentSize.width - spacing * 3) * 0.6
                    mainItemSize.height = mainItemSize.width * min(ratio, 1.25)
                    contentSize.height = mainItemSize.height * 2 + spacing * 3
                    
                    smallItemSize.width = (contentSize.width - spacing * 3) * 0.4
                    smallItemSize.height = (contentSize.height - CGFloat(numSmall + 1) * spacing) / CGFloat(numSmall)
                } else {
                    mainItemSize.height = mainItemSize.width * min(ratio, 0.8)
                    contentSize.height = mainItemSize.height * 1.0 / 0.6 + spacing * 3
                    
                    smallItemSize.width = (contentSize.width - CGFloat(numSmall + 1) * spacing) / CGFloat(numSmall)
                    smallItemSize.height = mainItemSize.height * 0.4 / 0.6
                }
            }
        }
        let smallIndex = CGFloat(index) - 1
        let x = isVertical ? mainItemSize.width + spacing * 2 : spacing + (smallItemSize.width + spacing) * smallIndex
        let y = isVertical ? spacing + (smallItemSize.height + spacing) * smallIndex : mainItemSize.height + spacing * 2
        
        return CGRect(origin: CGPoint(x: x, y: y), size: mainItemSize)
    }
    
    

    var numMain = 2
    var numSmall = 3
    var isVertical = false
    
    var mainSize = CGSize.zero
    var smallSize = CGSize.zero
    var contentSize = CGSize.zero
    
    
