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
}
.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 {

View file

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