ThreadsMobileLib / edna-sdk-ios

edna iOS sdk release libraries and demo project
11 stars 4 forks source link

Поиск работает некорректно #5

Closed Megal closed 5 years ago

Megal commented 5 years ago

Версия библиотеки 2.43.0

Не работает поиск. При нажатии на кнопку с лупой открывается клавиатура, но не отображается контроллер поиска.

https://monosnap.com/file/oD3fWF4kORuvBCW0ZrsjZWWx864VmB#

Код контроллера:

import UIKit

#if !targetEnvironment(simulator)
//import Threads
#endif // !targetEnvironment(simulator)

protocol NewChatViewProtocol: class {}

class NewChatViewController: UIViewController {

    private let chatService: MinimumChatService
    #if !targetEnvironment(simulator)
    private var attributes = THRAttributes()
    #endif // !targetEnvironment(simulator)

    init(chatService: MinimumChatService) {
        self.chatService = chatService

        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        configure()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        hideNaivgationBar(animated)
        chatService.startSessionIfNeeded()
    }

}

private extension NewChatViewController {

    func configure() {
    #if !targetEnvironment(simulator)
        attributes.navigationBarVisible = true
        attributes.navigationBarBackgroundColor = .white
        attributes.navigationBarTintColor = UIColor.darkText

        Threads.setAttributes(attributes)
        Threads.show(in: view, parentController: self, bottomSpacing: self.tabBarController?.tabBar.frame.height ?? 0.0)
    #endif // !targetEnvironment(simulator)
    }

    func hideNaivgationBar(_ animated: Bool) {
        self.navigationController?.setNavigationBarHidden(true, animated: animated)
    }

}
Megal commented 5 years ago

Нашли решение проблемы, изменили реализацию в след функции:

@@ -59,7 +59,12 @@ private extension NewChatViewController {
         attributes.navigationBarTintColor = UIColor.darkText

         Threads.setAttributes(attributes)
-        Threads.show(in: view, parentController: self, bottomSpacing: self.tabBarController?.tabBar.frame.height ?? 0.0)
+        self.navigationItem.rightBarButtonItem?.isEnabled = false
+
+        if self.children.count < 1 {
+            DLog("Adding threads controller")
+            Threads.show(in: view, parentController: self, bottomSpacing: self.tabBarController?.tabBar.frame.height ?? 0.0)
+        }
     #endif // !targetEnvironment(simulator)
     }