Use the new iOS 16.4 sheet background for app selection sheet (You'll need to use Xcode 14.3 going forward)

This commit is contained in:
Thomas Ricouard 2023-03-24 13:53:42 +01:00
parent 65431dc727
commit 356b58bf67
2 changed files with 22 additions and 6 deletions

View file

@ -47,10 +47,19 @@ public struct AppAccountsSelectorView: View {
labelView labelView
} }
.sheet(isPresented: $isPresented, content: { .sheet(isPresented: $isPresented, content: {
accountsView.presentationDetents([.height(preferredHeight), .large]) if #available(iOS 16.4, *) {
.onAppear { accountsView.presentationDetents([.height(preferredHeight), .large])
refreshAccounts() .presentationBackground(.thinMaterial)
} .presentationCornerRadius(16)
.onAppear {
refreshAccounts()
}
} else {
accountsView.presentationDetents([.height(preferredHeight), .large])
.onAppear {
refreshAccounts()
}
}
}) })
.onChange(of: currentAccount.account?.id) { _ in .onChange(of: currentAccount.account?.id) { _ in
refreshAccounts() refreshAccounts()
@ -80,6 +89,14 @@ public struct AppAccountsSelectorView: View {
.accessibilityHint("accessibility.app-account.selector.accounts.hint") .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 { private var accountsView: some View {
NavigationStack { NavigationStack {
List { List {
@ -108,7 +125,7 @@ public struct AppAccountsSelectorView: View {
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor) .background(accountBackgroundColor)
.navigationTitle("settings.section.accounts") .navigationTitle("settings.section.accounts")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {

View file

@ -64,7 +64,6 @@ public struct AvatarView: View {
AvatarPlaceholderView(size: size) AvatarPlaceholderView(size: size)
} }
} }
.animation(nil)
.frame(width: size.size.width, height: size.size.height) .frame(width: size.size.width, height: size.size.height)
} }
} }