1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-12 01:16:46 +01:00
metatext-app-ios-iphone-ipad/macOS/View Models/SidebarNavigationViewModel.swift
2020-08-17 23:50:45 -07:00

55 lines
1.5 KiB
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
import Combine
class SidebarNavigationViewModel: ObservableObject {
@Published private(set) var identity: Identity
@Published private(set) var timelineViewModel: StatusesViewModel
@Published var alertItem: AlertItem?
var selectedTab: Tab? = .timelines
private let identityService: IdentityService
private var cancellables = Set<AnyCancellable>()
init(identityService: IdentityService) {
self.identityService = identityService
identity = identityService.identity
timelineViewModel = StatusesViewModel(statusListService: identityService.service(timeline: .home))
identityService.$identity.dropFirst().assign(to: &$identity)
}
}
extension SidebarNavigationViewModel {
enum Tab: CaseIterable {
case timelines
case search
case notifications
case messages
}
}
extension SidebarNavigationViewModel.Tab {
var title: String {
switch self {
case .timelines: return "Timelines"
case .search: return "Search"
case .notifications: return "Notifications"
case .messages: return "Messages"
}
}
var systemImageName: String {
switch self {
case .timelines: return "newspaper"
case .search: return "magnifyingglass"
case .notifications: return "bell"
case .messages: return "envelope"
}
}
}
extension SidebarNavigationViewModel.Tab: Identifiable {
var id: Self { self }
}