mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-23 00:40:59 +00:00
Add secondary column when screen is wide enough
This commit is contained in:
parent
243cbcbc41
commit
497c2a1fe1
5 changed files with 57 additions and 42 deletions
|
@ -94,22 +94,32 @@ struct IceCubesApp: App {
|
|||
popToRootTab: $popToRootTab,
|
||||
tabs: availableTabs,
|
||||
routerPath: sidebarRouterPath) {
|
||||
ZStack {
|
||||
if selectedTab == .profile {
|
||||
ProfileTab(popToRootTab: $popToRootTab)
|
||||
}
|
||||
ForEach(availableTabs) { tab in
|
||||
if tab == selectedTab || sideBarLoadedTabs.contains(tab) {
|
||||
tab
|
||||
.makeContentView(popToRootTab: $popToRootTab)
|
||||
.opacity(tab == selectedTab ? 1 : 0)
|
||||
.transition(.opacity)
|
||||
.id("\(tab)\(appAccountsManager.currentAccount.id)")
|
||||
.onAppear {
|
||||
sideBarLoadedTabs.insert(tab)
|
||||
GeometryReader { proxy in
|
||||
HStack(spacing: 0) {
|
||||
ZStack {
|
||||
if selectedTab == .profile {
|
||||
ProfileTab(popToRootTab: $popToRootTab)
|
||||
}
|
||||
ForEach(availableTabs) { tab in
|
||||
if tab == selectedTab || sideBarLoadedTabs.contains(tab) {
|
||||
tab
|
||||
.makeContentView(popToRootTab: $popToRootTab)
|
||||
.opacity(tab == selectedTab ? 1 : 0)
|
||||
.transition(.opacity)
|
||||
.id("\(tab)\(appAccountsManager.currentAccount.id)")
|
||||
.onAppear {
|
||||
sideBarLoadedTabs.insert(tab)
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
if proxy.frame(in: .global).width > (.maxColumnWidth + .secondaryColumnWidth),
|
||||
currentAccount.account?.id != nil {
|
||||
Divider().edgesIgnoringSafeArea(.all)
|
||||
NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil, isSecondaryColumn: true)
|
||||
.frame(maxWidth: 360)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct NotificationsTab: View {
|
|||
@Binding var popToRootTab: Tab
|
||||
|
||||
let lockedType: Models.Notification.NotificationType?
|
||||
let isSecondaryColumn: Bool
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
|
@ -25,11 +26,13 @@ struct NotificationsTab: View {
|
|||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: userPreferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
if !isSecondaryColumn {
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: userPreferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
case .federated:
|
||||
TimelineTab(popToRootTab: popToRootTab, timeline: .federated)
|
||||
case .notifications:
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: nil)
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: nil, isSecondaryColumn: false)
|
||||
case .mentions:
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: .mention)
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: .mention, isSecondaryColumn: false)
|
||||
case .explore:
|
||||
ExploreTab(popToRootTab: popToRootTab)
|
||||
case .messages:
|
||||
|
|
|
@ -5,6 +5,7 @@ public extension CGFloat {
|
|||
static let dividerPadding: CGFloat = 2
|
||||
static let statusColumnsSpacing: CGFloat = 8
|
||||
static let maxColumnWidth: CGFloat = 650
|
||||
static let secondaryColumnWidth: CGFloat = 360
|
||||
static let sidebarWidth: CGFloat = 80
|
||||
static let pollBarHeight: CGFloat = 30
|
||||
}
|
||||
|
|
|
@ -319,6 +319,7 @@ public struct StatusRowView: View {
|
|||
Text("status.action.translate")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
}
|
||||
|
||||
if let translation = viewModel.translation, !viewModel.isLoadingTranslation {
|
||||
|
|
Loading…
Reference in a new issue