Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-2104 - Fixed messaging nav bar when search is active #605

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class BaseViewController: UIViewController, CNavigationControllerChild, ViewAnal

var keyboardFrame: CGRect { KeyboardService.shared.keyboardFrame }
var keyboardAnimationDuration: TimeInterval { KeyboardService.shared.keyboardAnimationDuration }
var keyboardAppeared: Bool { KeyboardService.shared.keyboardAppeared }
var isKeyboardOpened: Bool { KeyboardService.shared.isKeyboardOpened }
var isObservingKeyboard: Bool { false }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct HomeActivityView: View, ViewAnalyticsLogger {
logAnalytic(event: .didPullToRefresh)
await viewModel.didPullToRefresh()
}
.onReceive(keyboardPublisher) { value in
.onReceive(KeyboardService.shared.keyboardOpenedPublisher.receive(on: DispatchQueue.main)) { value in
viewModel.isKeyboardActive = value
if !value {
UDVibration.buttonTap.vibrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct HomeExploreView: View, ViewAnalyticsLogger {
.passViewAnalyticsDetails(logger: self)
.displayError($viewModel.error)
.background(Color.backgroundMuted2)
.onReceive(keyboardPublisher) { value in
.onReceive(KeyboardService.shared.keyboardOpenedPublisher.receive(on: DispatchQueue.main)) { value in
viewModel.isKeyboardActive = value
if !value {
UDVibration.buttonTap.vibrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ChatListView: View, ViewAnalyticsLogger {
.trackAppearanceAnalytics(analyticsLogger: self)
.displayError($viewModel.error)
.background(Color.backgroundMuted2)
.onReceive(keyboardPublisher) { value in
.onReceive(KeyboardService.shared.keyboardOpenedPublisher.receive(on: DispatchQueue.main)) { value in
viewModel.isSearchActive = value
if !value {
UDVibration.buttonTap.vibrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ final class KeyboardService {

static let shared = KeyboardService()

@Published
private(set) var keyboardFrame: CGRect = .zero
@Published private(set) var keyboardFrame: CGRect = .zero
var keyboardFramePublisher: Published<CGRect>.Publisher { $keyboardFrame }

@Published private(set) var isKeyboardOpened = false
var keyboardOpenedPublisher: Published<Bool>.Publisher { $isKeyboardOpened }

private(set) var keyboardAnimationDuration: TimeInterval = 0.25
private(set) var keyboardAppeared = false
private(set) var isKeyboardOpened = false
private var cancellables: Set<AnyCancellable> = []
private var listeners: [KeyboardServiceListenerHolder] = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ extension View {
appContext.coreAppCoordinator.topVC?.view.allSubviewsOfType(type) ?? []
}

var keyboardPublisher: AnyPublisher<Bool, Never> {
Publishers.Merge(
NotificationCenter.default
.publisher(for: UIResponder.keyboardWillShowNotification)
.map { _ in true },

NotificationCenter.default
.publisher(for: UIResponder.keyboardWillHideNotification)
.map { _ in false }
)
.eraseToAnyPublisher()
}

var screenSize: CGSize { UIScreen.main.bounds.size }
var isIPSE: Bool { deviceSize == .i4_7Inch }
}
Expand Down