This commit is contained in:
Justin Mazzocchi 2020-09-09 16:00:10 -07:00
parent 182ecb5b91
commit a729058add
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
6 changed files with 14 additions and 14 deletions

View file

@ -5,7 +5,7 @@ import Foundation
import Mastodon
import ServiceLayer
public final class TabNavigationViewModel: ObservableObject {
public final class NavigationViewModel: ObservableObject {
public let identification: Identification
@Published public private(set) var recentIdentities = [Identity]()
@Published public var timeline: Timeline
@ -40,7 +40,7 @@ public final class TabNavigationViewModel: ObservableObject {
}
}
public extension TabNavigationViewModel {
public extension NavigationViewModel {
var tabs: [Tab] {
if identification.service.isAuthorized {
return Tab.allCases
@ -92,7 +92,7 @@ public extension TabNavigationViewModel {
}
}
public extension TabNavigationViewModel {
public extension NavigationViewModel {
enum Tab: CaseIterable {
case timelines
case explore
@ -101,6 +101,6 @@ public extension TabNavigationViewModel {
}
}
extension TabNavigationViewModel.Tab: Identifiable {
extension NavigationViewModel.Tab: Identifiable {
public var id: Self { self }
}

View file

@ -5,7 +5,7 @@ import Foundation
import ServiceLayer
public final class RootViewModel: ObservableObject {
@Published public private(set) var navigationViewModel: TabNavigationViewModel?
@Published public private(set) var navigationViewModel: NavigationViewModel?
@Published private var mostRecentlyUsedIdentityID: UUID?
private let environment: AppEnvironment
@ -100,7 +100,7 @@ private extension RootViewModel {
.store(in: &self.cancellables)
}
return TabNavigationViewModel(identification: identification)
return NavigationViewModel(identification: identification)
}
.assign(to: &$navigationViewModel)
}

View file

@ -61,7 +61,7 @@ import PreviewViewModels
struct ListsView_Previews: PreviewProvider {
static var previews: some View {
ListsView(viewModel: .init(identification: .preview))
.environmentObject(TabNavigationViewModel(identification: .preview))
.environmentObject(NavigationViewModel(identification: .preview))
}
}
#endif

View file

@ -5,7 +5,7 @@ import SwiftUI
import ViewModels
struct SecondaryNavigationView: View {
@ObservedObject var viewModel: TabNavigationViewModel
@ObservedObject var viewModel: NavigationViewModel
@EnvironmentObject var identification: Identification
@EnvironmentObject var rootViewModel: RootViewModel
@Environment(\.displayScale) var displayScale: CGFloat
@ -85,7 +85,7 @@ import PreviewViewModels
struct SecondaryNavigationView_Previews: PreviewProvider {
static var previews: some View {
SecondaryNavigationView(viewModel: TabNavigationViewModel(identification: .preview))
SecondaryNavigationView(viewModel: NavigationViewModel(identification: .preview))
.environmentObject(Identification.preview)
.environmentObject(RootViewModel.preview)
}

View file

@ -20,7 +20,7 @@ import PreviewViewModels
struct StatusListView_Previews: PreviewProvider {
static var previews: some View {
StatusListView(viewModel: TabNavigationViewModel(identification: .preview).viewModel(timeline: .home))
StatusListView(viewModel: NavigationViewModel(identification: .preview).viewModel(timeline: .home))
}
}
#endif

View file

@ -6,7 +6,7 @@ import SwiftUI
import ViewModels
struct TabNavigationView: View {
@ObservedObject var viewModel: TabNavigationViewModel
@ObservedObject var viewModel: NavigationViewModel
@EnvironmentObject var rootViewModel: RootViewModel
@Environment(\.displayScale) var displayScale: CGFloat
@ -42,7 +42,7 @@ struct TabNavigationView: View {
private extension TabNavigationView {
@ViewBuilder
func view(tab: TabNavigationViewModel.Tab) -> some View {
func view(tab: NavigationViewModel.Tab) -> some View {
switch tab {
case .timelines:
StatusListView(viewModel: viewModel.viewModel(timeline: viewModel.timeline))
@ -133,7 +133,7 @@ private extension Timeline {
}
}
extension TabNavigationViewModel.Tab {
extension NavigationViewModel.Tab {
var title: String {
switch self {
case .timelines: return "Timelines"
@ -158,7 +158,7 @@ import PreviewViewModels
struct TabNavigation_Previews: PreviewProvider {
static var previews: some View {
TabNavigationView(viewModel: TabNavigationViewModel(identification: .preview))
TabNavigationView(viewModel: NavigationViewModel(identification: .preview))
.environmentObject(Identification.preview)
.environmentObject(RootViewModel.preview)
}