Remove reference to view model in UIViewControllerRepresentable

This commit is contained in:
Justin Mazzocchi 2020-12-02 10:59:02 -08:00
parent b5f80237b0
commit a62c6d9781
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 10 additions and 10 deletions

View file

@ -22,10 +22,10 @@ struct PreferencesView: View {
viewModel: .init(identification: identification)))
}
NavigationLink("preferences.muted-users",
destination: TableView(viewModel: viewModel.mutedUsersViewModel())
destination: TableView(viewModelClosure: viewModel.mutedUsersViewModel)
.navigationTitle(Text("preferences.muted-users")))
NavigationLink("preferences.blocked-users",
destination: TableView(viewModel: viewModel.blockedUsersViewModel())
destination: TableView(viewModelClosure: viewModel.blockedUsersViewModel)
.navigationTitle(Text("preferences.blocked-users")))
}
Section(header: Text("preferences.app")) {

View file

@ -56,11 +56,11 @@ struct SecondaryNavigationView: View {
NavigationLink(destination: ListsView(viewModel: .init(identification: viewModel.identification))) {
Label("secondary-navigation.lists", systemImage: "scroll")
}
NavigationLink(destination: TableView(viewModel: viewModel.favoritesViewModel())
NavigationLink(destination: TableView(viewModelClosure: viewModel.favoritesViewModel)
.navigationTitle(Text("favorites"))) {
Label("favorites", systemImage: "star")
}
NavigationLink(destination: TableView(viewModel: viewModel.bookmarksViewModel())
NavigationLink(destination: TableView(viewModelClosure: viewModel.bookmarksViewModel)
.navigationTitle(Text("bookmarks"))) {
Label("bookmarks", systemImage: "bookmark")
}

View file

@ -62,7 +62,7 @@ private extension TabNavigationView {
func view(tab: NavigationViewModel.Tab) -> some View {
switch tab {
case .timelines:
TableView(viewModel: viewModel.timelineViewModel)
TableView { viewModel.timelineViewModel }
.id(viewModel.timeline.id)
.edgesIgnoringSafeArea(.all)
.navigationTitle(viewModel.timeline.title)
@ -95,7 +95,7 @@ private extension TabNavigationView {
})
case .notifications:
if let notificationsViewModel = viewModel.notificationsViewModel {
TableView(viewModel: notificationsViewModel)
TableView { notificationsViewModel }
.id(tab)
.edgesIgnoringSafeArea(.all)
.navigationTitle("notifications")
@ -104,7 +104,7 @@ private extension TabNavigationView {
}
case .messages:
if let conversationsViewModel = viewModel.conversationsViewModel {
TableView(viewModel: conversationsViewModel)
TableView { conversationsViewModel }
.id(tab)
.edgesIgnoringSafeArea(.all)
.navigationTitle("messages")

View file

@ -5,10 +5,10 @@ import ViewModels
struct TableView: UIViewControllerRepresentable {
@EnvironmentObject var identification: Identification
let viewModel: CollectionViewModel
let viewModelClosure: () -> CollectionViewModel
func makeUIViewController(context: Context) -> TableViewController {
TableViewController(viewModel: viewModel, identification: identification)
TableViewController(viewModel: viewModelClosure(), identification: identification)
}
func updateUIViewController(_ uiViewController: TableViewController, context: Context) {
@ -21,7 +21,7 @@ import PreviewViewModels
struct StatusListView_Previews: PreviewProvider {
static var previews: some View {
TableView(viewModel: NavigationViewModel(identification: .preview).timelineViewModel)
TableView { NavigationViewModel(identification: .preview).timelineViewModel }
}
}
#endif