Skip to content

Commit

Permalink
KeyboardObserver injection moved to the root ContentView for wider us…
Browse files Browse the repository at this point in the history
…age in ongoing views
  • Loading branch information
Devepre committed Dec 8, 2019
1 parent 9aa5336 commit cc22878
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions QBChat-MVVM/QBChat-MVVM/Common/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let viewModel = AnyViewModel(ChatListViewModel(chatService: chatService))
let contentView = ChatListView()
.environmentObject(viewModel)
.environmentObject(KeyboardObserver.shared)

// Use a UIHostingController as window root view controller.
if let windowScene = scene as? UIWindowScene {
Expand Down
6 changes: 2 additions & 4 deletions QBChat-MVVM/QBChat-MVVM/View/ChatList/ChatListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ struct ChatListView: View {
var body: some View {
NavigationView {
List(viewModel.chats) { viewModel in
NavigationLink(destination: ChatDetailView()
.environmentObject(viewModel)
.environmentObject(KeyboardObserver.shared)) {
ChatCell(chat: viewModel.state.chat)
NavigationLink(destination: ChatDetailView().environmentObject(viewModel)) {
ChatCell(chat: viewModel.state.chat)
}
}
.navigationBarTitle("Chats")
Expand Down

0 comments on commit cc22878

Please sign in to comment.