2021-06-12 13:48:29 +03:00
|
|
|
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
2021-06-12 13:32:27 +03:00
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
2021-06-13 02:12:03 +03:00
|
|
|
class ImportViewController: NSViewController {
|
2021-06-12 17:39:42 +03:00
|
|
|
|
2021-06-13 02:24:02 +03:00
|
|
|
@IBOutlet weak var textField: NSTextField! {
|
|
|
|
didSet {
|
|
|
|
textField.delegate = self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@IBOutlet weak var okButton: NSButton!
|
2021-06-12 17:39:42 +03:00
|
|
|
|
2021-06-12 13:32:27 +03:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
}
|
|
|
|
|
2021-06-12 19:33:24 +03:00
|
|
|
@IBAction func actionButtonTapped(_ sender: Any) {
|
2021-06-13 03:45:24 +03:00
|
|
|
AccountsService.addAccount(privateKey: textField.stringValue)
|
|
|
|
|
2021-06-13 02:24:02 +03:00
|
|
|
// TODO: open accounts list
|
|
|
|
|
2021-06-12 20:37:56 +03:00
|
|
|
WalletConnect.shared.connect(link: globalLink, address: "0xCf60CC6E4AD79187E7eBF62e0c21ae3a343180B2") { connected in
|
|
|
|
// TODO: close here
|
|
|
|
// use connected value
|
|
|
|
}
|
|
|
|
|
2021-06-13 04:05:42 +03:00
|
|
|
showAccountsList()
|
2021-06-13 03:45:24 +03:00
|
|
|
|
2021-06-12 20:37:56 +03:00
|
|
|
// TODO: show spinner
|
2021-06-13 03:45:24 +03:00
|
|
|
// Window.closeAll()
|
|
|
|
// Window.activateSafari()
|
2021-06-12 19:33:24 +03:00
|
|
|
}
|
2021-06-13 04:05:42 +03:00
|
|
|
|
|
|
|
private func showAccountsList() {
|
|
|
|
if let accounts = storyboard?.instantiateController(withIdentifier: "AccountsListViewController") as? AccountsListViewController {
|
|
|
|
view.window?.contentViewController = accounts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func cancelButtonTapped(_ sender: NSButton) {
|
|
|
|
showAccountsList()
|
|
|
|
// TODO: in some cases should close the window
|
|
|
|
}
|
2021-06-12 19:33:24 +03:00
|
|
|
|
2021-06-12 13:32:27 +03:00
|
|
|
}
|
2021-06-13 02:24:02 +03:00
|
|
|
|
|
|
|
extension ImportViewController: NSTextFieldDelegate {
|
|
|
|
|
|
|
|
func controlTextDidChange(_ obj: Notification) {
|
|
|
|
okButton.isEnabled = AccountsService.validateAccountKey(textField.stringValue)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|