IceCubesApp/IceCubesApp/App/SideBarView.swift

58 lines
1.7 KiB
Swift
Raw Normal View History

2023-01-16 18:51:05 +00:00
import Account
2023-01-16 20:15:33 +00:00
import AppAccount
2023-01-17 10:36:01 +00:00
import DesignSystem
import Env
import SwiftUI
2023-01-16 18:51:05 +00:00
struct SideBarView<Content: View>: View {
@EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var theme: Theme
2023-01-17 10:36:01 +00:00
2023-01-16 18:51:05 +00:00
@Binding var selectedTab: Tab
@Binding var popToRootTab: Tab
var tabs: [Tab]
2023-01-16 20:15:33 +00:00
@ViewBuilder var content: () -> Content
2023-01-17 10:36:01 +00:00
2023-01-16 18:51:05 +00:00
var body: some View {
HStack(spacing: 0) {
VStack(alignment: .center) {
2023-01-16 20:27:54 +00:00
Button {
selectedTab = .profile
} label: {
AppAccountsSelectorView(routeurPath: RouterPath(),
accountCreationEnabled: false,
avatarSize: .status)
2023-01-16 18:51:05 +00:00
}
2023-01-16 21:01:04 +00:00
.frame(width: 80, height: 60)
2023-01-16 20:27:54 +00:00
.background(selectedTab == .profile ? theme.secondaryBackgroundColor : .clear)
2023-01-16 18:51:05 +00:00
ForEach(tabs) { tab in
Button {
if tab == selectedTab {
popToRootTab = .other
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
popToRootTab = tab
}
}
selectedTab = tab
} label: {
Image(systemName: tab.iconName)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 24, height: 24)
.foregroundColor(tab == selectedTab ? theme.tintColor : .gray)
}
2023-01-16 21:01:04 +00:00
.frame(width: 80, height: 50)
2023-01-16 18:51:05 +00:00
.background(tab == selectedTab ? theme.secondaryBackgroundColor : .clear)
}
Spacer()
}
2023-01-16 21:01:04 +00:00
.frame(width: 80)
2023-01-16 18:51:05 +00:00
.background(.clear)
Divider()
.edgesIgnoringSafeArea(.top)
2023-01-16 20:15:33 +00:00
content()
2023-01-16 18:51:05 +00:00
}
.background(.thinMaterial)
}
}