Skip to content
Snippets Groups Projects
Commit 12403d4d authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Working on restore from sftp ui

parent 75b421c9
No related branches found
No related tags found
2 merge requests!54Releasing 1.1.4,!42Adding SFTP as a service to backup/restore
...@@ -215,7 +215,8 @@ let package = Package( ...@@ -215,7 +215,8 @@ let package = Package(
.target( .target(
name: "SFTPFeature", name: "SFTPFeature",
dependencies: [ dependencies: [
"Shared",
"InputField"
] ]
), ),
......
...@@ -161,6 +161,7 @@ struct DependencyRegistrator { ...@@ -161,6 +161,7 @@ struct DependencyRegistrator {
container.register( container.register(
RestoreCoordinator( RestoreCoordinator(
sftpFactory: SFTPController.init,
successFactory: RestoreSuccessController.init, successFactory: RestoreSuccessController.init,
chatListFactory: ChatListController.init, chatListFactory: ChatListController.init,
restoreFactory: RestoreController.init(_:_:), restoreFactory: RestoreController.init(_:_:),
......
...@@ -58,8 +58,9 @@ public final class RestoreListController: UIViewController { ...@@ -58,8 +58,9 @@ public final class RestoreListController: UIViewController {
viewModel.didFetchBackup viewModel.didFetchBackup
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [unowned self] in coordinator.toRestore(using: ndf, with: $0, from: self) } .sink { [unowned self] in
.store(in: &cancellables) coordinator.toRestore(using: ndf, with: $0, from: self)
}.store(in: &cancellables)
screenView.cancelButton screenView.cancelButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
...@@ -68,23 +69,27 @@ public final class RestoreListController: UIViewController { ...@@ -68,23 +69,27 @@ public final class RestoreListController: UIViewController {
screenView.driveButton screenView.driveButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
.sink { [unowned self] in viewModel.didTapCloud(.drive, from: self) } .sink { [unowned self] in
.store(in: &cancellables) viewModel.didTapCloud(.drive, from: self)
}.store(in: &cancellables)
screenView.icloudButton screenView.icloudButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
.sink { [unowned self] in viewModel.didTapCloud(.icloud, from: self) } .sink { [unowned self] in
.store(in: &cancellables) viewModel.didTapCloud(.icloud, from: self)
}.store(in: &cancellables)
screenView.dropboxButton screenView.dropboxButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
.sink { [unowned self] in viewModel.didTapCloud(.dropbox, from: self) } .sink { [unowned self] in
.store(in: &cancellables) viewModel.didTapCloud(.dropbox, from: self)
}.store(in: &cancellables)
screenView.sftpButton screenView.sftpButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
.sink { [unowned self] in viewModel.didTapCloud(.sftp, from: self) } .sink { [unowned self] in
.store(in: &cancellables) coordinator.toSFTP(from: self) //viewModel.didTapCloud(.sftp, from: self)
}.store(in: &cancellables)
} }
@objc private func didTapBack() { @objc private func didTapBack() {
......
...@@ -4,6 +4,7 @@ import Shared ...@@ -4,6 +4,7 @@ import Shared
import Presentation import Presentation
public protocol RestoreCoordinating { public protocol RestoreCoordinating {
func toSFTP(from: UIViewController)
func toChats(from: UIViewController) func toChats(from: UIViewController)
func toSuccess(from: UIViewController) func toSuccess(from: UIViewController)
func toDrawer(_: UIViewController, from: UIViewController) func toDrawer(_: UIViewController, from: UIViewController)
...@@ -16,17 +17,20 @@ public struct RestoreCoordinator: RestoreCoordinating { ...@@ -16,17 +17,20 @@ public struct RestoreCoordinator: RestoreCoordinating {
var bottomPresenter: Presenting = BottomPresenter() var bottomPresenter: Presenting = BottomPresenter()
var replacePresenter: Presenting = ReplacePresenter() var replacePresenter: Presenting = ReplacePresenter()
var sftpFactory: () -> UIViewController
var successFactory: () -> UIViewController var successFactory: () -> UIViewController
var chatListFactory: () -> UIViewController var chatListFactory: () -> UIViewController
var restoreFactory: (String, RestoreSettings) -> UIViewController var restoreFactory: (String, RestoreSettings) -> UIViewController
var passphraseFactory: (@escaping StringClosure) -> UIViewController var passphraseFactory: (@escaping StringClosure) -> UIViewController
public init( public init(
sftpFactory: @escaping () -> UIViewController,
successFactory: @escaping () -> UIViewController, successFactory: @escaping () -> UIViewController,
chatListFactory: @escaping () -> UIViewController, chatListFactory: @escaping () -> UIViewController,
restoreFactory: @escaping (String, RestoreSettings) -> UIViewController, restoreFactory: @escaping (String, RestoreSettings) -> UIViewController,
passphraseFactory: @escaping (@escaping StringClosure) -> UIViewController passphraseFactory: @escaping (@escaping StringClosure) -> UIViewController
) { ) {
self.sftpFactory = sftpFactory
self.successFactory = successFactory self.successFactory = successFactory
self.restoreFactory = restoreFactory self.restoreFactory = restoreFactory
self.chatListFactory = chatListFactory self.chatListFactory = chatListFactory
...@@ -65,4 +69,9 @@ public extension RestoreCoordinator { ...@@ -65,4 +69,9 @@ public extension RestoreCoordinator {
let screen = passphraseFactory(completion) let screen = passphraseFactory(completion)
bottomPresenter.present(screen, from: parent) bottomPresenter.present(screen, from: parent)
} }
func toSFTP(from parent: UIViewController) {
let screen = sftpFactory()
pushPresenter.present(screen, from: parent)
}
} }
// import UIKit
// File.swift
// public final class SFTPController: UIViewController {
// lazy private var screenView = SFTPView()
// Created by Bruno Muniz on 6/30/22.
// public override func loadView() {
view = screenView
import Foundation }
public override func viewDidLoad() {
super.viewDidLoad()
setupNavigationBar()
}
private func setupNavigationBar() {
navigationItem.backButtonTitle = ""
let back = UIButton.back()
back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside)
navigationItem.leftBarButtonItem = UIBarButtonItem(
customView: UIStackView(arrangedSubviews: [back])
)
}
@objc private func didTapBack() {
navigationController?.popViewController(animated: true)
}
}
import UIKit
import Shared
import InputField
final class SFTPView: UIView {
let titleLabel = UILabel()
let subtitleLabel = UILabel()
let hostField = InputField()
let usernameField = InputField()
let passwordField = InputField()
let loginButton = CapsuleButton()
let stackView = UIStackView()
init() {
super.init(frame: .zero)
backgroundColor = Asset.neutralWhite.color
titleLabel.textColor = Asset.neutralDark.color
titleLabel.text = Localized.AccountRestore.Sftp.title
titleLabel.font = Fonts.Mulish.bold.font(size: 24.0)
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .left
paragraph.lineHeightMultiple = 1.15
let attString = NSAttributedString(
string: Localized.AccountRestore.Sftp.subtitle,
attributes: [
.foregroundColor: Asset.neutralBody.color,
.font: Fonts.Mulish.regular.font(size: 16.0) as Any,
.paragraphStyle: paragraph
])
subtitleLabel.numberOfLines = 0
subtitleLabel.attributedText = attString
hostField.setup(
style: .regular,
placeholder: Localized.AccountRestore.Sftp.host
)
usernameField.setup(
style: .regular,
placeholder: Localized.AccountRestore.Sftp.username
)
passwordField.setup(
style: .regular,
placeholder: Localized.AccountRestore.Sftp.password,
rightView: .toggleSecureEntry
)
loginButton.set(style: .brandColored, title: Localized.AccountRestore.Sftp.login)
stackView.spacing = 30
stackView.axis = .vertical
stackView.distribution = .fillEqually
stackView.addArrangedSubview(hostField)
stackView.addArrangedSubview(usernameField)
stackView.addArrangedSubview(passwordField)
stackView.addArrangedSubview(loginButton)
addSubview(titleLabel)
addSubview(subtitleLabel)
addSubview(stackView)
titleLabel.snp.makeConstraints {
$0.top.equalTo(safeAreaLayoutGuide).offset(15)
$0.left.equalToSuperview().offset(38)
$0.right.equalToSuperview().offset(-41)
}
subtitleLabel.snp.makeConstraints {
$0.top.equalTo(titleLabel.snp.bottom).offset(8)
$0.left.equalToSuperview().offset(38)
$0.right.equalToSuperview().offset(-41)
}
stackView.snp.makeConstraints {
$0.top.equalTo(subtitleLabel.snp.bottom).offset(28)
$0.left.equalToSuperview().offset(38)
$0.right.equalToSuperview().offset(-38)
$0.bottom.lessThanOrEqualToSuperview()
}
}
required init?(coder: NSCoder) { nil }
}
...@@ -211,6 +211,20 @@ public enum Localized { ...@@ -211,6 +211,20 @@ public enum Localized {
/// Backup not found /// Backup not found
public static let title = Localized.tr("Localizable", "accountRestore.notFound.title") public static let title = Localized.tr("Localizable", "accountRestore.notFound.title")
} }
public enum Sftp {
/// Host
public static let host = Localized.tr("Localizable", "accountRestore.sftp.host")
/// Login
public static let login = Localized.tr("Localizable", "accountRestore.sftp.login")
/// Password
public static let password = Localized.tr("Localizable", "accountRestore.sftp.password")
/// Login to your server. Your credentials will be automatically and securley saved locally on your device.
public static let subtitle = Localized.tr("Localizable", "accountRestore.sftp.subtitle")
/// Login to your SFTP
public static let title = Localized.tr("Localizable", "accountRestore.sftp.title")
/// Username
public static let username = Localized.tr("Localizable", "accountRestore.sftp.username")
}
public enum Success { public enum Success {
/// You now have access to all your contacts. /// You now have access to all your contacts.
public static let subtitle = Localized.tr("Localizable", "accountRestore.success.subtitle") public static let subtitle = Localized.tr("Localizable", "accountRestore.success.subtitle")
......
...@@ -831,6 +831,19 @@ ...@@ -831,6 +831,19 @@
"accountRestore.list.cancel" "accountRestore.list.cancel"
= "Cancel"; = "Cancel";
"accountRestore.sftp.title"
= "Login to your SFTP";
"accountRestore.sftp.subtitle"
= "Login to your server. Your credentials will be automatically and securley saved locally on your device.";
"accountRestore.sftp.host"
= "Host";
"accountRestore.sftp.username"
= "Username";
"accountRestore.sftp.password"
= "Password";
"accountRestore.sftp.login"
= "Login";
"accountRestore.header" "accountRestore.header"
= "Account restore"; = "Account restore";
"accountRestore.found.title" "accountRestore.found.title"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment