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

Merge branch 'fix/mr-50-patch' into 'development'

Fixed comments on MR 50

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