     weak var conversation:VChatConversation!
     weak var emojiKeyboard:VChatEmojiKeyboard!
     weak var layoutInputBottom:NSLayoutConstraint!
+    weak var spinner:VMainLoader?
     private let kAnimationDuration:TimeInterval = 0.4
     
     convenience init(controller:CChat)

        translatesAutoresizingMaskIntoConstraints = false
        self.controller = controller
        
        let input:VChatInput = VChatInput(controller:controller)
        self.input = input
        
        let conversation:VChatConversation = VChatConversation(controller:controller)
        self.conversation = conversation
        
        let display:VChatDisplay = VChatDisplay(controller:controller)
        self.display = display
        
        let emojiKeyboard:VChatEmojiKeyboard = VChatEmojiKeyboard(controller:controller)
        self.emojiKeyboard = emojiKeyboard
        
        addSubview(conversation)
        addSubview(display)
        addSubview(input)
        addSubview(emojiKeyboard)
        
        let views:[String:UIView] = [
            "input":input,
            "conversation":conversation,
            "display":display,
            "emojiKeyboard":emojiKeyboard]
        
        let metrics:[String:CGFloat] = [:]
        
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[input]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[display]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[conversation]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[emojiKeyboard]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"V:|-0-[conversation]-0-[display]-0-[input]",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"V:[emojiKeyboard]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        
        layoutInputBottom = NSLayoutConstraint(
            item:input,
            attribute:NSLayoutAttribute.bottom,
            relatedBy:NSLayoutRelation.equal,
            toItem:self,
            attribute:NSLayoutAttribute.bottom,
            multiplier:1,
            constant:0)
        input.layoutHeight = NSLayoutConstraint(
            item:input,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:input.kMinHeight)
        display.layoutHeight = NSLayoutConstraint(
            item:display,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:display.kMinHeight)
        emojiKeyboard.layoutHeight = NSLayoutConstraint(
            item:emojiKeyboard,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:0)
        
        addConstraint(layoutInputBottom)
        addConstraint(input.layoutHeight)
        addConstraint(display.layoutHeight)
        addConstraint(emojiKeyboard.layoutHeight)
        
        listenToKeyboard()
    }
    
    deinit

    
    //MARK: private
    
    private func chatLoaded()
    {
        spinner?.removeFromSuperview()
        
        let input:VChatInput = VChatInput(controller:controller)
        self.input = input
        
        let conversation:VChatConversation = VChatConversation(controller:controller)
        self.conversation = conversation
        
        let display:VChatDisplay = VChatDisplay(controller:controller)
        self.display = display
        
        let emojiKeyboard:VChatEmojiKeyboard = VChatEmojiKeyboard(controller:controller)
        self.emojiKeyboard = emojiKeyboard
        
        addSubview(conversation)
        addSubview(display)
        addSubview(input)
        addSubview(emojiKeyboard)
        
        let views:[String:UIView] = [
            "input":input,
            "conversation":conversation,
            "display":display,
            "emojiKeyboard":emojiKeyboard]
        
        let metrics:[String:CGFloat] = [:]
        
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[input]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[display]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[conversation]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[emojiKeyboard]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"V:|-0-[conversation]-0-[display]-0-[input]",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"V:[emojiKeyboard]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        
        layoutInputBottom = NSLayoutConstraint(
            item:input,
            attribute:NSLayoutAttribute.bottom,
            relatedBy:NSLayoutRelation.equal,
            toItem:self,
            attribute:NSLayoutAttribute.bottom,
            multiplier:1,
            constant:0)
        input.layoutHeight = NSLayoutConstraint(
            item:input,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:input.kMinHeight)
        display.layoutHeight = NSLayoutConstraint(
            item:display,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:display.kMinHeight)
        emojiKeyboard.layoutHeight = NSLayoutConstraint(
            item:emojiKeyboard,
            attribute:NSLayoutAttribute.height,
            relatedBy:NSLayoutRelation.equal,
            toItem:nil,
            attribute:NSLayoutAttribute.notAnAttribute,
            multiplier:1,
            constant:0)
        
        addConstraint(layoutInputBottom)
        addConstraint(input.layoutHeight)
        addConstraint(display.layoutHeight)
        addConstraint(emojiKeyboard.layoutHeight)
        
        listenToKeyboard()
    }
    
    private func animateInput(bottom:CGFloat)
    {
        let currentOffset:CGPoint = conversation.collectionView.contentOffset
