Files
raspberry/iOS/Wallet/Sources/Account/Controller/AccountController.swift
T

84 lines
3.9 KiB
Swift

//
// AccountUIViewController.swift
// List
//
// Created by Igor Danich on 25.06.2020.
// Copyright © 2020 Igor Danich. All rights reserved.
//
import UIKit
//import MaterialComponents.MaterialBottomSheet
class AccountController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Account"
}
}
extension AccountController {
static func showPopup(in viewController: UIViewController) {
let ctrl = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
ctrl.addAction(.init(title: L10n.Account.Alert.manual, style: .default) { _ in
let manualController = StoryboardScene.Account.manual.instantiate()
let ctrl = UINavigationController(rootViewController: manualController)
manualController.privateKeyHasBeenProcessed = {
ctrl.dismiss(animated: true)
}
ctrl.modalPresentationStyle = .fullScreen
viewController.present(ctrl, animated: true)
})
// Hide buttons while there is no clarity about buying wallet
// if let accountPrice = AccountOnboarding.Service.IAP.shared.products.first?.localizedPrice(),
// AccountOnboarding.Service.IAP.shared.canMakePayments() {
// ctrl.addAction(.init(title: L10n.Account.Alert.create + " ~\(accountPrice)", style: .default) { _ in
// let ctrl = UINavigationController(rootViewController: StoryboardScene.AccountOnboarding.accountOnboardingControllerSimpleUsername.instantiate())
// (ctrl.viewControllers.first as? AccountOnboardingControllerSimpleUsername)?.canClose = true
// ctrl.modalPresentationStyle = .fullScreen
// viewController.present(ctrl, animated: true)
// })
// }
ctrl.addAction(.init(title: L10n.Common.Button.cancel, style: .cancel, handler: nil))
viewController.present(ctrl, animated: true)
}
static func showPrivateKeyPopup(in viewController: UIViewController, account: Account.Model) {
Alert.system(
actions: [
.init(title: L10n.Main.Account.export, style: .default) { _ in
Account.Service.Authorize.shared.password = nil
AccountViewAuthorize.showGetPrivateKey(in: viewController, description: L10n.Main.Account.exportDescription) {
let ctrl = AccountViewControllerPrivateKey()
ctrl.subView.keyLbl.lzText = $0
ctrl.subView.qrImgView.image = $0.generateQRCode()
viewController.mainController.content.push(ctrl, animated: true)
}
},
.init(title: L10n.Main.Account.change, style: .default) { _ in
Account.Service.Authorize.shared.password = nil
AccountViewAuthorize.showGetPrivateKey(in: viewController, description: L10n.Main.Account.exportDescription) {
let changeKeyController = StoryboardScene.Account.changeKey.instantiate()
changeKeyController.navigationItem.leftBarButtonItem = .back {
DispatchQueue.main.async {
viewController.dismiss(animated: true)
}
}
changeKeyController.account = account
changeKeyController.privateKey = $0
let ctrl = UINavigationController(rootViewController: changeKeyController)
ctrl.modalPresentationStyle = .fullScreen
viewController.present(ctrl, animated: true)
}
},
.init(title: L10n.Common.Button.cancel, style: .cancel)
],
style: .actionSheet,
in: viewController
)
}
}