Impressia/Vernissage/Widgets/MainNavigationOptions.swift

129 lines
4.1 KiB
Swift
Raw Normal View History

2023-04-20 15:03:43 +02:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import Foundation
import SwiftUI
2023-10-22 10:09:02 +02:00
import EnvironmentKit
2023-04-20 15:03:43 +02:00
struct MainNavigationOptions: View {
2023-10-22 10:09:02 +02:00
@Environment(ApplicationState.self) var applicationState
2023-04-20 15:03:43 +02:00
let onViewModeIconTap: (MainView.ViewMode) -> Void
2023-04-21 16:58:52 +02:00
@Binding var hiddenMenuItems: [MainView.ViewMode]
init(hiddenMenuItems: Binding<[MainView.ViewMode]>, onViewModeIconTap: @escaping (MainView.ViewMode) -> Void) {
self._hiddenMenuItems = hiddenMenuItems
self.onViewModeIconTap = onViewModeIconTap
}
2023-04-20 15:03:43 +02:00
var body: some View {
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .home }) {
Button {
self.onViewModeIconTap(.home)
} label: {
HStack {
Text(MainView.ViewMode.home.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.home.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .local }) {
Button {
self.onViewModeIconTap(.local)
} label: {
HStack {
Text(MainView.ViewMode.local.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.local.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .federated }) {
Button {
self.onViewModeIconTap(.federated)
} label: {
HStack {
Text(MainView.ViewMode.federated.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.federated.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .search }) {
Button {
self.onViewModeIconTap(.search)
} label: {
HStack {
Text(MainView.ViewMode.search.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.search.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
Divider()
Menu {
Button {
self.onViewModeIconTap(.trendingPhotos)
} label: {
HStack {
Text(MainView.ViewMode.trendingPhotos.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.trendingPhotos.getImage(applicationState: applicationState)
2023-04-20 15:03:43 +02:00
}
}
Button {
self.onViewModeIconTap(.trendingTags)
} label: {
HStack {
Text(MainView.ViewMode.trendingTags.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.trendingTags.getImage(applicationState: applicationState)
2023-04-20 15:03:43 +02:00
}
}
Button {
self.onViewModeIconTap(.trendingAccounts)
} label: {
HStack {
Text(MainView.ViewMode.trendingAccounts.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.trendingAccounts.getImage(applicationState: applicationState)
2023-04-20 15:03:43 +02:00
}
}
} label: {
HStack {
Text("mainview.tab.trending", comment: "Trending menu section")
Image(systemName: "chart.line.uptrend.xyaxis")
}
}
Divider()
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .profile }) {
Button {
self.onViewModeIconTap(.profile)
} label: {
HStack {
Text(MainView.ViewMode.profile.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.profile.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
2023-04-21 16:58:52 +02:00
if !self.hiddenMenuItems.contains(where: { $0 == .notifications }) {
Button {
self.onViewModeIconTap(.notifications)
} label: {
HStack {
Text(MainView.ViewMode.notifications.title)
2023-10-22 10:09:02 +02:00
MainView.ViewMode.notifications.getImage(applicationState: applicationState)
2023-04-21 16:58:52 +02:00
}
2023-04-20 15:03:43 +02:00
}
}
}
}