     
     typealias ThemeType = MediaPickerRootModuleUITheme
     
-    private var isBeingRotated: Bool = false
     private let mediaPickerView = MediaPickerView()
     private var layoutSubviewsPromise = Promise<Void>()
     

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        if !isBeingRotated {
            layoutMediaPickerView(interfaceOrientation: interfaceOrientation)
        }
        onPreviewSizeDetermined?(mediaPickerView.previewSize)
        layoutSubviewsPromise.fulfill()
    }
    
    override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
        if shouldAutorotate {
            // Compensation animation for rotation.
            UIView.animate(
                withDuration: duration,
                animations: {
                    self.layoutMediaPickerView(interfaceOrientation: toInterfaceOrientation)
            })
        }
        super.willAnimateRotation(to: toInterfaceOrientation, duration: duration)
    }
    
    override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) {
        super.didRotate(from: fromInterfaceOrientation)
        
        if shouldAutorotate {
            layoutMediaPickerView(interfaceOrientation: interfaceOrientation)
        }
        isBeingRotated = false
    }
    
    override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
        super.willRotate(to: toInterfaceOrientation, duration: duration)
        isBeingRotated = true
    }
    
    override open var shouldAutorotate: Bool {

    func setCameraToggleButtonVisible(_ visible: Bool) {
        mediaPickerView.setCameraToggleButtonVisible(visible)
    }
    
    func addItems(_ items: [MediaPickerItem], animated: Bool, completion: @escaping () -> ()) {
        mediaPickerView.addItems(items, animated: animated, completion: completion)
    }
