77 lines
3.0 KiB
Swift
77 lines
3.0 KiB
Swift
//
|
|
// CashBillDetailsViewController.swift
|
|
// Wallet
|
|
//
|
|
// Created by Saveliy Stavitsky on 7/23/21.
|
|
// Copyright © 2021 AM. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class CashBillDetailsViewController: UIViewController {
|
|
|
|
var bill: CashBillsService.Bill?
|
|
var cashBillsService: CashBillsService?
|
|
|
|
@IBOutlet var dashedLine: UIView!
|
|
|
|
func drawDottedLine(start p0: CGPoint, end p1: CGPoint, view: UIView) {
|
|
let shapeLayer = CAShapeLayer()
|
|
shapeLayer.strokeColor = Asset.marble.color.cgColor
|
|
shapeLayer.lineWidth = 1
|
|
shapeLayer.lineDashPattern = [2, 2] // 7 is the length of dash, 3 is length of the gap.
|
|
|
|
let path = CGMutablePath()
|
|
path.addLines(between: [p0, p1])
|
|
shapeLayer.path = path
|
|
view.layer.addSublayer(shapeLayer)
|
|
}
|
|
|
|
@IBOutlet var date: UILabel!
|
|
@IBOutlet var token1: UILabel!
|
|
@IBOutlet var amount1: UILabel!
|
|
|
|
@IBOutlet var token2: UILabel!
|
|
@IBOutlet var amount2: UILabel!
|
|
|
|
@IBOutlet var token3: UILabel!
|
|
@IBOutlet var amount3: UILabel!
|
|
@IBOutlet var commission: UILabel!
|
|
@IBOutlet var youGet: UILabel!
|
|
@IBOutlet var amountGet: UILabel!
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
navigationItem.title = L10n.Cash.BillInfo.headerTitle
|
|
navigationItem.leftBarButtonItem = .pop(self)
|
|
|
|
drawDottedLine(start: CGPoint(x: 0, y: 0), end: CGPoint(x: UIScreen.main.bounds.width, y: 0), view: dashedLine)
|
|
date.lzText = bill?.creationDate.string(pattern: "dd.MM.yyyy HH:mm:ss")
|
|
token1.lzText = bill?.token_in.quantity.symbol
|
|
amount1.lzText = bill?.token_in.quantity.amount.toDecimal().toString(max: 5)
|
|
token2.lzText = bill?.token_out.quantity.symbol
|
|
amount2.lzText = bill?.token_out.quantity.amount.toDecimal().toString(max: 5)
|
|
token3.lzText = bill?.token_out.quantity.symbol
|
|
amount3.lzText = ((bill?.token_out.quantity.amount.toDecimal() ?? 0) * 1.03).toString(max: 5)
|
|
commission.lzText = ((bill?.token_out.quantity.amount.toDecimal() ?? 0) * 0.03).toString(max: 5)
|
|
youGet.lzText = bill?.token_in.quantity.symbol
|
|
amountGet.lzText = bill?.token_in.quantity.amount.toDecimal().toString(max: 5)
|
|
}
|
|
|
|
@IBAction func showBlocksPressed(_ sender: Any) {
|
|
//swiftlint:disable:next line_length
|
|
guard let checkBill = URL(billAccount: Network.servers.current.contract(.cash),
|
|
scope: Accounts().current?.username ?? "",
|
|
bounds: "\(bill?.id ?? 0)") else { return }
|
|
UIApplication.shared.open(checkBill, options: [:], completionHandler: nil)
|
|
}
|
|
|
|
@IBAction func destroyPressed(_ sender: Any) {
|
|
let destroyTokensViewController = StoryboardScene.Cccp.cccpControllerDestroyTokens.instantiate()
|
|
destroyTokensViewController.cashBillsService = self.cashBillsService
|
|
destroyTokensViewController.bill = bill
|
|
navigationController?.pushViewController(destroyTokensViewController, animated: true)
|
|
}
|
|
}
|