Files
a9fd9010f8 Gh safe creation flow (#3154)
* Create screen
* Create flow
* Fix layout
* Add todos

---------

Co-authored-by: Dirk Jäckel <[email protected]>
2023-07-05 09:23:31 +02:00

84 lines
2.7 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// InstructionsViewController.swift
// Multisig
//
// Created by Dirk Jäckel on 22.02.22.
// Copyright © 2022 Gnosis Ltd. All rights reserved.
//
import UIKit
class InstructionsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var button: UIButton!
@IBOutlet weak var tableView: UITableView!
enum Step {
case header
case step(number: String, title: String, description: String)
case finalStep(title: String)
}
var onClose: () -> Void = {}
var steps: [Step] = []
var chain: Chain?
override func viewDidLoad() {
super.viewDidLoad()
title = "How does it work?"
tableView.registerCell(InstructionHeaderTableViewCell.self)
tableView.registerCell(FinalStepInstructionTableViewCell.self)
tableView.registerCell(StepInstructionTableViewCell.self)
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 100
button.setText("OK, Let’s start", .filled)
}
override func closeModal() {
onClose()
}
@IBAction func didTapButton(_ sender: Any) {
let createSafeVC = CreateSafeViewController()
createSafeVC.onClose = onClose
if let chain = chain {
createSafeVC.chain = chain
}
show(createSafeVC, sender: self)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let currentStep = steps[indexPath.row]
switch currentStep {
case .header:
let cell = tableView.dequeueCell(InstructionHeaderTableViewCell.self, for: indexPath)
cell.selectionStyle = .none
cell.separatorInset.left = .greatestFiniteMagnitude
return cell
case let .step(number: number, title: title, description: description):
let cell = tableView.dequeueCell(StepInstructionTableViewCell.self, for: indexPath)
cell.selectionStyle = .none
cell.separatorInset.left = .greatestFiniteMagnitude
cell.circleLabel.text = number
cell.headerLabel.text = title
cell.descriptionLabel.text = description
return cell
case let .finalStep(title: title):
let cell = tableView.dequeueCell(FinalStepInstructionTableViewCell.self, for: indexPath)
cell.cellLabel.text = title
cell.selectionStyle = .none
cell.separatorInset.left = .greatestFiniteMagnitude
return cell
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
steps.count
}
}