From c9e542a2edc5903c8b18133ea5ee39c66c4c64f8 Mon Sep 17 00:00:00 2001 From: Alex Grebenyuk Date: Tue, 21 Feb 2023 01:03:24 -0500 Subject: [PATCH] Fix crash when opening account details (#972) close #918 --- .../Sources/Account/AccountDetailView.swift | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 1987f38a..8b43afd7 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -40,15 +40,13 @@ public struct AccountDetailView: View { public var body: some View { ScrollViewReader { proxy in List { - Group { - makeHeaderView(proxy: proxy) - .padding(.bottom, -20) - familiarFollowers - featuredTagsView - } - .listRowInsets(.init()) - .listRowSeparator(.hidden) - .listRowBackground(theme.primaryBackgroundColor) + makeHeaderView(proxy: proxy) + .applyAccountDetailsRowStyle(theme: theme) + .padding(.bottom, -20) + familiarFollowers + .applyAccountDetailsRowStyle(theme: theme) + featuredTagsView + .applyAccountDetailsRowStyle(theme: theme) Picker("", selection: $viewModel.selectedTab) { ForEach(isCurrentUser ? AccountDetailViewModel.Tab.currentAccountTabs : AccountDetailViewModel.Tab.accountTabs, @@ -59,9 +57,7 @@ public struct AccountDetailView: View { } .pickerStyle(.segmented) .padding(.layoutPadding) - .listRowSeparator(.hidden) - .listRowBackground(theme.primaryBackgroundColor) - .listRowInsets(.init()) + .applyAccountDetailsRowStyle(theme: theme) .id("status") switch viewModel.tabState { @@ -487,6 +483,15 @@ public struct AccountDetailView: View { } } +private extension View { + func applyAccountDetailsRowStyle(theme: Theme) -> some View { + self + .listRowInsets(.init()) + .listRowSeparator(.hidden) + .listRowBackground(theme.primaryBackgroundColor) + } +} + struct AccountDetailView_Previews: PreviewProvider { static var previews: some View { AccountDetailView(account: .placeholder())