From 5c81c9e6916611905ef292b331386e9e083a3afa Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Tue, 12 Sep 2023 15:55:11 +0200 Subject: [PATCH] More wip --- IceCubesApp/App/IceCubesApp.swift | 84 ++++++++++--------- .../Sources/DesignSystem/Theme.swift | 4 + .../Notifications/NotificationsListView.swift | 7 -- .../Status/List/StatusesListView.swift | 2 - .../Sources/Status/Row/StatusRowView.swift | 1 - .../Row/Subviews/StatusRowCardView.swift | 2 +- .../Row/Subviews/StatusRowContextMenu.swift | 1 - .../Subviews/StatusRowMediaPreviewView.swift | 2 +- .../Sources/Timeline/TimelineView.swift | 2 - 9 files changed, 50 insertions(+), 55 deletions(-) diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 56a54d61..d8c7c1f0 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -156,49 +156,53 @@ struct IceCubesApp: App { } private var tabBarView: some View { - TabView(selection: .init(get: { - selectedTab - }, set: { newTab in - if newTab == selectedTab { - /// Stupid hack to trigger onChange binding in tab views. - popToRootTab = .other - DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { - popToRootTab = selectedTab - } - } - - HapticManager.shared.fireHaptic(of: .tabSelection) - SoundEffectManager.shared.playSound(of: .tabSelection) - - selectedTab = newTab - - DispatchQueue.main.async { - if selectedTab == .notifications, - let token = appAccountsManager.currentAccount.oauthToken - { - userPreferences.setNotification(count: 0, token: token) - watcher.unreadNotificationsCount = 0 - } - } - - })) { - ForEach(availableTabs) { tab in - tab.makeContentView(popToRootTab: $popToRootTab) - .tabItem { - if userPreferences.showiPhoneTabLabel { - tab.label - .labelStyle(TitleAndIconLabelStyle()) - } else { - tab.label - .labelStyle(IconOnlyLabelStyle()) - } + HStack(spacing: 0) { + TabView(selection: .init(get: { + selectedTab + }, set: { newTab in + if newTab == selectedTab { + /// Stupid hack to trigger onChange binding in tab views. + popToRootTab = .other + DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { + popToRootTab = selectedTab } - .tag(tab) - .badge(badgeFor(tab: tab)) - .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .tabBar) + } + + HapticManager.shared.fireHaptic(of: .tabSelection) + SoundEffectManager.shared.playSound(of: .tabSelection) + + selectedTab = newTab + + DispatchQueue.main.async { + if selectedTab == .notifications, + let token = appAccountsManager.currentAccount.oauthToken + { + userPreferences.setNotification(count: 0, token: token) + watcher.unreadNotificationsCount = 0 + } + } + + })) { + ForEach(availableTabs) { tab in + tab.makeContentView(popToRootTab: $popToRootTab) + .tabItem { + if userPreferences.showiPhoneTabLabel { + tab.label + .labelStyle(TitleAndIconLabelStyle()) + } else { + tab.label + .labelStyle(IconOnlyLabelStyle()) + } + } + .tag(tab) + .badge(badgeFor(tab: tab)) + .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .tabBar) + } } + .id(appAccountsManager.currentClient.id) + Divider().edgesIgnoringSafeArea(.all) + notificationsSecondaryColumn } - .id(appAccountsManager.currentClient.id) } private func setNewClientsInEnv(client: Client) { diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index cb7458cf..036ad72f 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -169,6 +169,10 @@ public class Theme: ObservableObject { self?.setColor(withName: colorSetName) } .store(in: &cancellables) + + #if os(visionOS) + selectedSet = .iceCubeDark + #endif } public static var allColorSet: [ColorSet] { diff --git a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift index e6ecf75e..6e5716c8 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift @@ -72,7 +72,6 @@ public struct NotificationsListView: View { } .navigationBarTitleDisplayMode(.inline) .scrollContentBackground(.hidden) - .background(theme.primaryBackgroundColor) .task { viewModel.client = client viewModel.currentAccount = account @@ -119,7 +118,6 @@ public struct NotificationsListView: View { leading: .layoutPadding + 4, bottom: 12, trailing: .layoutPadding)) - .listRowBackground(theme.primaryBackgroundColor) .redacted(reason: .placeholder) } @@ -128,7 +126,6 @@ public struct NotificationsListView: View { EmptyView(iconName: "bell.slash", title: "notifications.empty.title", message: "notifications.empty.message") - .listRowBackground(theme.primaryBackgroundColor) .listSectionSeparator(.hidden) } else { ForEach(notifications) { notification in @@ -140,8 +137,6 @@ public struct NotificationsListView: View { leading: .layoutPadding + 4, bottom: 12, trailing: .layoutPadding)) - .listRowBackground(notification.type == .mention && lockedType != .mention ? - theme.secondaryBackgroundColor : theme.primaryBackgroundColor) .id(notification.id) } } @@ -169,7 +164,6 @@ public struct NotificationsListView: View { await viewModel.fetchNotifications() } } - .listRowBackground(theme.primaryBackgroundColor) .listSectionSeparator(.hidden) } } @@ -184,7 +178,6 @@ public struct NotificationsListView: View { leading: .layoutPadding + 4, bottom: .layoutPadding, trailing: .layoutPadding)) - .listRowBackground(theme.primaryBackgroundColor) } private var topPaddingView: some View { diff --git a/Packages/Status/Sources/Status/List/StatusesListView.swift b/Packages/Status/Sources/Status/List/StatusesListView.swift index 9eebdb4a..7b47e35e 100644 --- a/Packages/Status/Sources/Status/List/StatusesListView.swift +++ b/Packages/Status/Sources/Status/List/StatusesListView.swift @@ -41,7 +41,6 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { await fetcher.fetchNewestStatuses() } } - .listRowBackground(theme.primaryBackgroundColor) .listRowSeparator(.hidden) case let .display(statuses, nextPageState): @@ -83,6 +82,5 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { Spacer() } .padding(.horizontal, .layoutPadding) - .listRowBackground(theme.primaryBackgroundColor) } } diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index 940cbc34..17d4e142 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -117,7 +117,6 @@ public struct StatusRowView: View { StatusRowSwipeView(viewModel: viewModel, mode: .leading) } } - .listRowBackground(viewModel.highlightRowColor) .listRowInsets(.init(top: 12, leading: .layoutPadding, bottom: 12, diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift index 68979f74..7c465657 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift @@ -91,7 +91,7 @@ public struct StatusRowCardView: View { } .frame(maxWidth: maxWidth) .fixedSize(horizontal: false, vertical: true) - .background(theme.secondaryBackgroundColor) + .background(.ultraThinMaterial) .cornerRadius(16) .overlay( RoundedRectangle(cornerRadius: 16) diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift index f929ec4d..bbdb1bd8 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift @@ -94,7 +94,6 @@ struct StatusRowContextMenu: View { .environmentObject(viewModel.client) .preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light) .foregroundColor(Theme.shared.labelColor) - .background(Theme.shared.primaryBackgroundColor) .frame(width: sceneDelegate.windowWidth - 12) .tint(Theme.shared.tintColor) let renderer = ImageRenderer(content: view) diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift index eb2565c8..183c6cfd 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift @@ -25,7 +25,7 @@ public struct StatusRowMediaPreviewView: View { @State private var isHidingMedia: Bool = false var availableWidth: CGFloat { - return sceneDelegate.windowWidth + return sceneDelegate.windowWidth * 0.50 } var appLayoutWidth: CGFloat { diff --git a/Packages/Timeline/Sources/Timeline/TimelineView.swift b/Packages/Timeline/Sources/Timeline/TimelineView.swift index 9f1023f8..8b5012cd 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineView.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineView.swift @@ -57,7 +57,6 @@ public struct TimelineView: View { .environment(\.defaultMinListRowHeight, 1) .listStyle(.plain) .scrollContentBackground(.hidden) - .background(theme.primaryBackgroundColor) .introspect(.list, on: .iOS(.v16, .v17)) { (collectionView: UICollectionView) in DispatchQueue.main.async { self.collectionView = collectionView @@ -257,7 +256,6 @@ public struct TimelineView: View { private var scrollToTopView: some View { HStack { EmptyView() } - .listRowBackground(theme.primaryBackgroundColor) .listRowSeparator(.hidden) .listRowInsets(.init()) .frame(height: .layoutPadding)