Files
raspberry/iOS/Wallet/Sources/Account/Controller/AccountControllerConnect.swift
2022-05-27 20:21:01 +03:00

78 lines
2.8 KiB
Swift

//
// AccountControllerConnect.swift
// PayCash
//
// Created by Igor on 15.10.2020.
// Copyright © 2020 List. All rights reserved.
//
import UIKit
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()
title = L10n.Account.Connect.title
navigationItem.leftBarButtonItem = .pop(self)
description1Lbl.text = L10n.Account.Connect.description1(service.model.from, service.model.listAccount)
let string = NSMutableAttributedString()
string.append(NSAttributedString(string: L10n.Account.Connect.Description2.title + " ", attributes: [
.font : FontFamily.GolosUI.medium.font(size: 12)!,
.foregroundColor: Asset.liSTRedEnd.color,
]))
string.append(NSAttributedString(string: L10n.Account.Connect.Description2.text, attributes: [
.font : FontFamily.GolosUI.regular.font(size: 12)!,
.foregroundColor: Asset.dark.color,
]))
description2Lbl.attributedText = string
let lbl = UILabel()
lbl.font = FontFamily.GolosUI.regular.font(size: 14)
lbl.textColor = Asset.dark.color
lbl.text = service.model.symbol
lbl.sizeToFit()
amountTxtFld.rightViewMode = .always
amountTxtFld.rightView = lbl
accountTxtFld.text = service.model.to
memoTxtFld.text = service.model.memo
amountTxtFld.text = service.model.amount
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
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 != nil {
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 ?? ""
))
}
}
}
}
}