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

Fixed comments on MR 50

parent 7bc0562b
No related branches found
No related tags found
1 merge request!55Fixed comments on MR 50
......@@ -93,8 +93,6 @@ public class Client {
fatalError("Trying to add json parameters to backup but no backup manager created yet")
}
print("^^^ Set params: \(string) to backup")
backupManager.addJson(string)
}
......
......@@ -140,8 +140,6 @@ public final class Session: SessionType {
}
}
print("^^^ \(report.parameters)")
guard username!.isEmpty == false else {
fatalError("Trying to restore an account that has no username")
}
......
......@@ -80,12 +80,12 @@ final class ScanView: UIView {
actionButton.isHidden = false
case .alreadyFriends(let name):
text = Localized.Scan.Error.friends(name)
text = Localized.Scan.Error.alreadyFriends(name)
actionButton.setTitle(Localized.Scan.contact, for: .normal)
actionButton.isHidden = false
case .cameraPermission:
text = Localized.Scan.Error.denied
text = Localized.Scan.Error.cameraPermissionNeeded
actionButton.setTitle(Localized.Scan.settings, for: .normal)
actionButton.isHidden = false
......
......@@ -126,12 +126,20 @@ final class SearchLeftViewModel {
let localsQuery = Contact.Query(text: stateSubject.value.input, authStatus: [.friend])
if let locals = try? session.dbManager.fetchContacts(localsQuery), locals.count > 0 {
let localsWithoutMe = locals.filter { $0.id != session.myId }
if let locals = try? session.dbManager.fetchContacts(localsQuery),
let localsWithoutMe = removeMyself(from: locals),
localsWithoutMe.isEmpty == false {
snapshot.appendSections([.connections])
snapshot.appendItems(localsWithoutMe.map(SearchItem.connection), toSection: .connections)
snapshot.appendItems(
localsWithoutMe.map(SearchItem.connection),
toSection: .connections
)
}
stateSubject.value.snapshot = snapshot
}
private func removeMyself(from collection: [Contact]) -> [Contact]? {
collection.filter { $0.id != session.myId }
}
}
......@@ -39,51 +39,39 @@ final class SearchRightView: UIView {
required init?(coder: NSCoder) { nil }
func update(status: ScanningStatus) {
var text: String
setupTitle(for: status)
setupImageView(for: status)
setupActionButton(for: status)
setupCornerColors(for: status)
setupAnimationView(for: status)
}
switch status {
case .reading, .processing:
imageView.isHidden = true
actionButton.isHidden = true
text = Localized.Scan.Status.reading
overlayView.updateCornerColor(Asset.brandPrimary.color)
private func setupTitle(for status: ScanningStatus) {
let title: String
switch status {
case .success:
animationView.isHidden = true
actionButton.isHidden = true
imageView.isHidden = false
imageView.image = Asset.sharedSuccess.image
text = Localized.Scan.Status.success
overlayView.updateCornerColor(Asset.accentSuccess.color)
case .failed(let error):
animationView.isHidden = true
imageView.image = Asset.scanError.image
imageView.isHidden = false
overlayView.updateCornerColor(Asset.accentDanger.color)
title = Localized.Scan.Status.success
case .reading:
title = Localized.Scan.Status.reading
case .processing:
title = Localized.Scan.Status.processing
case .failed(let scanningError):
switch scanningError {
case .unknown(let content):
title = content
switch error {
case .requestOpened:
text = Localized.Scan.Error.requested
actionButton.setTitle(Localized.Scan.requests, for: .normal)
actionButton.isHidden = false
title = Localized.Scan.Error.requested
case .alreadyFriends(let name):
text = Localized.Scan.Error.friends(name)
actionButton.setTitle(Localized.Scan.contact, for: .normal)
actionButton.isHidden = false
title = Localized.Scan.Error.alreadyFriends(name)
case .cameraPermission:
text = Localized.Scan.Error.denied
actionButton.setTitle(Localized.Scan.settings, for: .normal)
actionButton.isHidden = false
case .unknown(let content):
text = content
title = Localized.Scan.Error.cameraPermissionNeeded
}
}
let attString = NSMutableAttributedString(string: text)
let attString = NSMutableAttributedString(string: title)
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .center
paragraph.lineHeightMultiple = 1.35
......@@ -92,13 +80,71 @@ final class SearchRightView: UIView {
attString.addAttribute(.foregroundColor, value: Asset.neutralWhite.color)
attString.addAttribute(.font, value: Fonts.Mulish.regular.font(size: 14.0) as Any)
if text.contains("#") {
if title.contains("#") {
attString.addAttribute(name: .foregroundColor, value: Asset.brandPrimary.color, betweenCharacters: "#")
}
statusLabel.attributedText = attString
}
private func setupImageView(for status: ScanningStatus) {
let image: UIImage?
switch status {
case .reading, .processing:
image = nil
case .success:
image = Asset.sharedSuccess.image
case .failed(_):
image = Asset.scanError.image
}
imageView.image = image
imageView.isHidden = image == nil
}
private func setupActionButton(for status: ScanningStatus) {
let buttonTitle: String?
switch status {
case .failed(.requestOpened):
buttonTitle = Localized.Scan.requests
case .failed(.alreadyFriends(_)):
buttonTitle = Localized.Scan.contact
case .failed(.cameraPermission):
buttonTitle = Localized.Scan.settings
case .reading, .processing, .success, .failed(.unknown(_)):
buttonTitle = nil
}
actionButton.setTitle(buttonTitle, for: .normal)
actionButton.isHidden = buttonTitle == nil
}
private func setupCornerColors(for status: ScanningStatus) {
let color: UIColor
switch status {
case .reading, .processing:
color = Asset.brandPrimary.color
case .success:
color = Asset.accentSuccess.color
case .failed(_):
color = Asset.accentDanger.color
}
overlayView.updateCornerColor(color)
}
private func setupAnimationView(for status: ScanningStatus) {
switch status {
case .reading, .processing:
animationView.isHidden = false
case .success, .failed(_):
animationView.isHidden = true
}
}
private func setupConstraints() {
overlayView.snp.makeConstraints {
$0.top.equalToSuperview()
......
......@@ -1010,13 +1010,13 @@ public enum Localized {
}
}
public enum Error {
/// Camera needs permission to be used
public static let denied = Localized.tr("Localizable", "scan.error.denied")
/// You've already added
/// #%@#
public static func friends(_ p1: Any) -> String {
return Localized.tr("Localizable", "scan.error.friends", String(describing: p1))
public static func alreadyFriends(_ p1: Any) -> String {
return Localized.tr("Localizable", "scan.error.alreadyFriends", String(describing: p1))
}
/// Camera needs permission to be used
public static let cameraPermissionNeeded = Localized.tr("Localizable", "scan.error.cameraPermissionNeeded")
/// Something’s gone wrong. Please try again.
public static let general = Localized.tr("Localizable", "scan.error.general")
/// Invalid QR code
......@@ -1039,6 +1039,8 @@ public enum Localized {
public static let `right` = Localized.tr("Localizable", "scan.segmentedControl.right")
}
public enum Status {
/// Processing...
public static let processing = Localized.tr("Localizable", "scan.status.processing")
/// Place QR code inside frame to scan
public static let reading = Localized.tr("Localizable", "scan.status.reading")
/// Success
......
......@@ -172,6 +172,8 @@
"scan.status.reading"
= "Place QR code inside frame to scan";
"scan.status.processing"
= "Processing...";
"scan.status.success"
= "Success";
"scan.display.copied"
......@@ -197,7 +199,7 @@
= "Scan Code";
"scan.segmentedControl.right"
= "My Code";
"scan.error.denied"
"scan.error.cameraPermissionNeeded"
= "Camera needs permission to be used";
"scan.error.invalid"
= "Invalid QR code";
......@@ -205,7 +207,7 @@
= "Something’s gone wrong. Please try again.";
"scan.error.requested"
= "You already have a request open with this contact.";
"scan.error.friends"
"scan.error.alreadyFriends"
= "You've already added \n#%@#";
"scan.error.pending"
= "This user is already pending in your contact list";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment