Skip to content
Snippets Groups Projects
Commit 48e7cda8 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

UI/UX: fix animation in conversation

Change-Id: I471c80d3beb20e4bcb153d6669e4b0cde9c5fdcc
parent 58b4fa7f
Branches
No related tags found
No related merge requests found
...@@ -24,7 +24,6 @@ struct SmartListContentView: View { ...@@ -24,7 +24,6 @@ struct SmartListContentView: View {
@ObservedObject var model: ConversationsViewModel @ObservedObject var model: ConversationsViewModel
let stateEmitter: ConversationStatePublisher let stateEmitter: ConversationStatePublisher
@SwiftUI.State var mode: ConversationsViewModel.Target @SwiftUI.State var mode: ConversationsViewModel.Target
@SwiftUI.State var hideTopView: Bool = true
@ObservedObject var requestsModel: RequestsViewModel @ObservedObject var requestsModel: RequestsViewModel
@Binding var isSearchBarActive: Bool @Binding var isSearchBarActive: Bool
@SwiftUI.State var currentSearchBarStatus: Bool = false @SwiftUI.State var currentSearchBarStatus: Bool = false
...@@ -34,9 +33,7 @@ struct SmartListContentView: View { ...@@ -34,9 +33,7 @@ struct SmartListContentView: View {
let conversationsView = ConversationsView(model: model, stateEmitter: stateEmitter) let conversationsView = ConversationsView(model: model, stateEmitter: stateEmitter)
return ZStack { return ZStack {
Group {
if isSearchBarActive { if isSearchBarActive {
// Use ScrollView instead of List to prevent memory leaks when using a conversation model inside ForEach.
ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
publicDirectorySearchView publicDirectorySearchView
...@@ -50,6 +47,7 @@ struct SmartListContentView: View { ...@@ -50,6 +47,7 @@ struct SmartListContentView: View {
} }
.padding(.horizontal, 15) .padding(.horizontal, 15)
} }
.transition(.opacity)
} else { } else {
ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
...@@ -66,14 +64,11 @@ struct SmartListContentView: View { ...@@ -66,14 +64,11 @@ struct SmartListContentView: View {
} }
.padding(.horizontal, 15) .padding(.horizontal, 15)
} }
.transition(.identity)
.animation(nil, value: isSearchBarActive)
} }
} }
.transition(AnyTransition.asymmetric( .animation(isSearchBarActive ? .easeIn(duration: 0.3) : nil, value: isSearchBarActive)
insertion: .opacity,
removal: .opacity.animation(.easeOut(duration: 0))
))
}
.animation(.easeIn(duration: 0.3), value: isSearchBarActive)
.onAppear { [weak model] in .onAppear { [weak model] in
guard let model = model else { return } guard let model = model else { return }
// If there was an active search before presenting the conversation, the search results should remain the same upon returning to the page. Otherwise, flickering will occur. // If there was an active search before presenting the conversation, the search results should remain the same upon returning to the page. Otherwise, flickering will occur.
...@@ -81,7 +76,6 @@ struct SmartListContentView: View { ...@@ -81,7 +76,6 @@ struct SmartListContentView: View {
isSearchBarActive = true isSearchBarActive = true
model.presentedConversation.resetPresentedConversation() model.presentedConversation.resetPresentedConversation()
} }
hideTopView = false
} }
.listStyle(.plain) .listStyle(.plain)
.hideRowSeparator() .hideRowSeparator()
...@@ -174,6 +168,7 @@ struct SmartListContentView: View { ...@@ -174,6 +168,7 @@ struct SmartListContentView: View {
actionItem(icon: "person.2", title: L10n.Smartlist.newGroup, action: stateEmitter.createSwarm) actionItem(icon: "person.2", title: L10n.Smartlist.newGroup, action: stateEmitter.createSwarm)
} }
.hideRowSeparator() .hideRowSeparator()
.animation(nil, value: isSearchBarActive)
} }
private func actionItem(icon: String, title: String, action: @escaping () -> Void) -> some View { private func actionItem(icon: String, title: String, action: @escaping () -> Void) -> some View {
...@@ -221,18 +216,22 @@ struct SmartListContentView: View { ...@@ -221,18 +216,22 @@ struct SmartListContentView: View {
if !model.isSipAccount() { if !model.isSipAccount() {
newChatOptions newChatOptions
.padding(.vertical, 10) .padding(.vertical, 10)
.animation(nil, value: isSearchBarActive)
} }
if !model.searchQuery.isEmpty { if !model.searchQuery.isEmpty {
Text(model.publicDirectoryTitle) Text(model.publicDirectoryTitle)
.fontWeight(.semibold) .fontWeight(.semibold)
.hideRowSeparator() .hideRowSeparator()
.padding(.top) .padding(.top)
.animation(nil, value: isSearchBarActive)
searchResultView searchResultView
.hideRowSeparator() .hideRowSeparator()
.padding(.bottom) .padding(.bottom)
.padding(.top, 3) .padding(.top, 3)
.animation(nil, value: isSearchBarActive)
if let conversation = model.blockedConversation { if let conversation = model.blockedConversation {
blockedcontactsView(conversation: conversation) blockedcontactsView(conversation: conversation)
.animation(nil, value: isSearchBarActive)
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment