remove tab bar from compact apple views

This commit is contained in:
Satindar Dhillon 2022-02-23 08:56:12 -08:00
parent a2b968f991
commit da212e8e46
3 changed files with 14 additions and 56 deletions

View file

@ -4,21 +4,9 @@ import Views
extension PrimaryContentViewModel {
static func make(services: Services) -> PrimaryContentViewModel {
let viewModel = PrimaryContentViewModel(
PrimaryContentViewModel(
homeFeedViewModel: HomeFeedViewModel.make(services: services),
profileContainerViewModel: ProfileContainerViewModel.make(services: services)
)
viewModel.bind(services: services)
return viewModel
}
func bind(services _: Services) {
performActionSubject.sink { action in
switch action {
case .nothing:
break
}
}
.store(in: &subscriptions)
}
}

View file

@ -56,20 +56,3 @@ enum PrimaryContentCategory: Identifiable, Hashable, Equatable {
hasher.combine(id)
}
}
struct TabIcon: View {
let isSelected: Bool
let primaryContentCategory: PrimaryContentCategory
var body: some View {
if isSelected {
Label {
Text(primaryContentCategory.title)
} icon: {
primaryContentCategory.selectedImage
}
} else {
primaryContentCategory.listLabel
}
}
}

View file

@ -3,29 +3,20 @@ import Models
import SwiftUI
public final class PrimaryContentViewModel: ObservableObject {
let categories: [PrimaryContentCategory]
public enum Action {
case nothing
}
public var subscriptions = Set<AnyCancellable>()
public let performActionSubject = PassthroughSubject<Action, Never>()
let homeFeedViewModel: HomeFeedViewModel
let profileContainerViewModel: ProfileContainerViewModel
public init(
homeFeedViewModel: HomeFeedViewModel,
profileContainerViewModel: ProfileContainerViewModel
) {
self.categories = [
.feed(viewModel: homeFeedViewModel),
.profile(viewModel: profileContainerViewModel)
]
self.homeFeedViewModel = homeFeedViewModel
self.profileContainerViewModel = profileContainerViewModel
}
}
public struct PrimaryContentView: View {
@ObservedObject private var viewModel: PrimaryContentViewModel
@State private var currentTab = 0
public init(viewModel: PrimaryContentViewModel) {
self.viewModel = viewModel
@ -45,27 +36,23 @@ public struct PrimaryContentView: View {
// iphone view container
private var compactView: some View {
TabView(selection: $currentTab) {
ForEach(viewModel.categories.indices, id: \.self) { index in
viewModel.categories[index].destinationView
.tabItem {
TabIcon(isSelected: currentTab == index, primaryContentCategory: viewModel.categories[index])
}
.tag(index)
}
}
.accentColor(.appGrayTextContrast)
HomeFeedView(viewModel: viewModel.homeFeedViewModel)
}
// ipad and mac view container
private var regularView: some View {
NavigationView {
let categories = [
PrimaryContentCategory.feed(viewModel: viewModel.homeFeedViewModel),
PrimaryContentCategory.profile(viewModel: viewModel.profileContainerViewModel)
]
return NavigationView {
// The first column is the sidebar.
PrimaryContentSidebar(categories: viewModel.categories)
PrimaryContentSidebar(categories: categories)
.navigationTitle("Categories")
// Initial Content of second column
if let destinationView = viewModel.categories.first?.destinationView {
if let destinationView = categories.first?.destinationView {
destinationView
} else {
Text("Select a Category")