Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create screen #3286

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Multisig.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
0463F5C326296924009C04FA /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = 0463F5C226296924009C04FA /* FirebaseCrashlytics */; };
0463F5C526296924009C04FA /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 0463F5C426296924009C04FA /* FirebaseMessaging */; };
0466877628E6388F0004D488 /* UIViewController+Display.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0466877528E6388F0004D488 /* UIViewController+Display.swift */; };
0468C32B2A826398009872C2 /* KeySecurityOverviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468C3292A826398009872C2 /* KeySecurityOverviewViewController.swift */; };
0468C32F2A83D1DA009872C2 /* SecurityFactorTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468C32D2A83D1DA009872C2 /* SecurityFactorTableViewCell.swift */; };
0468C3302A83D1DA009872C2 /* SecurityFactorTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0468C32E2A83D1DA009872C2 /* SecurityFactorTableViewCell.xib */; };
0468EE9D26148A3B008270BF /* PrivacyProtectionScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468EE9B26148A3B008270BF /* PrivacyProtectionScreenViewController.swift */; };
0468EE9E26148A3B008270BF /* PrivacyProtectionScreenViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0468EE9C26148A3B008270BF /* PrivacyProtectionScreenViewController.xib */; };
0468FB45259106F400541536 /* StyledView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468FB44259106F400541536 /* StyledView.swift */; };
Expand Down Expand Up @@ -1127,6 +1130,9 @@
04626EB4265E6BBC00CC7FC8 /* OwnerKeyDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OwnerKeyDetailsViewController.swift; sourceTree = "<group>"; };
0463F5AB2628B60C009C04FA /* FirebaseRemoteConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseRemoteConfig.swift; sourceTree = "<group>"; };
0466877528E6388F0004D488 /* UIViewController+Display.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Display.swift"; sourceTree = "<group>"; };
0468C3292A826398009872C2 /* KeySecurityOverviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeySecurityOverviewViewController.swift; sourceTree = "<group>"; };
0468C32D2A83D1DA009872C2 /* SecurityFactorTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityFactorTableViewCell.swift; sourceTree = "<group>"; };
0468C32E2A83D1DA009872C2 /* SecurityFactorTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecurityFactorTableViewCell.xib; sourceTree = "<group>"; };
0468EE9B26148A3B008270BF /* PrivacyProtectionScreenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyProtectionScreenViewController.swift; sourceTree = "<group>"; };
0468EE9C26148A3B008270BF /* PrivacyProtectionScreenViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PrivacyProtectionScreenViewController.xib; sourceTree = "<group>"; };
0468FB44259106F400541536 /* StyledView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyledView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2274,6 +2280,16 @@
path = OwnerKeyDetailsViewController;
sourceTree = "<group>";
};
0468C3282A826199009872C2 /* MFA */ = {
isa = PBXGroup;
children = (
0468C3292A826398009872C2 /* KeySecurityOverviewViewController.swift */,
0468C32D2A83D1DA009872C2 /* SecurityFactorTableViewCell.swift */,
0468C32E2A83D1DA009872C2 /* SecurityFactorTableViewCell.xib */,
);
path = MFA;
sourceTree = "<group>";
};
0468FB8D25912E8300541536 /* Cells */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2986,6 +3002,7 @@
0A6886A52588FB0F0045CAB5 /* Settings */ = {
isa = PBXGroup;
children = (
0468C3282A826199009872C2 /* MFA */,
0455A42C2720413B008B772D /* AddressBook */,
558835DE255A90420014E8C7 /* AppSettingsViewController */,
550FB1C626691E4A00C13D54 /* Experimental */,
Expand Down Expand Up @@ -4991,6 +5008,7 @@
0ADD0FB427C148880099DF7D /* DatePickerViewController.xib in Resources */,
0AD0273A25A34FF600886671 /* MultiSendRowTableViewCell.xib in Resources */,
04D1323625E43C560032FA03 /* DetailRejectionInfoCell.xib in Resources */,
0468C3302A83D1DA009872C2 /* SecurityFactorTableViewCell.xib in Resources */,
0472B2AA2857B44F0049BA17 /* ShareTextView.xib in Resources */,
6A1CFA4B2807F24800B2C340 /* NoScreenshotViewController.xib in Resources */,
0A6630F128C10DC300F0FFAE /* AllocationTotalCell.xib in Resources */,
Expand Down Expand Up @@ -5331,6 +5349,7 @@
D88FA81E2770869E0023B77F /* TokenAmountField.swift in Sources */,
93788EDC29C356F100503C1A /* NullCryptoProvider.swift in Sources */,
047588182774D6D2001DD992 /* ReviewSendFundsTransactionViewController.swift in Sources */,
0468C32F2A83D1DA009872C2 /* SecurityFactorTableViewCell.swift in Sources */,
0A8AEB1025A4712B002A3FE1 /* ActionDetailTextCell.swift in Sources */,
0A7AEAF82463190100014184 /* LoadableENSNameText.swift in Sources */,
0A8CDD5327A85C0D0020066C /* TransactionExecutionLookup.swift in Sources */,
Expand Down Expand Up @@ -5567,6 +5586,7 @@
0ADF9DD028B4E02700D4FBA2 /* Guardian.swift in Sources */,
6AD4772F28932160004C736D /* GuardianCountTableViewCell.swift in Sources */,
5532D4BD2449A17D0067505A /* LogFormatter.swift in Sources */,
0468C32B2A826398009872C2 /* KeySecurityOverviewViewController.swift in Sources */,
0AC0948527948BD900FA1B83 /* TransactionDataTransformer.swift in Sources */,
0A451C0C252DDBE5001DB7D2 /* CollectibleListSection.swift in Sources */,
55BCFC2A2551C9C200020CE7 /* UITableView+Reusable.swift in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "ico-relayer-clock.pdf",
"filename" : "Check Filled.pdf",
"idiom" : "universal"
}
],
Expand Down
15 changes: 15 additions & 0 deletions Multisig/Assets.xcassets/ico-clock.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "ico-relayer-clock.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
22 changes: 22 additions & 0 deletions Multisig/Assets.xcassets/ico-mobile.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Mobile.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Mobile (1).pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions Multisig/Assets.xcassets/ico-password.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Lock (1).pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Lock.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ class SafeCellBuilder {
return view
}

func warningCell(image: UIImage? = nil, title: String? = nil, description: String? = nil, for indexPath: IndexPath) -> WarningTableViewCell {
func warningCell(image: UIImage? = nil,
title: String? = nil,
description: String? = nil,
backgroundColor: UIColor = .warningBackground,
for indexPath: IndexPath) -> WarningTableViewCell {
let cell = tableView.dequeueCell(WarningTableViewCell.self, for: indexPath)
cell.set(image: image, title: title, description: description)
cell.set(image: image, title: title, description: description, backgroundColor: backgroundColor)

return cell
}
Expand Down
161 changes: 161 additions & 0 deletions Multisig/UI/Settings/MFA/KeySecurityOverviewViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//
// KeySecurityOverviewViewController.swift
// Multisig
//
// Created by Mouaz on 8/8/23.
// Copyright © 2023 Gnosis Ltd. All rights reserved.
//

import UIKit

fileprivate protocol SectionItem {}

class KeySecurityOverviewViewController: LoadableViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet private var infoButton: UIBarButtonItem!

private typealias SectionItems = (section: Section, items: [SectionItem])
private var sections = [SectionItems]()

enum Section {
case enabledFactors(String)
case otherFactors(String)
case info

enum Factor: SectionItem {
case factor(String, String?, String, Bool, Bool)
}

enum Info: SectionItem {
case info(String, String)
}
}

convenience init() {
self.init(namedClass: Self.superclass())
}

override func viewDidLoad() {
super.viewDidLoad()

tableView.registerCell(SecurityFactorTableViewCell.self)
tableView.registerCell(WarningTableViewCell.self)
tableView.registerHeaderFooterView(BasicHeaderView.self)

tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 60

tableView.delegate = self
tableView.dataSource = self
tableView.tableFooterView = UIView()
title = "Recovery Kit"

if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}

infoButton = UIBarButtonItem(image: UIImage(named: "ico-info-24"),
style: UIBarButtonItem.Style.plain,
target: self,
action: #selector(showHelpScreen))
navigationItem.rightBarButtonItem = infoButton
}

@objc func showHelpScreen() {

}

override func reloadData() {
buildSections()
tableView.reloadData()
}

private func buildSections() {
sections = []

// TODO: Build sections properly
sections.append(SectionItems(section: .enabledFactors("ENABLED FACTORS"), items: [
Section.Factor.factor("Email address", "ann.fischer@gmail", "ico-eMail", true, true)]))
sections.append(SectionItems(section: .otherFactors("OTHER FACTORS"),
items: [
Section.Factor.factor("Security password", nil, "ico-password", false, false),
Section.Factor.factor("Trusted device", nil, "ico-mobile", false, false)]))
sections.append(SectionItems(section: .info,
items: [Section.Info.info("More factors are coming soon!", "ico-clock")]))

let header = TableHeaderView(frame: CGRect(x: 0, y: 0, width: 0, height: 120))
header.set("Protect your owner from unauthorised access and ensure easy recovery. We recommend to enable at least 2 recovery factors.", centered: true, linesCount: 3, backgroundColor: .backgroundPrimary)

tableView.tableHeaderView = header
}

func numberOfSections(in tableView: UITableView) -> Int {
sections.count
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
sections[section].items.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let factor = sections[indexPath.section].items[indexPath.row]
switch sections[indexPath.section].section {
case .enabledFactors(_), .otherFactors(_):
if case let Section.Factor.factor(name, value, image, isDefault, selected) = factor {
let cell = tableView.dequeueCell(SecurityFactorTableViewCell.self, for: indexPath)
cell.selectionStyle = .none
cell.set(name: name,
icon: UIImage(named: image)!,
value: value,
tag: isDefault ? "(Default)" : nil,
selected: selected)

return cell
}
case .info:
if case let Section.Info.info(text, image) = factor {
let cell = tableView.dequeueCell(WarningTableViewCell.self, for: indexPath)
cell.selectionStyle = .none
cell.set(image: UIImage(named: image)?.withTintColor(.info, renderingMode: .alwaysOriginal),
description: text,
backgroundColor: .infoBackground)
cell.backgroundColor = .clear

return cell
}
}

return UITableViewCell()
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var view: UIView?

var title: String
switch sections[section].section {
case .enabledFactors(let name):
title = name
case .otherFactors(let name):
title = name
case .info:
title = ""
}

view = tableView.dequeueHeaderFooterView(BasicHeaderView.self)
(view as! BasicHeaderView).setName(title, backgroundColor: .clear, style: .caption2Secondary)

return view
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
switch sections[section].section {
case .info:
return 0
default:
return BasicHeaderView.headerHeight
}
}
}
37 changes: 37 additions & 0 deletions Multisig/UI/Settings/MFA/SecurityFactorTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// SecurityFactorTableViewCell.swift
// Multisig
//
// Created by Mouaz on 8/9/23.
// Copyright © 2023 Gnosis Ltd. All rights reserved.
//

import UIKit

class SecurityFactorTableViewCell: UITableViewCell {

@IBOutlet private weak var selectedImageView: UIImageView!
@IBOutlet private weak var iconImageView: UIImageView!
@IBOutlet private weak var tagLabel: UILabel!
@IBOutlet private weak var valueLabel: UILabel!
@IBOutlet private weak var nameLabel: UILabel!

override func awakeFromNib() {
super.awakeFromNib()

nameLabel.setStyle(.headline)
tagLabel.setStyle(.subheadlineSecondary)
valueLabel.setStyle(.callout)
}

func set(name: String, icon: UIImage, value: String? = nil, tag: String? = nil, selected: Bool = false) {
nameLabel.text = name
valueLabel.text = value
valueLabel.isHidden = value == nil
tagLabel.text = tag
tagLabel.isHidden = tag == nil
selectedImageView.isHidden = !selected
iconImageView.image = icon
layoutIfNeeded()
}
}
Loading
Loading