From 5a2dbbe277176c9127ac5b952a2e2ba9dd7927d9 Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho <bruno@elixxir.io> Date: Mon, 18 Jul 2022 13:40:56 -0300 Subject: [PATCH] Fixed empty state for ud username search --- .../SearchUsernameController.swift | 2 ++ .../Views/SearchUsernameView.swift | 30 +++++++++++++++++++ Sources/Shared/AutoGenerated/Strings.swift | 6 +++- .../Resources/en.lproj/Localizable.strings | 3 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Sources/SearchFeature/Controllers/SearchUsernameController.swift b/Sources/SearchFeature/Controllers/SearchUsernameController.swift index d40aac04..45cfd638 100644 --- a/Sources/SearchFeature/Controllers/SearchUsernameController.swift +++ b/Sources/SearchFeature/Controllers/SearchUsernameController.swift @@ -80,6 +80,8 @@ final class SearchUsernameController: UIViewController { .receive(on: DispatchQueue.main) .sink { [unowned self] in screenView.placeholderView.isHidden = true + screenView.emptyView.isHidden = $0.numberOfItems != 0 + dataSource.apply($0, animatingDifferences: false) }.store(in: &cancellables) diff --git a/Sources/SearchFeature/Views/SearchUsernameView.swift b/Sources/SearchFeature/Views/SearchUsernameView.swift index 4e60479d..bd979803 100644 --- a/Sources/SearchFeature/Views/SearchUsernameView.swift +++ b/Sources/SearchFeature/Views/SearchUsernameView.swift @@ -4,6 +4,26 @@ import Shared final class SearchUsernameView: UIView { let tableView = UITableView() let inputField = SearchComponent() + let emptyView: UIView = { + let view = UIView() + let label = UILabel() + + label.numberOfLines = 0 + label.textAlignment = .center + label.font = Fonts.Mulish.regular.font(size: 15.0) + label.text = Localized.Ud.Search.Username.Empty.title + label.textColor = Asset.neutralSecondaryAlternative.color + + view.addSubview(label) + label.snp.makeConstraints { + $0.center.equalToSuperview() + $0.left.equalToSuperview().offset(20) + $0.right.equalToSuperview().offset(-20) + } + + return view + }() + let placeholderView = SearchUsernamePlaceholderView() init() { @@ -14,8 +34,11 @@ final class SearchUsernameView: UIView { imageAtRight: nil ) + emptyView.isHidden = true + addSubview(tableView) addSubview(inputField) + addSubview(emptyView) addSubview(placeholderView) setupConstraints() @@ -37,6 +60,13 @@ final class SearchUsernameView: UIView { $0.bottom.equalToSuperview() } + emptyView.snp.makeConstraints { + $0.top.equalTo(inputField.snp.bottom).offset(20) + $0.left.equalToSuperview() + $0.right.equalToSuperview() + $0.bottom.equalToSuperview() + } + placeholderView.snp.makeConstraints { $0.top.equalTo(inputField.snp.bottom) $0.left.equalToSuperview().offset(32.5) diff --git a/Sources/Shared/AutoGenerated/Strings.swift b/Sources/Shared/AutoGenerated/Strings.swift index 0117c9b8..ada5805c 100644 --- a/Sources/Shared/AutoGenerated/Strings.swift +++ b/Sources/Shared/AutoGenerated/Strings.swift @@ -218,7 +218,7 @@ public enum Localized { 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. + /// Login to your server. Your credentials will be automatically and securely 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") @@ -1249,6 +1249,10 @@ public enum Localized { public enum Username { /// Search by username public static let input = Localized.tr("Localizable", "ud.search.username.input") + public enum Empty { + /// There are no users with that username + public static let title = Localized.tr("Localizable", "ud.search.username.empty.title") + } public enum Placeholder { /// Your searches are anonymous. Search information is never linked to your account or personally identifiable. public static let subtitle = Localized.tr("Localizable", "ud.search.username.placeholder.subtitle") diff --git a/Sources/Shared/Resources/en.lproj/Localizable.strings b/Sources/Shared/Resources/en.lproj/Localizable.strings index fb5ab0e2..0668a396 100644 --- a/Sources/Shared/Resources/en.lproj/Localizable.strings +++ b/Sources/Shared/Resources/en.lproj/Localizable.strings @@ -989,6 +989,9 @@ "ud.search.phone.input" = "Search by phone number"; +"ud.search.username.empty.title" += "There are no users with that username"; + "ud.search.username.placeholder.title" = "Search for #friends# anonymously, add them to your #connections# to start a completely private messaging channel."; "ud.search.username.placeholder.subtitle" -- GitLab