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

Refactored HUD

parent 3f1517d0
No related branches found
No related tags found
2 merge requests!54Releasing 1.1.4,!50Search UI 2.0
Showing
with 38 additions and 17 deletions
...@@ -47,7 +47,7 @@ final class RestoreListViewModel { ...@@ -47,7 +47,7 @@ final class RestoreListViewModel {
guard let self = self else { return } guard let self = self else { return }
controller.navigationController?.popViewController(animated: true) controller.navigationController?.popViewController(animated: true)
self.hudSubject.send(.on(nil)) self.hudSubject.send(.on)
self.sftpService.fetchMetadata{ result in self.sftpService.fetchMetadata{ result in
switch result { switch result {
...@@ -72,7 +72,7 @@ final class RestoreListViewModel { ...@@ -72,7 +72,7 @@ final class RestoreListViewModel {
googleDriveService.authorize(presenting: controller) { authResult in googleDriveService.authorize(presenting: controller) { authResult in
switch authResult { switch authResult {
case .success: case .success:
self.hudSubject.send(.on(nil)) self.hudSubject.send(.on)
self.googleDriveService.downloadMetadata { downloadResult in self.googleDriveService.downloadMetadata { downloadResult in
switch downloadResult { switch downloadResult {
case .success(let metadata): case .success(let metadata):
...@@ -97,7 +97,7 @@ final class RestoreListViewModel { ...@@ -97,7 +97,7 @@ final class RestoreListViewModel {
private func didRequestICloudAuthorization() { private func didRequestICloudAuthorization() {
if icloudService.isAuthorized() { if icloudService.isAuthorized() {
self.hudSubject.send(.on(nil)) self.hudSubject.send(.on)
icloudService.downloadMetadata { result in icloudService.downloadMetadata { result in
switch result { switch result {
...@@ -129,7 +129,7 @@ final class RestoreListViewModel { ...@@ -129,7 +129,7 @@ final class RestoreListViewModel {
case .success(let bool): case .success(let bool):
guard bool == true else { return } guard bool == true else { return }
self.hudSubject.send(.on(nil)) self.hudSubject.send(.on)
dropboxService.downloadMetadata { metadataResult in dropboxService.downloadMetadata { metadataResult in
switch metadataResult { switch metadataResult {
case .success(let metadata): case .success(let metadata):
......
...@@ -5,7 +5,7 @@ import DependencyInjection ...@@ -5,7 +5,7 @@ import DependencyInjection
import ScrollViewController import ScrollViewController
public final class SFTPController: UIViewController { public final class SFTPController: UIViewController {
@Dependency private var hud: HUDType @Dependency private var hud: HUD
lazy private var screenView = SFTPView() lazy private var screenView = SFTPView()
lazy private var scrollViewController = ScrollViewController() lazy private var scrollViewController = ScrollViewController()
......
...@@ -45,7 +45,7 @@ final class SFTPViewModel { ...@@ -45,7 +45,7 @@ final class SFTPViewModel {
} }
func didTapLogin() { func didTapLogin() {
hudSubject.send(.on(nil)) hudSubject.send(.on)
let host = stateSubject.value.host let host = stateSubject.value.host
let username = stateSubject.value.username let username = stateSubject.value.username
......
...@@ -9,7 +9,7 @@ import DrawerFeature ...@@ -9,7 +9,7 @@ import DrawerFeature
import DependencyInjection import DependencyInjection
final class SearchLeftController: UIViewController { final class SearchLeftController: UIViewController {
@Dependency private var hud: HUDType @Dependency private var hud: HUD
@Dependency private var coordinator: SearchCoordinating @Dependency private var coordinator: SearchCoordinating
@KeyObject(.email, defaultValue: nil) var email: String? @KeyObject(.email, defaultValue: nil) var email: String?
...@@ -19,12 +19,14 @@ final class SearchLeftController: UIViewController { ...@@ -19,12 +19,14 @@ final class SearchLeftController: UIViewController {
lazy private var screenView = SearchLeftView() lazy private var screenView = SearchLeftView()
private var cancellables = Set<AnyCancellable>()
private var dataSource: SearchDiffableDataSource! private var dataSource: SearchDiffableDataSource!
private(set) var viewModel = SearchLeftViewModel() private(set) var viewModel = SearchLeftViewModel()
private var drawerCancellables = Set<AnyCancellable>() private var drawerCancellables = Set<AnyCancellable>()
private let adrpURLString = "https://links.xx.network/adrp" private let adrpURLString = "https://links.xx.network/adrp"
private var cancellables = Set<AnyCancellable>()
private var hudCancellables = Set<AnyCancellable>()
override func loadView() { override func loadView() {
view = screenView view = screenView
} }
...@@ -75,10 +77,24 @@ final class SearchLeftController: UIViewController { ...@@ -75,10 +77,24 @@ final class SearchLeftController: UIViewController {
private func setupBindings() { private func setupBindings() {
viewModel.hudPublisher viewModel.hudPublisher
.removeDuplicates()
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [hud] in hud.update(with: $0) } .sink { [unowned self] in
hud.update(with: $0)
if case .onAction = $0, let hudBtn = hud.actionButton {
hudBtn.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in viewModel.didTapCancelSearch() }
.store(in: &self.hudCancellables)
} else {
hudCancellables.forEach { $0.cancel() }
hudCancellables.removeAll()
}
}
.store(in: &cancellables) .store(in: &cancellables)
viewModel.statePublisher viewModel.statePublisher
.map(\.item) .map(\.item)
.removeDuplicates() .removeDuplicates()
......
import HUD import HUD
import UIKit import UIKit
import Shared
import Combine import Combine
import XXModels import XXModels
import Countries import Countries
...@@ -56,7 +57,7 @@ final class SearchLeftViewModel { ...@@ -56,7 +57,7 @@ final class SearchLeftViewModel {
func didStartSearching() { func didStartSearching() {
guard stateSubject.value.input.isEmpty == false else { return } guard stateSubject.value.input.isEmpty == false else { return }
hudSubject.send(.on(nil)) hudSubject.send(.onAction(Localized.Ud.Search.cancel))
var content = stateSubject.value.input var content = stateSubject.value.input
let prefix = stateSubject.value.item.written.first!.uppercased() let prefix = stateSubject.value.item.written.first!.uppercased()
...@@ -78,7 +79,7 @@ final class SearchLeftViewModel { ...@@ -78,7 +79,7 @@ final class SearchLeftViewModel {
} }
func didTapRequest(contact: Contact) { func didTapRequest(contact: Contact) {
hudSubject.send(.on(nil)) hudSubject.send(.on)
var contact = contact var contact = contact
contact.nickname = contact.username contact.nickname = contact.username
......
...@@ -10,7 +10,7 @@ import DependencyInjection ...@@ -10,7 +10,7 @@ import DependencyInjection
public final class AccountDeleteController: UIViewController { public final class AccountDeleteController: UIViewController {
@KeyObject(.username, defaultValue: "") var username: String @KeyObject(.username, defaultValue: "") var username: String
@Dependency private var hud: HUDType @Dependency private var hud: HUD
@Dependency private var coordinator: SettingsCoordinating @Dependency private var coordinator: SettingsCoordinating
lazy private var screenView = AccountDeleteView() lazy private var screenView = AccountDeleteView()
......
...@@ -8,7 +8,7 @@ import DependencyInjection ...@@ -8,7 +8,7 @@ import DependencyInjection
import ScrollViewController import ScrollViewController
public final class SettingsController: UIViewController { public final class SettingsController: UIViewController {
@Dependency private var hud: HUDType @Dependency private var hud: HUD
@Dependency private var coordinator: SettingsCoordinating @Dependency private var coordinator: SettingsCoordinating
@Dependency private var statusBarController: StatusBarStyleControlling @Dependency private var statusBarController: StatusBarStyleControlling
......
...@@ -17,7 +17,7 @@ final class AccountDeleteViewModel { ...@@ -17,7 +17,7 @@ final class AccountDeleteViewModel {
deleting = true deleting = true
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.hudRelay.send(.on(nil)) self?.hudRelay.send(.on)
} }
do { do {
......
...@@ -110,7 +110,7 @@ final class SettingsViewModel { ...@@ -110,7 +110,7 @@ final class SettingsViewModel {
} }
private func pushNotifications(enable: Bool) { private func pushNotifications(enable: Bool) {
hudRelay.send(.on(nil)) hudRelay.send(.on)
if enable == true { if enable == true {
pushHandler.requestAuthorization { [weak self] result in pushHandler.requestAuthorization { [weak self] result in
......
...@@ -1238,6 +1238,8 @@ public enum Localized { ...@@ -1238,6 +1238,8 @@ public enum Localized {
public static let title = Localized.tr("Localizable", "ud.requestDrawer.title") public static let title = Localized.tr("Localizable", "ud.requestDrawer.title")
} }
public enum Search { public enum Search {
/// Cancel search
public static let cancel = Localized.tr("Localizable", "ud.search.cancel")
/// There are no users with that %@. /// There are no users with that %@.
public static func empty(_ p1: Any) -> String { public static func empty(_ p1: Any) -> String {
return Localized.tr("Localizable", "ud.search.empty", String(describing: p1)) return Localized.tr("Localizable", "ud.search.empty", String(describing: p1))
......
...@@ -987,6 +987,8 @@ ...@@ -987,6 +987,8 @@
= "Search by %@"; = "Search by %@";
"ud.search.empty" "ud.search.empty"
= "There are no users with that %@."; = "There are no users with that %@.";
"ud.search.cancel"
= "Cancel search";
"ud.search.placeholder.title" "ud.search.placeholder.title"
= "Search for #friends# anonymously, add them to your #connections# to start a completely private messaging channel."; = "Search for #friends# anonymously, add them to your #connections# to start a completely private messaging channel.";
......
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://git.xx.network/elixxir/client-ios-db.git", "location" : "https://git.xx.network/elixxir/client-ios-db.git",
"state" : { "state" : {
"revision" : "adf3c4b906870ecbd0d1d7208f0666939fd08665", "revision" : "c0ef6d7d25a6dac4668e684ec155cf0e1eb90617",
"version" : "1.0.5" "version" : "1.0.7"
} }
}, },
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment