From 356b58bf6741efaf20e3cc260ff664f6a5af545b Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 24 Mar 2023 13:53:42 +0100 Subject: [PATCH] Use the new iOS 16.4 sheet background for app selection sheet (You'll need to use Xcode 14.3 going forward) --- .../AppAccount/AppAccountsSelectorView.swift | 27 +++++++++++++++---- .../DesignSystem/Views/AvatarView.swift | 1 - 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift index 342945b9..cf7b5483 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift @@ -47,10 +47,19 @@ public struct AppAccountsSelectorView: View { labelView } .sheet(isPresented: $isPresented, content: { - accountsView.presentationDetents([.height(preferredHeight), .large]) - .onAppear { - refreshAccounts() - } + if #available(iOS 16.4, *) { + accountsView.presentationDetents([.height(preferredHeight), .large]) + .presentationBackground(.thinMaterial) + .presentationCornerRadius(16) + .onAppear { + refreshAccounts() + } + } else { + accountsView.presentationDetents([.height(preferredHeight), .large]) + .onAppear { + refreshAccounts() + } + } }) .onChange(of: currentAccount.account?.id) { _ in refreshAccounts() @@ -80,6 +89,14 @@ public struct AppAccountsSelectorView: View { .accessibilityHint("accessibility.app-account.selector.accounts.hint") } + private var accountBackgroundColor: Color { + if #available(iOS 16.4, *) { + return Color.clear + } else { + return theme.secondaryBackgroundColor + } + } + private var accountsView: some View { NavigationStack { List { @@ -108,7 +125,7 @@ public struct AppAccountsSelectorView: View { } .listStyle(.insetGrouped) .scrollContentBackground(.hidden) - .background(theme.secondaryBackgroundColor) + .background(accountBackgroundColor) .navigationTitle("settings.section.accounts") .navigationBarTitleDisplayMode(.inline) .toolbar { diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift index 53fdbb6b..82c79319 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift @@ -64,7 +64,6 @@ public struct AvatarView: View { AvatarPlaceholderView(size: size) } } - .animation(nil) .frame(width: size.size.width, height: size.size.height) } }