Accounts selector: Add correct initial height

This commit is contained in:
Thomas Ricouard 2023-03-12 12:01:38 +01:00
parent 8b4f6dbd05
commit 5c9122a72c

View file

@ -16,13 +16,19 @@ public struct AppAccountsSelectorView: View {
private let accountCreationEnabled: Bool
private let avatarSize: AvatarView.Size
var showNotificationBadge: Bool {
private var showNotificationBadge: Bool {
accountsViewModel
.filter { $0.account?.id != currentAccount.account?.id }
.compactMap { $0.appAccount.oauthToken }
.map { preferences.getNotificationsCount(for: $0) }
.reduce(0, +) > 0
}
private var preferredHeight: CGFloat {
var baseHeight: CGFloat = 220
baseHeight += CGFloat(60 * accountsViewModel.count)
return baseHeight
}
public init(routerPath: RouterPath,
accountCreationEnabled: Bool = true,
@ -41,7 +47,7 @@ public struct AppAccountsSelectorView: View {
labelView
}
.sheet(isPresented: $isPresented, content: {
accountsView.presentationDetents([.medium, .large])
accountsView.presentationDetents([.height(preferredHeight), .large])
.onAppear {
refreshAccounts()
}