2022-12-27 09:25:26 +01:00
|
|
|
import Account
|
|
|
|
import Explore
|
2023-01-17 11:36:01 +01:00
|
|
|
import Foundation
|
|
|
|
import Status
|
2022-12-27 09:25:26 +01:00
|
|
|
import SwiftUI
|
|
|
|
|
2023-01-04 12:50:57 +01:00
|
|
|
enum Tab: Int, Identifiable, Hashable {
|
2023-01-19 07:24:24 +01:00
|
|
|
case timeline, notifications, mentions, explore, messages, settings, other
|
2023-01-16 14:40:23 +01:00
|
|
|
case trending, federated, local
|
|
|
|
case profile
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2022-12-27 09:25:26 +01:00
|
|
|
var id: Int {
|
|
|
|
rawValue
|
|
|
|
}
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2022-12-27 09:25:26 +01:00
|
|
|
static func loggedOutTab() -> [Tab] {
|
|
|
|
[.timeline, .settings]
|
|
|
|
}
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2022-12-27 09:25:26 +01:00
|
|
|
static func loggedInTabs() -> [Tab] {
|
2023-01-16 14:40:23 +01:00
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
2023-01-19 07:24:24 +01:00
|
|
|
return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings]
|
2023-01-16 14:40:23 +01:00
|
|
|
} else {
|
2023-01-26 07:34:29 +01:00
|
|
|
return [.timeline, .notifications, .explore, .messages, .profile]
|
2023-01-16 14:40:23 +01:00
|
|
|
}
|
2022-12-27 09:25:26 +01:00
|
|
|
}
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2022-12-27 09:25:26 +01:00
|
|
|
@ViewBuilder
|
|
|
|
func makeContentView(popToRootTab: Binding<Tab>) -> some View {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .trending:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .trending)
|
|
|
|
case .local:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .local)
|
|
|
|
case .federated:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .federated)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .notifications:
|
2023-01-19 07:24:24 +01:00
|
|
|
NotificationsTab(popToRootTab: popToRootTab, lockedType: nil)
|
|
|
|
case .mentions:
|
|
|
|
NotificationsTab(popToRootTab: popToRootTab, lockedType: .mention)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .explore:
|
|
|
|
ExploreTab(popToRootTab: popToRootTab)
|
2023-01-05 12:21:54 +01:00
|
|
|
case .messages:
|
|
|
|
MessagesTab(popToRootTab: popToRootTab)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .settings:
|
2023-01-10 06:58:50 +01:00
|
|
|
SettingsTabs(popToRootTab: popToRootTab)
|
2023-01-26 07:34:29 +01:00
|
|
|
case .profile:
|
|
|
|
ProfileTab(popToRootTab: popToRootTab)
|
|
|
|
case .other:
|
2022-12-27 09:25:26 +01:00
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2022-12-27 09:25:26 +01:00
|
|
|
@ViewBuilder
|
|
|
|
var label: some View {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.timeline", systemImage: iconName)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .trending:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.trending", systemImage: iconName)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .local:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.local", systemImage: iconName)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .federated:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.federated", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .notifications:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.notifications", systemImage: iconName)
|
2023-01-19 07:24:24 +01:00
|
|
|
case .mentions:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.notifications", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .explore:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.explore", systemImage: iconName)
|
2023-01-05 12:21:54 +01:00
|
|
|
case .messages:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.messages", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .settings:
|
2023-01-19 18:14:08 +01:00
|
|
|
Label("tab.settings", systemImage: iconName)
|
2023-01-26 07:34:29 +01:00
|
|
|
case .profile:
|
|
|
|
Label("tab.profile", systemImage: iconName)
|
|
|
|
case .other:
|
2022-12-27 09:25:26 +01:00
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
2023-01-17 11:36:01 +01:00
|
|
|
|
2023-01-16 14:40:23 +01:00
|
|
|
var iconName: String {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
2023-01-29 15:08:41 +01:00
|
|
|
return "rectangle.stack"
|
2023-01-16 14:40:23 +01:00
|
|
|
case .trending:
|
|
|
|
return "chart.line.uptrend.xyaxis"
|
|
|
|
case .local:
|
|
|
|
return "person.2"
|
|
|
|
case .federated:
|
|
|
|
return "globe.americas"
|
|
|
|
case .notifications:
|
|
|
|
return "bell"
|
2023-01-19 07:24:24 +01:00
|
|
|
case .mentions:
|
|
|
|
return "at"
|
2023-01-16 14:40:23 +01:00
|
|
|
case .explore:
|
|
|
|
return "magnifyingglass"
|
|
|
|
case .messages:
|
|
|
|
return "tray"
|
|
|
|
case .settings:
|
|
|
|
return "gear"
|
2023-01-26 07:34:29 +01:00
|
|
|
case .profile:
|
|
|
|
return "person.crop.circle"
|
|
|
|
case .other:
|
2023-01-16 14:40:23 +01:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2022-12-27 09:25:26 +01:00
|
|
|
}
|