114 lines
4.4 KiB
Swift
114 lines
4.4 KiB
Swift
//
|
|
// ApartmentsControllerRequest.swift
|
|
// Wallet
|
|
//
|
|
// Created by Igor on 15.10.2020.
|
|
// Copyright © 2020 List. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class ApartmentsControllerRequest: UIViewController {
|
|
|
|
@IBOutlet private weak var titleLabel: UILabel!
|
|
@IBOutlet private var receiverValueLabel: UILabel!
|
|
@IBOutlet private var receiverTitleLabel: UILabel!
|
|
@IBOutlet private var receiverStackView: UIStackView!
|
|
@IBOutlet private var areaStackView: UIStackView!
|
|
@IBOutlet private var areaValueLabel: UILabel!
|
|
@IBOutlet private var areaTitleLabel: UILabel!
|
|
@IBOutlet weak private var warningLbl: UILabel!
|
|
@IBOutlet weak private var regionLbl: UILabel!
|
|
@IBOutlet weak private var addressLbl: UILabel!
|
|
@IBOutlet weak private var submitBtn: CommonButtonAction!
|
|
|
|
var service: Apartments.Service.Request!
|
|
var popupDescription: String = ""
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.setupView()
|
|
}
|
|
|
|
private func setupView() {
|
|
navigationItem.leftBarButtonItem = .pop(self)
|
|
warningLbl.text = service.warning
|
|
regionLbl.text = service.region
|
|
addressLbl.text = service.address
|
|
submitBtn.lzTitle = service.submit
|
|
self.areaTitleLabel.text = service.actionTitle
|
|
self.titleLabel.text = service.title
|
|
self.receiverValueLabel.text = service.receiver
|
|
self.areaValueLabel.text = service.area?.amount.toDecimal().toReadebleString(precisionMax: 8,
|
|
symbol: service.area?.symbol)
|
|
self.areaStackView.isHidden = service.area?.isEmpty ?? true
|
|
self.receiverStackView.isHidden = service.receiver?.isEmpty ?? true
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
Accounts().isLocked = true
|
|
navigationController?.setNavigationBarHidden(false, animated: true)
|
|
}
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
Accounts().isLocked = false
|
|
}
|
|
|
|
@IBAction func onSubmit(_: AnyObject?) {
|
|
AccountViewAuthorize.showGetPrivateKey(in: self) { [weak self]key in
|
|
Loader.show()
|
|
self?.service.submit(privateKey: key) { [weak self] txt, error in
|
|
Loader.hide()
|
|
if let error = error {
|
|
Alert.error(text: error)
|
|
} else {
|
|
self?.submitPopup(id: txt ?? "")
|
|
self?.navigationController?.popViewController(animated: true)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func submitPopup(id: String) {
|
|
|
|
var views: [UIView] = [
|
|
.label(
|
|
text: popupDescription
|
|
.attributed(style: .regular, size: 14, color: Asset.textCoal.color),
|
|
numberOfLines: 0
|
|
)
|
|
]
|
|
let areaString = service.area?.amount.toDecimal().toReadebleString(precisionMax: 8,
|
|
symbol: service.area?.symbol)
|
|
views.append(contentsOf:
|
|
[.field(title: L10n.Apartments.Request.region, text: service.region),
|
|
.field(title: L10n.Apartments.Request.address, text: service.address),
|
|
.field(title: service.actionTitle ?? L10n.Apartments.Tokenization.Emission.title, text: areaString)]
|
|
)
|
|
|
|
if !(service.receiver?.isEmpty ?? true) {
|
|
views.append(.field(title: L10n.Apartments.Tokenization.Recipient.title, text: service.receiver))
|
|
}
|
|
|
|
Popup.show(title: L10n.Apartments.Tokenization.transactionDetails,
|
|
text: nil,
|
|
image: nil,
|
|
description: nil,
|
|
views: views,
|
|
submit: L10n.Common.Button.checkOnBloksIO,
|
|
submitStyle: .outline,
|
|
cancel: L10n.Common.Button.done, { _ in
|
|
guard let checkTransactionUrl = URL(transactionId: id) else { return }
|
|
UIApplication.shared.open(checkTransactionUrl, options: [:], completionHandler: nil)
|
|
}, { [weak self] in
|
|
self?.navigationController?.popViewController(animated: true)
|
|
self?.dismiss(animated: true)
|
|
})
|
|
|
|
|
|
}
|
|
|
|
}
|