mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
remove tab bar from compact apple views
This commit is contained in:
parent
a2b968f991
commit
da212e8e46
3 changed files with 14 additions and 56 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue