Switch to iOS 17 inspector

This commit is contained in:
Thomas Ricouard 2023-09-20 21:19:31 +02:00
parent 15f498037d
commit 7589ab75f8
3 changed files with 34 additions and 32 deletions

View file

@ -113,36 +113,34 @@ struct IceCubesApp: App {
popToRootTab: $popToRootTab, popToRootTab: $popToRootTab,
tabs: availableTabs) tabs: availableTabs)
{ {
GeometryReader { _ in ZStack {
HStack(spacing: 0) { if selectedTab == .profile {
ZStack { ProfileTab(popToRootTab: $popToRootTab)
if selectedTab == .profile { }
ProfileTab(popToRootTab: $popToRootTab) ForEach(availableTabs) { tab in
} if tab == selectedTab || sideBarLoadedTabs.contains(tab) {
ForEach(availableTabs) { tab in tab
if tab == selectedTab || sideBarLoadedTabs.contains(tab) { .makeContentView(popToRootTab: $popToRootTab)
tab .opacity(tab == selectedTab ? 1 : 0)
.makeContentView(popToRootTab: $popToRootTab) .transition(.opacity)
.opacity(tab == selectedTab ? 1 : 0) .id("\(tab)\(appAccountsManager.currentAccount.id)")
.transition(.opacity) .onAppear {
.id("\(tab)\(appAccountsManager.currentAccount.id)") sideBarLoadedTabs.insert(tab)
.onAppear {
sideBarLoadedTabs.insert(tab)
}
} else {
EmptyView()
} }
} } else {
} EmptyView()
if appAccountsManager.currentClient.isAuth,
userPreferences.showiPadSecondaryColumn
{
Divider().edgesIgnoringSafeArea(.all)
notificationsSecondaryColumn
} }
} }
} }
}.onChange(of: $appAccountsManager.currentAccount.id) { }
.inspector(isPresented: .init(get: {
appAccountsManager.currentClient.isAuth && userPreferences.showiPadSecondaryColumn
}, set: { newValue in
userPreferences.showiPadSecondaryColumn = newValue
}), content: {
notificationsSecondaryColumn
})
.onChange(of: $appAccountsManager.currentAccount.id) {
sideBarLoadedTabs.removeAll() sideBarLoadedTabs.removeAll()
} }
.environment(sidebarRouterPath) .environment(sidebarRouterPath)
@ -151,8 +149,8 @@ struct IceCubesApp: App {
private var notificationsSecondaryColumn: some View { private var notificationsSecondaryColumn: some View {
NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil) NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil)
.environment(\.isSecondaryColumn, true) .environment(\.isSecondaryColumn, true)
.frame(maxWidth: .secondaryColumnWidth)
.id(appAccountsManager.currentAccount.id) .id(appAccountsManager.currentAccount.id)
.inspectorColumnWidth(.secondaryColumnWidth)
} }
private var tabBarView: some View { private var tabBarView: some View {

View file

@ -75,12 +75,14 @@ public struct NotificationsListView: View {
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
.task { .task {
viewModel.client = client if client.isAuth {
viewModel.currentAccount = account viewModel.client = client
if let lockedType { viewModel.currentAccount = account
viewModel.selectedType = lockedType if let lockedType {
viewModel.selectedType = lockedType
}
await viewModel.fetchNotifications()
} }
await viewModel.fetchNotifications()
} }
.refreshable { .refreshable {
SoundEffectManager.shared.playSound(of: .pull) SoundEffectManager.shared.playSound(of: .pull)

View file

@ -93,6 +93,8 @@ import SwiftUI
nextPageState: consolidatedNotifications.isEmpty ? .none : nextPageState) nextPageState: consolidatedNotifications.isEmpty ? .none : nextPageState)
} }
} catch { } catch {
let error = error as NSError
guard error.code != -999 else { return }
state = .error(error: error) state = .error(error: error)
} }
} }