Files
raspberry/iOS/Wallet/Sources/Account/Controller/AccountControllerConnect.swift
2022-12-13 22:30:08 +03:00

86 lines
3.0 KiB
Swift

//
// AccountControllerConnect.swift
// Wallet
//
// Created by Igor on 15.10.2020.
// Copyright © 2020 List. All rights reserved.
//
import UIKit
import WalletFoundation
final class AccountControllerConnect: UIViewController {
@IBOutlet private weak var description1Lbl: UILabel!
@IBOutlet private weak var description2Lbl: UILabel!
@IBOutlet private weak var accountTxtFld: UITextField!
@IBOutlet private weak var memoTxtFld: UITextField!
@IBOutlet private weak var amountTxtFld: UITextField!
let service = Account.Service.Connect()
override func viewDidLoad() {
super.viewDidLoad()
self.title = L10n.Account.Connect.title
self.navigationItem.leftBarButtonItem = .pop(self)
self.description1Lbl.text = L10n.Account.Connect.description1(service.model.from, service.model.listAccount)
let string = NSMutableAttributedString()
FontFamily.GolosUI.medium.font(size: 12) >>- {
string.append(NSAttributedString(string: L10n.Account.Connect.Description2.title + " ", attributes: [
.font: $0,
.foregroundColor: Asset.liSTRedEnd.color
]))
}
FontFamily.GolosUI.regular.font(size: 12) >>- {
string.append(NSAttributedString(string: L10n.Account.Connect.Description2.text, attributes: [
.font: $0,
.foregroundColor: Asset.dark.color
]))
}
self.description2Lbl.attributedText = string
let lbl = UILabel()
lbl.font = FontFamily.GolosUI.regular.font(size: 14)
lbl.textColor = Asset.dark.color
lbl.text = self.service.model.symbol
lbl.sizeToFit()
self.amountTxtFld.rightViewMode = .always
self.amountTxtFld.rightView = lbl
self.accountTxtFld.text = self.service.model.to
self.memoTxtFld.text = self.service.model.memo
self.amountTxtFld.text = self.service.model.amount
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
@IBAction func onSubmit(_: AnyObject?) {
AccountViewAuthorize.showGetPrivateKey(in: self) { [weak self] key in
Loader.show()
self?.service.submit(privateKey: key) { error in
Loader.hide()
if error.isExist {
Alert.error(text: L10n.Account.Connect.Error.text(
self?.service.model.from ?? "",
self?.service.model.listAccount ?? ""
))
} else {
self?.navigationController?.popViewController(animated: true)
Alert.success(text: L10n.Account.Connect.Success.text(
self?.service.model.from ?? "",
self?.service.model.listAccount ?? ""
))
}
}
}
}
}