         }
     }
 }
+
+class DefaultSettingsTableViewCell: UITableViewCell {
+    
+    var sw: UISwitch
+    var label: UILabel
+    var longLabel: UITextView
+    var constraintsSetForLongLabel: Bool
+    
+    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+        self.sw = UISwitch()
+        self.label = UILabel()
+        self.longLabel = UITextView()
+        
+        self.constraintsSetForLongLabel = false
+        
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        
+        self.sw.setTranslatesAutoresizingMaskIntoConstraints(false)
+        self.label.setTranslatesAutoresizingMaskIntoConstraints(false)
+        self.longLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
+        
+        self.longLabel.text = nil
+        self.longLabel.scrollEnabled = false
+        self.longLabel.selectable = false
+        self.longLabel.backgroundColor = UIColor.clearColor()
+        
+        self.sw.tag = 1
+        self.label.tag = 2
+        self.longLabel.tag = 3
+
+        self.addSubview(self.sw)
+        self.addSubview(self.label)
+        self.addSubview(self.longLabel)
+        
+        self.addConstraints()
+    }
+
+    required init(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    func addConstraints() {
+        let hasLongText = self.longLabel.text != nil && !self.longLabel.text.isEmpty
+        if hasLongText {
+            let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.RightMargin, multiplier: 1, constant: 0)
+            let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.TopMargin, multiplier: 1, constant: 0)
+            let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.LeftMargin, multiplier: 1, constant: 0)
+            let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: sw, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)
+            
+            self.addConstraint(switchSide)
+            self.addConstraint(switchTop)
+            self.addConstraint(labelSide)
+            self.addConstraint(labelCenter)
+            
+            let left = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.LeftMargin, multiplier: 1, constant: 0)
+            let right = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.RightMargin, multiplier: 1, constant: 0)
+            let top = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: sw, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 8)
+            let bottom = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.BottomMargin, multiplier: 1, constant: 0)
+            
+            self.addConstraint(left)
+            self.addConstraint(right)
+            self.addConstraint(top)
+            self.addConstraint(bottom)
+            
+            self.constraintsSetForLongLabel = true
+        }
+        else {
+            let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.RightMargin, multiplier: 1, constant: 0)
+            let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.TopMargin, multiplier: 1, constant: 0)
+            let switchBottom = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.BottomMargin, multiplier: 1, constant: 0)
+            let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.LeftMargin, multiplier: 1, constant: 0)
+            let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: sw, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)
+            
+            self.addConstraint(switchSide)
+            self.addConstraint(switchTop)
+            self.addConstraint(switchBottom)
+            self.addConstraint(labelSide)
+            self.addConstraint(labelCenter)
+            
+            self.constraintsSetForLongLabel = false
+        }
+    }
+    
+    override func updateConstraints() {
+        super.updateConstraints()
+        
+        let hasLongText = self.longLabel.text != nil && !self.longLabel.text.isEmpty
+        if hasLongText != self.constraintsSetForLongLabel {
+            self.removeConstraints(self.constraints())
+            self.addConstraints()
+        }
+    }
+}


import UIKit

// TODO: move this somewhere else and localize
let settings = [
    (kAutoCapitalization, "Auto-Capitalization"),
    (kPeriodShortcut,  "“.” Shortcut"),
    (kKeyboardClicks, "Keyboard Clicks")
]

let notes = [
    kKeyboardClicks: "Please note that keyboard clicks will work only if “Allow Full Access” is enabled in the keyboard settings. Unfortunately, this is a limitation of the operating system. Rest assured that absoutely none of your keystrokes will be recorded or sent over the network with this setting enabled — it is strictly for sound playback and nothing else."
]

class DefaultSettings: ExtraView, UITableViewDataSource, UITableViewDelegate {
    
    @IBOutlet var tableView: UITableView?
    @IBOutlet var effectsView: UIVisualEffectView?
    @IBOutlet var backButton: UIButton?
    @IBOutlet var settingsLabel: UILabel?
    
    override var darkMode: Bool {
        didSet {

                        cell.backgroundColor = cellBackgroundColorDark
                        var label = cell.viewWithTag(2) as? UILabel
                        label?.textColor = cellLabelColorDark
                        var longLabel = cell.viewWithTag(3) as? UITextView
                        longLabel?.textColor = cellLongLabelColorDark
                    }
                }
            }
        }
        else {
            let blueColor = UIColor(red: 0/CGFloat(255), green: 122/CGFloat(255), blue: 255/CGFloat(255), alpha: 1)
            self.pixelLine?.backgroundColor = blueColor.colorWithAlphaComponent(CGFloat(0.5))
            self.backButton?.setTitleColor(blueColor, forState: UIControlState.Normal)
            self.settingsLabel?.textColor = UIColor.grayColor()
            
            if let visibleCells = self.tableView?.visibleCells() {
