CreateRingAccountViewController.swift: change superclass

Change superclass from UIViewController to UITableViewController
Add username and password fields

UITableViewController allows to automatically scroll to cells while
editing UITextField

Also added new cells :
- TextCell
- SwitchCell
- TextFieldCell

Using a simple UIViewController with a UITableView as subview does
not automatically scroll to the cells

Tuleap: #1400
Change-Id: I0837e30f006fdfd03aaa5e4914a15aa4f417b7f1
Reviewed-by: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
diff --git a/Ring/Ring.xcodeproj/project.pbxproj b/Ring/Ring.xcodeproj/project.pbxproj
index 958db50..b2b3211 100644
--- a/Ring/Ring.xcodeproj/project.pbxproj
+++ b/Ring/Ring.xcodeproj/project.pbxproj
@@ -111,6 +111,10 @@
 		5557FD4F1E81B2990043E394 /* AccountCredentialsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DD80C91E1EAF1A009A3510 /* AccountCredentialsModel.swift */; };
 		557086521E8ADB9D001A7CE4 /* SystemAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 557086511E8ADB9D001A7CE4 /* SystemAdapter.mm */; };
 		56AC64D91E8012CA00EA1AA9 /* Walkthrough.strings in Resources */ = {isa = PBXBuildFile; fileRef = 56AC64DB1E8012CA00EA1AA9 /* Walkthrough.strings */; };
+		56AC64DF1E804ECC00EA1AA9 /* SwitchCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC64DE1E804ECC00EA1AA9 /* SwitchCell.swift */; };
+		56AC64E11E80542300EA1AA9 /* TextFieldCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC64E01E80542300EA1AA9 /* TextFieldCell.swift */; };
+		56AC64E31E805F0200EA1AA9 /* TextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC64E21E805F0200EA1AA9 /* TextCell.swift */; };
+		56AC650E1E85694D00EA1AA9 /* RoundedTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC650D1E85694D00EA1AA9 /* RoundedTextField.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -245,6 +249,10 @@
 		557086501E8ADB9D001A7CE4 /* SystemAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SystemAdapter.h; path = Bridging/SystemAdapter.h; sourceTree = "<group>"; };
 		557086511E8ADB9D001A7CE4 /* SystemAdapter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SystemAdapter.mm; path = Bridging/SystemAdapter.mm; sourceTree = "<group>"; };
 		56AC64DA1E8012CA00EA1AA9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Walkthrough.strings; sourceTree = "<group>"; };
+		56AC64DE1E804ECC00EA1AA9 /* SwitchCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitchCell.swift; sourceTree = "<group>"; };
+		56AC64E01E80542300EA1AA9 /* TextFieldCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldCell.swift; sourceTree = "<group>"; };
+		56AC64E21E805F0200EA1AA9 /* TextCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextCell.swift; sourceTree = "<group>"; };
+		56AC650D1E85694D00EA1AA9 /* RoundedTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoundedTextField.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -334,6 +342,7 @@
 		0273C3021E0C689600CF00BA /* Walkthrough */ = {
 			isa = PBXGroup;
 			children = (
+				56AC64DD1E804EB500EA1AA9 /* Cells */,
 				0273C3031E0C68B100CF00BA /* CreateProfileViewController.swift */,
 				0273C3041E0C68B100CF00BA /* CreateRingAccountViewController.swift */,
 			);
@@ -443,6 +452,7 @@
 			children = (
 				0273C3071E0C68BF00CF00BA /* RoundedButton.swift */,
 				043866351D22D06500E06CE2 /* AccountTableViewCell.swift */,
+				56AC650D1E85694D00EA1AA9 /* RoundedTextField.swift */,
 			);
 			name = UI;
 			sourceTree = "<group>";
@@ -611,6 +621,16 @@
 			name = Internationalization;
 			sourceTree = "<group>";
 		};
+		56AC64DD1E804EB500EA1AA9 /* Cells */ = {
+			isa = PBXGroup;
+			children = (
+				56AC64DE1E804ECC00EA1AA9 /* SwitchCell.swift */,
+				56AC64E01E80542300EA1AA9 /* TextFieldCell.swift */,
+				56AC64E21E805F0200EA1AA9 /* TextCell.swift */,
+			);
+			name = Cells;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -777,10 +797,14 @@
 				02C9B63F1E1D4E8C00F82F0C /* ServiceEvent.swift in Sources */,
 				02DD80CD1E1EB2E4009A3510 /* ConfigKeyModel.swift in Sources */,
 				5516C29F1E71CEFF009D3D2D /* AccountModelHelper.swift in Sources */,
+				56AC64E11E80542300EA1AA9 /* TextFieldCell.swift in Sources */,
+				56AC64E31E805F0200EA1AA9 /* TextCell.swift in Sources */,
+				56AC650E1E85694D00EA1AA9 /* RoundedTextField.swift in Sources */,
 				02B22E011DF755E5000358C9 /* MainTabBarViewController.swift in Sources */,
 				043999F71D1C2D9D00E99CD9 /* AppDelegate.swift in Sources */,
 				02B22DFC1DF755BB000358C9 /* AccountModel.swift in Sources */,
 				043866331D22CE8C00E06CE2 /* MeViewController.swift in Sources */,
+				56AC64DF1E804ECC00EA1AA9 /* SwitchCell.swift in Sources */,
 				04399AAE1D1C304300E99CD9 /* Utils.mm in Sources */,
 				02B22DFD1DF755BB000358C9 /* CreateRingAccountViewModel.swift in Sources */,
 				043999FA1D1C2D9D00E99CD9 /* Ring.xcdatamodeld in Sources */,
diff --git a/Ring/Ring/Account/CreateRingAccountViewModel.swift b/Ring/Ring/Account/CreateRingAccountViewModel.swift
index 6ed3259..45e2fb3 100644
--- a/Ring/Ring/Account/CreateRingAccountViewModel.swift
+++ b/Ring/Ring/Account/CreateRingAccountViewModel.swift
@@ -43,6 +43,8 @@
      */
     fileprivate var account: AccountModel?
 
+    var registerUsername = Variable<Bool>(true)
+
     /**
      The accountService instance injected in initializer.
      */
diff --git a/Ring/Ring/Base.lproj/Walkthrough.strings b/Ring/Ring/Base.lproj/Walkthrough.strings
index a1bb359..69ac874 100644
--- a/Ring/Ring/Base.lproj/Walkthrough.strings
+++ b/Ring/Ring/Base.lproj/Walkthrough.strings
@@ -24,3 +24,12 @@
 "WelcomeText" = "A Ring account allows you to reach people securely in peer to peer through fully distributed network";
 "LinkDeviceButton" = "Link this device to an account";
 "CreateAccount" = "Create a Ring account";
+
+//Create Account form
+
+"CreateAccountFormTitle" = "Create your Ring account";
+"RegisterPublicUsername" = "Register public username (experimental)";
+"ChooseStrongPassword" = "Choose strong password you will remember to protect your Ring account.";
+"EnterNewUsernamePlaceholder" = "Enter new username";
+"NewPasswordPlaceholder" = "New Password";
+"RepeatPasswordPlaceholder" = "Repeat new password";
diff --git a/Ring/Ring/RoundedTextField.swift b/Ring/Ring/RoundedTextField.swift
new file mode 100644
index 0000000..5478afd
--- /dev/null
+++ b/Ring/Ring/RoundedTextField.swift
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2017 Savoir-faire Linux Inc.
+ *
+ *  Author: Silbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+import UIKit
+
+class RoundedTextField: UITextField {
+
+    required init?(coder aDecoder: NSCoder) {
+        super.init(coder: aDecoder)
+        self.layer.borderColor = UIColor.white.cgColor
+        self.layer.borderWidth = 1.0
+        self.clipsToBounds = true
+    }
+
+    override func layoutSubviews() {
+        super.layoutSubviews()
+        self.layer.cornerRadius = self.frame.size.height / 2.0
+    }
+
+}
diff --git a/Ring/Ring/SwitchCell.swift b/Ring/Ring/SwitchCell.swift
new file mode 100644
index 0000000..2c5214b
--- /dev/null
+++ b/Ring/Ring/SwitchCell.swift
@@ -0,0 +1,39 @@
+/*
+ *  Copyright (C) 2017 Savoir-faire Linux Inc.
+ *
+ *  Author: Silbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+import UIKit
+
+class SwitchCell: UITableViewCell {
+
+    @IBOutlet weak var titleLabel: UILabel!
+    @IBOutlet weak var registerSwitch: UISwitch!
+
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        // Initialization code
+    }
+
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+
+        // Configure the view for the selected state
+    }
+
+}
diff --git a/Ring/Ring/TextCell.swift b/Ring/Ring/TextCell.swift
new file mode 100644
index 0000000..8e4f42f
--- /dev/null
+++ b/Ring/Ring/TextCell.swift
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (C) 2017 Savoir-faire Linux Inc.
+ *
+ *  Author: Silbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+import UIKit
+
+class TextCell: UITableViewCell {
+
+    @IBOutlet weak var label: UILabel!
+
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        // Initialization code
+    }
+
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+
+        // Configure the view for the selected state
+    }
+
+}
diff --git a/Ring/Ring/TextFieldCell.swift b/Ring/Ring/TextFieldCell.swift
new file mode 100644
index 0000000..1c7b458
--- /dev/null
+++ b/Ring/Ring/TextFieldCell.swift
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (C) 2017 Savoir-faire Linux Inc.
+ *
+ *  Author: Silbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+import UIKit
+
+class TextFieldCell: UITableViewCell {
+
+    @IBOutlet weak var textField: UITextField!
+
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        // Initialization code
+    }
+
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+
+        // Configure the view for the selected state
+    }
+
+}
diff --git a/Ring/Ring/Walkthrough/CreateRingAccountViewController.swift b/Ring/Ring/Walkthrough/CreateRingAccountViewController.swift
index 8f922b3..f43d503 100644
--- a/Ring/Ring/Walkthrough/CreateRingAccountViewController.swift
+++ b/Ring/Ring/Walkthrough/CreateRingAccountViewController.swift
@@ -23,16 +23,37 @@
 import RxCocoa
 import RxSwift
 
-class CreateRingAccountViewController: UIViewController {
+fileprivate enum CreateRingAccountCellType {
+    case registerPublicUsername
+    case usernameField
+    case passwordNotice
+    case newPasswordField
+    case repeatPasswordField
+}
+
+class CreateRingAccountViewController: UITableViewController {
 
     var mAccountViewModel = CreateRingAccountViewModel(withAccountService: AppDelegate.accountService)
 
     @IBOutlet weak var mCreateAccountButton: RoundedButton!
+    @IBOutlet weak var mCreateAccountTitleLabel: UILabel!
+
+    /**
+     Cell identifiers
+     */
+
+    let mSwitchCellId = "SwitchCellId"
+    let mTextFieldCellId = "TextFieldCellId"
+    let mTableViewCellId = "TableViewCellId"
+
+    var mDisposeBag = DisposeBag()
 
     override func viewDidLoad() {
         super.viewDidLoad()
 
         self.bindViews()
+
+        self.setupUI()
     }
 
     /**
@@ -62,6 +83,24 @@
                 }
                 self?.setCreateAccountAsIdle()
         })
+
+        _ = self.mAccountViewModel.registerUsername.asObservable()
+            .subscribe(onNext: { [weak self] showUsernameField in
+                self?.toggleRegisterSwitch(showUsernameField)
+        }).addDisposableTo(mDisposeBag)
+    }
+
+    /**
+     Customize the views
+     */
+
+    fileprivate func setupUI() {
+        self.tableView.estimatedRowHeight = 44.0
+        self.tableView.rowHeight = UITableViewAutomaticDimension
+
+        self.mCreateAccountTitleLabel.text = NSLocalizedString("CreateAccountFormTitle",
+                                                              tableName: LocalizedStringTableNames.walkthrough,
+                                                              comment: "")
     }
 
     fileprivate func setCreateAccountAsLoading() {
@@ -74,4 +113,89 @@
         self.mCreateAccountButton.setTitle("Create a Ring account", for: .normal)
         self.mCreateAccountButton.isUserInteractionEnabled = true
     }
+
+    /**
+     Show or hide the username field cell in function of the switch state
+     */
+
+    func toggleRegisterSwitch(_ show: Bool) {
+
+        let usernameFieldCellIndex = 1
+
+        if show && !mCells.contains(.usernameField) {
+            self.mCells.insert(.usernameField, at: usernameFieldCellIndex)
+            self.tableView.insertRows(at: [IndexPath(row: usernameFieldCellIndex, section: 0)],
+                                      with: .automatic)
+        } else if !show && mCells.contains(.usernameField) {
+            self.mCells.remove(at: usernameFieldCellIndex)
+            self.tableView.deleteRows(at: [IndexPath(row: usernameFieldCellIndex, section: 0)],
+                                      with: .automatic)
+        }
+
+    }
+
+    //MARK: TableView datasource
+    fileprivate var mCells :[CreateRingAccountCellType] = [.registerPublicUsername,
+                                                          .passwordNotice,
+                                                          .newPasswordField,
+                                                          .repeatPasswordField]
+
+    override func numberOfSections(in tableView: UITableView) -> Int {
+        return 1
+    }
+
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return mCells.count
+    }
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+
+        let currentCellType = mCells[indexPath.row]
+
+        if currentCellType == .registerPublicUsername {
+            let cell = tableView.dequeueReusableCell(withIdentifier: mSwitchCellId,
+                                                     for: indexPath) as! SwitchCell
+            cell.titleLabel.text = NSLocalizedString("RegisterPublicUsername",
+                                                     tableName: LocalizedStringTableNames.walkthrough,
+                                                     comment: "")
+            cell.titleLabel.textColor = .white
+
+            _ = cell.registerSwitch.rx.value.bindTo(self.mAccountViewModel.registerUsername)
+                .addDisposableTo(mDisposeBag)
+
+            return cell
+        } else if currentCellType == .usernameField {
+            let cell = tableView.dequeueReusableCell(withIdentifier: mTextFieldCellId,
+                                                     for: indexPath) as! TextFieldCell
+            cell.textField.isSecureTextEntry = false
+            cell.textField.placeholder = NSLocalizedString("EnterNewUsernamePlaceholder",
+                                                           tableName: LocalizedStringTableNames.walkthrough,
+                                                           comment: "")
+            return cell
+        } else if currentCellType == .passwordNotice {
+            let cell = tableView.dequeueReusableCell(withIdentifier: mTableViewCellId,
+                                                     for: indexPath) as! TextCell
+            cell.label.text = NSLocalizedString("ChooseStrongPassword",
+                                                tableName: LocalizedStringTableNames.walkthrough,
+                                                comment: "")
+            return cell
+        } else if currentCellType == .newPasswordField {
+            let cell = tableView.dequeueReusableCell(withIdentifier: mTextFieldCellId,
+                                                     for: indexPath) as! TextFieldCell
+            cell.textField.isSecureTextEntry = true
+            cell.textField.placeholder = NSLocalizedString("NewPasswordPlaceholder",
+                                                           tableName: LocalizedStringTableNames.walkthrough,
+                                                           comment: "")
+            return cell
+        } else {
+            let cell = tableView.dequeueReusableCell(withIdentifier: mTextFieldCellId,
+                                                     for: indexPath) as! TextFieldCell
+            cell.textField.isSecureTextEntry = true
+            cell.textField.placeholder = NSLocalizedString("RepeatPasswordPlaceholder",
+                                                           tableName: LocalizedStringTableNames.walkthrough,
+                                                           comment: "")
+            return cell
+        }
+    }
+
 }
diff --git a/Ring/Ring/Walkthrough/WalkthroughStoryboard.storyboard b/Ring/Ring/Walkthrough/WalkthroughStoryboard.storyboard
index 45da4d1..6db76a2 100644
--- a/Ring/Ring/Walkthrough/WalkthroughStoryboard.storyboard
+++ b/Ring/Ring/Walkthrough/WalkthroughStoryboard.storyboard
@@ -153,7 +153,7 @@
                         </constraints>
                     </view>
                     <connections>
-                        <segue destination="ja8-pO-qtF" kind="show" identifier="ProfileToAccountSegue" id="3D3-9L-iuy"/>
+                        <segue destination="kzh-87-Ao9" kind="show" identifier="ProfileToAccountSegue" id="CDO-bH-qiw"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="YDh-Qj-wfv" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -161,39 +161,154 @@
             <point key="canvasLocation" x="1105" y="367"/>
         </scene>
         <!--Create Ring Account View Controller-->
-        <scene sceneID="hlW-WP-KN4">
+        <scene sceneID="XTt-go-ZNJ">
             <objects>
-                <viewController id="ja8-pO-qtF" customClass="CreateRingAccountViewController" customModule="Ring" customModuleProvider="target" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="lys-bB-GcZ"/>
-                        <viewControllerLayoutGuide type="bottom" id="5jn-tZ-fJ1"/>
-                    </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="iHs-VJ-9vN">
+                <tableViewController id="kzh-87-Ao9" customClass="CreateRingAccountViewController" customModule="Ring" customModuleProvider="target" sceneMemberID="viewController">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="69" sectionHeaderHeight="28" sectionFooterHeight="28" id="e9y-lu-Idq">
                         <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <subviews>
-                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="exC-LF-5rp" customClass="RoundedButton" customModule="Ring" customModuleProvider="target">
-                                <rect key="frame" x="84" y="225" width="152" height="30"/>
-                                <color key="backgroundColor" red="0.0" green="0.29803921570000003" blue="0.37647058820000001" alpha="1" colorSpace="calibratedRGB"/>
-                                <state key="normal" title="Create a Ring account">
-                                    <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                                </state>
-                            </button>
-                        </subviews>
                         <color key="backgroundColor" red="0.039215686270000001" green="0.4549019608" blue="0.53725490200000003" alpha="1" colorSpace="calibratedRGB"/>
-                        <constraints>
-                            <constraint firstItem="exC-LF-5rp" firstAttribute="centerY" secondItem="iHs-VJ-9vN" secondAttribute="centerY" id="3gQ-AK-GLL"/>
-                            <constraint firstItem="exC-LF-5rp" firstAttribute="centerX" secondItem="iHs-VJ-9vN" secondAttribute="centerX" id="eBl-JO-6ae"/>
-                        </constraints>
-                    </view>
+                        <view key="tableHeaderView" contentMode="scaleToFill" id="gnd-b0-Ncm">
+                            <rect key="frame" x="0.0" y="0.0" width="320" height="130"/>
+                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Create your Ring account" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AIX-eC-baN">
+                                    <rect key="frame" x="8" y="8" width="304" height="114"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="24"/>
+                                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                            <constraints>
+                                <constraint firstItem="AIX-eC-baN" firstAttribute="leading" secondItem="gnd-b0-Ncm" secondAttribute="leading" constant="8" id="D6R-DY-N4I"/>
+                                <constraint firstAttribute="trailing" secondItem="AIX-eC-baN" secondAttribute="trailing" constant="8" id="c58-zW-D8i"/>
+                                <constraint firstAttribute="bottom" secondItem="AIX-eC-baN" secondAttribute="bottom" constant="8" id="k5Z-6d-hx8"/>
+                                <constraint firstItem="AIX-eC-baN" firstAttribute="top" secondItem="gnd-b0-Ncm" secondAttribute="top" constant="8" id="peB-GQ-GOz"/>
+                            </constraints>
+                        </view>
+                        <view key="tableFooterView" contentMode="scaleToFill" id="MnN-De-arJ">
+                            <rect key="frame" x="0.0" y="365" width="320" height="54"/>
+                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                            <subviews>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gsT-SB-0AP" customClass="RoundedButton" customModule="Ring" customModuleProvider="target">
+                                    <rect key="frame" x="84" y="8" width="152" height="30"/>
+                                    <color key="backgroundColor" red="0.0" green="0.29803921570000003" blue="0.37647058820000001" alpha="1" colorSpace="calibratedRGB"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="30" id="KVf-AW-ms7"/>
+                                    </constraints>
+                                    <state key="normal" title="Create a Ring account">
+                                        <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                    </state>
+                                </button>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                            <constraints>
+                                <constraint firstItem="gsT-SB-0AP" firstAttribute="top" secondItem="MnN-De-arJ" secondAttribute="top" constant="8" id="pqs-B0-TWU"/>
+                                <constraint firstAttribute="bottom" secondItem="gsT-SB-0AP" secondAttribute="bottom" constant="16" id="qOI-R4-9EJ"/>
+                                <constraint firstItem="gsT-SB-0AP" firstAttribute="centerX" secondItem="MnN-De-arJ" secondAttribute="centerX" id="tMA-Qg-oxa"/>
+                            </constraints>
+                        </view>
+                        <prototypes>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SwitchCellId" rowHeight="69" id="xv3-kL-wNV" customClass="SwitchCell" customModule="Ring" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="158" width="320" height="69"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="xv3-kL-wNV" id="u8d-10-5fQ">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="69"/>
+                                    <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Register public username (experimental)" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l6E-2a-51c">
+                                            <rect key="frame" x="16" y="8" width="231" height="52.5"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                        <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eXQ-lo-PPY">
+                                            <rect key="frame" x="255" y="19" width="51" height="31"/>
+                                        </switch>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstAttribute="bottom" secondItem="l6E-2a-51c" secondAttribute="bottom" constant="8" id="3mf-5d-kOd"/>
+                                        <constraint firstItem="eXQ-lo-PPY" firstAttribute="centerY" secondItem="u8d-10-5fQ" secondAttribute="centerY" id="UJ8-RD-ddQ"/>
+                                        <constraint firstItem="l6E-2a-51c" firstAttribute="leading" secondItem="u8d-10-5fQ" secondAttribute="leading" constant="16" id="UsX-gS-0TN"/>
+                                        <constraint firstAttribute="trailing" secondItem="eXQ-lo-PPY" secondAttribute="trailing" constant="16" id="cE9-Xf-bT3"/>
+                                        <constraint firstItem="eXQ-lo-PPY" firstAttribute="leading" secondItem="l6E-2a-51c" secondAttribute="trailing" constant="8" id="cyW-Kw-ea3"/>
+                                        <constraint firstItem="l6E-2a-51c" firstAttribute="top" secondItem="u8d-10-5fQ" secondAttribute="top" constant="8" id="oun-Kt-auw"/>
+                                    </constraints>
+                                </tableViewCellContentView>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                                <connections>
+                                    <outlet property="registerSwitch" destination="eXQ-lo-PPY" id="SlD-P6-SiF"/>
+                                    <outlet property="titleLabel" destination="l6E-2a-51c" id="28k-pL-Ri6"/>
+                                </connections>
+                            </tableViewCell>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TextFieldCellId" rowHeight="69" id="hll-q9-QzR" customClass="TextFieldCell" customModule="Ring" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="227" width="320" height="69"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hll-q9-QzR" id="b0d-cJ-IJT">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="69"/>
+                                    <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dWn-2T-XDN" customClass="RoundedTextField" customModule="Ring" customModuleProvider="target">
+                                            <rect key="frame" x="16" y="8" width="288" height="52.5"/>
+                                            <nil key="textColor"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                            <textInputTraits key="textInputTraits" secureTextEntry="YES"/>
+                                        </textField>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstAttribute="bottom" secondItem="dWn-2T-XDN" secondAttribute="bottom" constant="8" id="ExW-Ye-ifb"/>
+                                        <constraint firstAttribute="trailing" secondItem="dWn-2T-XDN" secondAttribute="trailing" constant="16" id="TZI-tk-XCc"/>
+                                        <constraint firstItem="dWn-2T-XDN" firstAttribute="top" secondItem="b0d-cJ-IJT" secondAttribute="top" constant="8" id="gXN-EW-HYY"/>
+                                        <constraint firstItem="dWn-2T-XDN" firstAttribute="leading" secondItem="b0d-cJ-IJT" secondAttribute="leading" constant="16" id="zAm-rb-vhR"/>
+                                    </constraints>
+                                </tableViewCellContentView>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                                <connections>
+                                    <outlet property="textField" destination="dWn-2T-XDN" id="xz6-aa-Izw"/>
+                                </connections>
+                            </tableViewCell>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TableViewCellId" rowHeight="69" id="ExW-Pf-YtL" customClass="TextCell" customModule="Ring" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="296" width="320" height="69"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ExW-Pf-YtL" id="D4j-0H-Fhi">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="69"/>
+                                    <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tqa-H7-iG3">
+                                            <rect key="frame" x="16" y="8" width="288" height="52.5"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstAttribute="trailing" secondItem="tqa-H7-iG3" secondAttribute="trailing" constant="16" id="VN7-fC-5Av"/>
+                                        <constraint firstItem="tqa-H7-iG3" firstAttribute="leading" secondItem="D4j-0H-Fhi" secondAttribute="leading" constant="16" id="ghI-k7-j7e"/>
+                                        <constraint firstAttribute="bottom" secondItem="tqa-H7-iG3" secondAttribute="bottom" constant="8" id="r6B-sj-b0Z"/>
+                                        <constraint firstItem="tqa-H7-iG3" firstAttribute="top" secondItem="D4j-0H-Fhi" secondAttribute="top" constant="8" id="vYA-FB-IGa"/>
+                                    </constraints>
+                                </tableViewCellContentView>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                                <connections>
+                                    <outlet property="label" destination="tqa-H7-iG3" id="LDf-uD-qqo"/>
+                                </connections>
+                            </tableViewCell>
+                        </prototypes>
+                        <connections>
+                            <outlet property="dataSource" destination="kzh-87-Ao9" id="fWb-k5-HBL"/>
+                            <outlet property="delegate" destination="kzh-87-Ao9" id="DE2-dv-wl2"/>
+                        </connections>
+                    </tableView>
                     <connections>
-                        <outlet property="mCreateAccountButton" destination="exC-LF-5rp" id="z71-gN-58V"/>
-                        <segue destination="E3W-r7-J4y" kind="show" identifier="AccountToPermissionsSegue" id="KYM-Jg-1oB"/>
+                        <outlet property="mCreateAccountButton" destination="gsT-SB-0AP" id="9Fj-aJ-0Ik"/>
+                        <outlet property="mCreateAccountTitleLabel" destination="AIX-eC-baN" id="YUL-yb-Ecy"/>
+                        <segue destination="E3W-r7-J4y" kind="show" identifier="AccountToPermissionsSegue" id="Zig-iC-h9U"/>
                     </connections>
-                </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="fjG-WS-Fbj" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                </tableViewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="W0G-TV-Z9c" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="1868" y="367"/>
+            <point key="canvasLocation" x="1965.5999999999999" y="366.56671664167919"/>
         </scene>
         <!--View Controller-->
         <scene sceneID="c8H-6M-3dO">
@@ -211,7 +326,7 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="bS8-E0-lOu" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="2646" y="367"/>
+            <point key="canvasLocation" x="2852" y="367"/>
         </scene>
         <!--View Controller-->
         <scene sceneID="JGg-HD-FXJ">