Files
Dirk JäckelandGitHub 46a5c50276 GH-2184 - Tracking (#2217)
* GH-2184 Track chainId with screen
* GH-2184 adding the chainid is handled within the tracking event method
* GH-2184 Add backup skipped tracking.
* GH-2184 More backup tracking
* GH-2184 Move tracking to a better place.
* GH-2184 Typos.
* GH-2184 Typos continued
* GH-2184 Not going to backup from key selection.
* GH-2184 confirm -> propose
* GH-2184 Missing events
* GH-2184 chainId -> chain_id
* GH-2184 All those tracking keys start with "screen" and are already included.
* GH-2184 copy seed phrase tracking
2022-04-19 15:04:18 +02:00

78 lines
2.6 KiB
Swift

//
// ExportViewController.swift
// Multisig
//
// Created by Dmitry Bespalov on 26.05.21.
// Copyright © 2021 Gnosis Ltd. All rights reserved.
//
import UIKit
class ExportViewController: ContainerViewController {
var privateKey: String = ""
var seedPhrase: [String]?
var segmentVC: SegmentViewController!
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Export"
navigationItem.rightBarButtonItem = UIBarButtonItem(
image: UIImage(systemName: "square.and.arrow.up"),
style: .done,
target: self,
action: #selector(didTapExport(_:)))
if let seedPhrase = seedPhrase {
// create seed phrase and private key inside segment view controller
let seedPhraseVC = SeedPhraseViewController(nibName: nil, bundle: nil)
seedPhraseVC.seedPhrase = seedPhrase
let privateKeyVC = PrivateKeyViewController(nibName: nil, bundle: nil)
privateKeyVC.showsHeader = false
privateKeyVC.privateKey = privateKey
segmentVC = SegmentViewController(namedClass: nil)
segmentVC.segmentItems = [
SegmentBarItem(image: UIImage(named: "ico-seed-phrase")!, title: "SEED PHRASE"),
SegmentBarItem(image: UIImage(named: "ico-private-key")!, title: "PRIVATE KEY")
]
segmentVC.viewControllers = [
seedPhraseVC,
privateKeyVC
]
segmentVC.selectedIndex = 0
viewControllers = [segmentVC]
displayChild(at: 0, in: view)
} else {
// only create private key controller
let privateKeyVC = PrivateKeyViewController(nibName: nil, bundle: nil)
privateKeyVC.showsHeader = true
privateKeyVC.privateKey = privateKey
viewControllers = [privateKeyVC]
displayChild(at: 0, in: view)
}
}
@objc func didTapExport(_ sender: Any) {
let vc = seedPhrase == nil ? viewControllers.first : segmentVC?.selectedViewController
switch vc {
case let vc as SeedPhraseViewController:
export(vc.seedPhrase.joined(separator: " "))
case let vc as PrivateKeyViewController:
export(vc.privateKey)
default:
assertionFailure("Check that controller is set up and configured correctly")
}
}
func export(_ value: String) {
Tracker.trackEvent(.backupUserCopiedSeedPhrase)
let vc = UIActivityViewController(activityItems: [value], applicationActivities: nil)
present(vc, animated: true, completion: nil)
}
}