         tableView.rowHeight = UITableViewAutomaticDimension
         tableView.estimatedRowHeight = 44
     }
+    
+    // MARK: - ModuleSelectorViewController Delegate
+    
+    func moduleSelectorViewController(moduleSelectorViewController: ModuleSelectorViewController, didtSelectModule module: ComposerModule) {
+        
+        switch module.type{
+            
+        case .ImageModule:
+            
+            let squareSize = CGSizeMake(tableView.frame.width, tableView.frame.width)
+            module.image?.resize(toSize: squareSize, completionHandler: { (resizedImage, data) -> () in
+                module.image = resizedImage
+            })
+            
+        case .TextModule:
+            println()
+        }
+        
+        tableViewDataSource?.tableData.append(module)
+        moduleSelectorViewController.dismissViewControllerAnimated(true, completion: nil)
+    }
+    
+    func moduleSelectorViewControllerWasDismissed(moduleSelectorViewController: ModuleSelectorViewController) {
+        moduleSelectorViewController.dismissViewControllerAnimated(true, completion: nil)
+    }
 
     override func didReceiveMemoryWarning() {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
+
+    // MARK: - Navigation
+
+    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+        
+        if segue.destinationViewController.isKindOfClass(ModuleSelectorViewController){
+            let moduleSelectViewController = segue.destinationViewController as ModuleSelectorViewController
+            moduleSelectViewController.delegate = self
+        }
+    }
     
 
-    /*
-    // MARK: - Navigation
-
-    // In a storyboard-based application, you will often want to do a little preparation before navigation
-    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
-        // Get the new view controller using segue.destinationViewController.
-        // Pass the selected object to the new view controller.
-    }
-    */
-
 }


import UIKit

class ComposerViewController: UIViewController {

    @IBOutlet var tableView: UITableView!
    var tableViewDataSource: ComposerTableViewDataSource?


    override func viewDidLoad() {
        super.viewDidLoad()
        setupTableView()
    }
    
    // MARK: - TableView Setup
