Hello Everyone,
I would like to build a List with autohiding custom header. This header should autohide similar to search field.
Can some one let me know how can we achieve this with SwiftUI. I've seen Whatsapp it does the job with search field.
https://stackoverflow.com/questions/70198587/how-does-not-hide-the-search-bar-when-scrolling-swiftui
-Janakiram
Post
Replies
Boosts
Views
Activity
We have a requirement for SwiftUI List to show the header only when user scrolls to top. This behaviour should be similar to search control that hides by default and only when the user pulls down then it displays. We would like to show our customView similar to search.
example : .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .automatic))
We need to implement similar functionality ( such as hide list header by default and enable it on scroll ).
Can anyone suggest me a way to achieve this functionality.
Appreciate your response.
Thanks,
Janakiram
In our SwiftUI application , we are using List in one of our screen. We have a requirement to scroll to specific section header.
Below code works fine till iOS16 and from iOS16 onwards we are getting the app crash.
Can anyone suggest me any probable solution to achive this ?.
ScrollViewReader { proxy in
List {
ForEach(Array(viewModel.newSections), id: .self) { sectionName in
Section(header: VStack { LeaguesScheduleListSectionView(text: sectionName) }) {
ForEach(viewModel.newRowsPerSection[sectionName] ?? []) { leagueScheduleEvent in
LeaguesScheduleListRowView(leagueSchedule: leagueScheduleEvent)
}
}
.id(sectionName)
}
}
.listStyle(.plain)
.onAppear(perform: {
if viewModel.newSections.contains("Today/Ongoing"),
viewModel.newRowsPerSection[("Today/Ongoing")]?.count ?? 0 > 0 {
proxy.scrollTo("Today/Ongoing", anchor: UnitPoint.topLeading)
}
})
}