Skip to content

Commit

Permalink
Add use another account button to SetupInitialViewController (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharchevskyi authored Dec 29, 2021
1 parent b6aa4a6 commit e096689
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 30 deletions.
60 changes: 33 additions & 27 deletions FlowCrypt/Common UI/CommonNodesInputs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,45 @@ import FlowCryptUI
import UIKit

extension TextCellNode {
static let loading: TextCellNode = .init(
input: .init(
backgroundColor: .backgroundColor,
title: "loading_title".localized + "...",
withSpinner: true,
size: CGSize(width: 44, height: 44)
static var loading: TextCellNode {
.init(
input: .init(
backgroundColor: .backgroundColor,
title: "loading_title".localized + "...",
withSpinner: true,
size: CGSize(width: 44, height: 44)
)
)
)
}
}

extension ButtonCellNode.Input {
static let retry: ButtonCellNode.Input = .init(
title: "retry_title"
.localized
.attributed(.bold(16), color: .white, alignment: .center),
insets: UIEdgeInsets(top: 16, left: 24, bottom: 8, right: 24),
color: .main
)
static var retry: ButtonCellNode.Input {
.init(
title: "retry_title"
.localized
.attributed(.bold(16), color: .white, alignment: .center),
insets: UIEdgeInsets(top: 16, left: 24, bottom: 8, right: 24),
color: .main
)
}

static let chooseAnotherAccount: ButtonCellNode.Input = .init(
title: "setup_use_another"
.localized
.attributed(
.regular(15),
color: UIColor.colorFor(
darkStyle: .white,
lightStyle: .blueColor
static var chooseAnotherAccount: ButtonCellNode.Input {
.init(
title: "setup_use_another"
.localized
.attributed(
.regular(15),
color: UIColor.colorFor(
darkStyle: .white,
lightStyle: .blueColor
),
alignment: .center
),
alignment: .center
),
insets: .side(8),
color: .backgroundColor
)
insets: .side(8),
color: .backgroundColor
)
}
}

extension CheckBoxTextNode.Input {
Expand Down
9 changes: 7 additions & 2 deletions FlowCrypt/Controllers/Setup/SetupInitialViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class SetupInitialViewController: TableNodeViewController {
case .searchingKeyBackupsInInbox:
return 2
case .error:
return 3
return 4
case .noKeyBackupsInInbox:
return Parts.allCases.count
}
Expand Down Expand Up @@ -306,7 +306,7 @@ extension SetupInitialViewController {
return TextCellNode(
input: .init(
backgroundColor: .backgroundColor,
title: error.localizedDescription,
title: error.errorMessage,
withSpinner: false,
size: CGSize(width: 200, height: 200)
)
Expand All @@ -315,6 +315,10 @@ extension SetupInitialViewController {
return ButtonCellNode(input: .retry) { [weak self] in
self?.state = .searchingKeyBackupsInInbox
}
case 3:
return ButtonCellNode(input: .chooseAnotherAccount) { [weak self] in
self?.signOut()
}
default:
return ASCellNode()
}
Expand All @@ -332,6 +336,7 @@ extension SetupInitialViewController {
let viewController = SetupGenerateKeyViewController(appContext: appContext, user: user)
navigationController?.pushViewController(viewController, animated: true)
}

private func proceedToSetupWithEKMKeys(keys: [KeyDetails]) {
let viewController = SetupEKMKeyViewController(appContext: appContext, user: user, keys: keys)
navigationController?.pushViewController(viewController, animated: true)
Expand Down
2 changes: 1 addition & 1 deletion FlowCrypt/Extensions/UIColorExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public extension UIColor {
lightStyle: .black
)
}

static var warningColor: UIColor {
UIColor(r: 194, g: 126, b: 35)
}
Expand Down
13 changes: 13 additions & 0 deletions FlowCrypt/Functionality/Mail Provider/Imap/ImapError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ enum ImapError: Error {
case providerError(Error)
case missedMessageInfo(String)
}

extension ImapError: CustomStringConvertible {
var description: String {
switch self {
case .noSession:
return "imap_error_no_session".localized
case .providerError(let error):
return "imap_error_provider".localizeWithArguments(error.localizedDescription)
case .missedMessageInfo(let message):
return "imap_error_msg_info".localizeWithArguments(message)
}
}
}
5 changes: 5 additions & 0 deletions FlowCrypt/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,8 @@

// Attachments details
"no_preview_avalable" = "No preview available";

// ImapError
"imap_error_no_session" = "Session isn't established";
"imap_error_provider" = "Provider error %@";
"imap_error_msg_info" = "Can't parse message without \"%@\"";

0 comments on commit e096689

Please sign in to comment.