 /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 import UIKit
 import Storage

    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("ClientCell", forIndexPath: indexPath)

        if clients.count > 0 {
            if indexPath.section == 0 {
                let textLabel = UILabel()
                cell.contentView.addSubview(textLabel)
                textLabel.font = ClientPickerViewControllerUX.TableHeaderTextFont
                textLabel.text = NSLocalizedString("Available devices:", tableName: "SendTo", comment: "Header for the list of devices table")
                textLabel.textColor = ClientPickerViewControllerUX.TableHeaderTextColor
                textLabel.snp_makeConstraints { make in
                    make.left.equalTo(ClientPickerViewControllerUX.TableHeaderTextPaddingLeft)
                    make.centerY.equalTo(cell.snp_centerY)
                    make.right.equalTo(cell.snp_right)
                }

                cell.accessoryType = UITableViewCellAccessoryType.None
                cell.preservesSuperviewLayoutMargins = false
                cell.layoutMargins = UIEdgeInsetsZero
                cell.separatorInset = UIEdgeInsetsZero
            } else {
                let textLabel = UILabel()
                cell.contentView.addSubview(textLabel)
                textLabel.font = ClientPickerViewControllerUX.DeviceRowTextFont
                textLabel.text = clients[indexPath.row].name
                textLabel.numberOfLines = 2
                textLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
                textLabel.snp_makeConstraints { make in
                    make.left.equalTo(ClientPickerViewControllerUX.DeviceRowTextPaddingLeft)
                    make.centerY.equalTo(cell.snp_centerY)
                    make.right.equalTo(cell.snp_right).offset(-ClientPickerViewControllerUX.DeviceRowTextPaddingRight)
                }

                cell.imageView?.image = UIImage(named: clients[indexPath.row].type == "mobile" ? "deviceTypeMobile" : "deviceTypeDesktop")

                cell.accessoryType = selectedClients.containsObject(indexPath) ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None
                cell.tintColor = ClientPickerViewControllerUX.DeviceRowTintColor
                cell.preservesSuperviewLayoutMargins = false
            }
        } else {
            if reloading == false {
                setupHelpView(cell.contentView,
                    introText: NSLocalizedString("You don't have any other devices connected to this Firefox Account available to sync.", tableName: "SendTo", comment: "Error message shown in the remote tabs panel"),
                    showMeText: "") // TODO We used to have a 'show me how to ...' text here. But, we cannot open web pages from the extension. So this is clear for now until we decide otherwise.
                // Move the separator off screen
                cell.separatorInset = UIEdgeInsetsMake(0, 1000, 0, 0)
            }
        }


        refreshControl = UIRefreshControl()
        refreshControl?.addTarget(self, action: "refresh", forControlEvents: UIControlEvents.ValueChanged)
        navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: "cancel")
        tableView.registerClass(ClientPickerTableViewHeaderCell.self, forCellReuseIdentifier: ClientPickerTableViewHeaderCell.CellIdentifier)
        tableView.registerClass(ClientPickerTableViewCell.self, forCellReuseIdentifier: ClientPickerTableViewCell.CellIdentifier)
        tableView.registerClass(ClientPickerNoClientsTableViewCell.self, forCellReuseIdentifier: ClientPickerNoClientsTableViewCell.CellIdentifier)
        tableView.tableFooterView = UIView(frame: CGRectZero)
    }

