passforios/pass/Controllers/SSHKeySettingTableViewController.swift
Danny Moesch 8351c16d75 Compute heights of TableViewCells automatically
This is necessary because different languages need different amounts of space. Especially text fields with some more text need to be variable in their heights.
2019-02-23 14:22:27 -08:00

41 lines
1.3 KiB
Swift

//
// SSHKeySettingTableViewController.swift
// pass
//
// Created by Mingshen Sun on 25/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import SVProgressHUD
import passKit
class SSHKeySettingTableViewController: AutoCellHeightUITableViewController {
@IBOutlet weak var privateKeyURLTextField: UITextField!
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
privateKeyURLTextField.text = SharedDefaults[.gitSSHPrivateKeyURL]?.absoluteString
}
@IBAction func doneButtonTapped(_ sender: UIButton) {
guard let privateKeyURL = URL(string: privateKeyURLTextField.text!.trimmed) else {
Utils.alert(title: "CannotSave".localize(), message: "SetPrivateKeyUrl.".localize(), controller: self, completion: nil)
return
}
SharedDefaults[.gitSSHPrivateKeyURL] = privateKeyURL
do {
try Data(contentsOf: privateKeyURL).write(to: URL(fileURLWithPath: Globals.gitSSHPrivateKeyPath), options: .atomic)
} catch {
Utils.alert(title: "Error".localize(), message: error.localizedDescription, controller: self, completion: nil)
}
SharedDefaults[.gitSSHKeySource] = "url"
self.navigationController!.popViewController(animated: true)
}
}