add animation, remove vstack

This commit is contained in:
Evgeny Poberezkin 2024-07-01 00:07:00 +01:00
parent 62cc26c873
commit aa9d9ad2a1

View file

@ -110,7 +110,6 @@ struct ChatListView<ToolbarContent: View>: View {
}
if !chatModel.chats.isEmpty && searchVisible {
VStack {
ChatListSearchBar(
searchMode: $searchMode,
searchFocussed: $searchFocussed,
@ -122,7 +121,7 @@ struct ChatListView<ToolbarContent: View>: View {
.listRowSeparator(.hidden)
.frame(maxWidth: .infinity)
.padding(10)
}
.transition(.move(edge: .top))
}
}
.background(.bar)
@ -139,10 +138,12 @@ struct ChatListView<ToolbarContent: View>: View {
if frame.maxY <= screenHeight && frame.maxY > screenHeight - frame.height / 2 {
if topVisibleRowIndex != index {
if let topVisibleRowIndex = topVisibleRowIndex {
searchVisible = topVisibleRowIndex > index || index == 0
withAnimation {
searchVisible = if let topVisibleRowIndex {
topVisibleRowIndex > index || index == 0
} else {
searchVisible = true
true
}
}
topVisibleRowIndex = index
@ -151,10 +152,12 @@ struct ChatListView<ToolbarContent: View>: View {
} else {
if frame.minY >= 0 && frame.minY < frame.height / 2 {
if topVisibleRowIndex != index {
if let topVisibleRowIndex = topVisibleRowIndex {
searchVisible = topVisibleRowIndex > index
withAnimation {
searchVisible = if let topVisibleRowIndex {
topVisibleRowIndex > index
} else {
searchVisible = true
true
}
}
topVisibleRowIndex = index