From 4b93b2226c1c27ab138400e49754adb36f4a2a01 Mon Sep 17 00:00:00 2001
From: Bruno Muniz Azevedo Filho <bruno@elixxir.io>
Date: Tue, 29 Nov 2022 21:15:47 -0300
Subject: [PATCH] fix keyboard dismissing when hud shows up

---
 Sources/AppCore/Models/HUDModel.swift                      | 3 ++-
 Sources/AppCore/RootViewController.swift                   | 1 +
 Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Sources/AppCore/Models/HUDModel.swift b/Sources/AppCore/Models/HUDModel.swift
index 8d2679e6..5e443598 100644
--- a/Sources/AppCore/Models/HUDModel.swift
+++ b/Sources/AppCore/Models/HUDModel.swift
@@ -14,6 +14,7 @@ public struct HUDModel {
     content: String? = nil,
     actionTitle: String? = nil,
     hasDotAnimation: Bool = false,
+    isAutoDismissable: Bool = false,
     onTapClosure: (() -> Void)? = nil
   ) {
     self.title = title
@@ -21,7 +22,7 @@ public struct HUDModel {
     self.actionTitle = actionTitle
     self.onTapClosure = onTapClosure
     self.hasDotAnimation = hasDotAnimation
-    self.isAutoDismissable = onTapClosure == nil && !hasDotAnimation
+    self.isAutoDismissable = isAutoDismissable
   }
 
   public init(
diff --git a/Sources/AppCore/RootViewController.swift b/Sources/AppCore/RootViewController.swift
index 2c794a01..fbeebe5e 100644
--- a/Sources/AppCore/RootViewController.swift
+++ b/Sources/AppCore/RootViewController.swift
@@ -68,6 +68,7 @@ public final class RootViewController: UIViewController {
           return
         }
         add(hudView: HUDView().setup(model: model))
+        view.endEditing(true)
       }.store(in: &cancellables)
   }
 }
diff --git a/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift b/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
index 9a9aacb8..e4249b8b 100644
--- a/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
+++ b/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
@@ -66,6 +66,7 @@ final class SearchLeftViewModel {
       hudManager.show(.init(
         actionTitle: Localized.Ud.Search.cancel,
         hasDotAnimation: true,
+        isAutoDismissable: false,
         onTapClosure: { [weak self] in
           guard let self else { return }
           self.didTapCancelSearch()
@@ -114,6 +115,7 @@ final class SearchLeftViewModel {
     hudManager.show(.init(
       actionTitle: Localized.Ud.Search.cancel,
       hasDotAnimation: true,
+      isAutoDismissable: false,
       onTapClosure: { [weak self] in
         guard let self else { return }
         self.didTapCancelSearch()
-- 
GitLab