From 5c9122a72c0e43686e09439cf26093933a42c60a Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 12 Mar 2023 12:01:38 +0100 Subject: [PATCH] Accounts selector: Add correct initial height --- .../Sources/AppAccount/AppAccountsSelectorView.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift index be429d4f..e65c3fb7 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift @@ -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() }