#1098 - Various changes following code review.

This commit is contained in:
Stefan Ceriu
2021-10-07 12:21:40 +03:00
parent 9470a9336f
commit 94459be545
8 changed files with 16 additions and 15 deletions
@@ -51,6 +51,7 @@ struct UserSuggestionList: View {
.listStyle(PlainListStyle())
.environment(\.defaultMinListRowHeight, rowHeight)
.frame(height: min(maxHeight, rowHeight * CGFloat(viewModel.viewState.items.count)))
// .frame(maxHeight: maxHeight)
.id(UUID()) // Rebuild the whole list on item changes. Fixes performance issues.
}
}
@@ -69,7 +70,7 @@ private struct BackgroundView<Content: View>: View {
}
var body: some View {
VStack(content: content)
content()
.background(theme.colors.background)
.clipShape(RoundedCornerShape(radius: shadowRadius, corners: [.topLeft, .topRight]))
.shadow(color: .black.opacity(0.20), radius: 20.0, x: 0.0, y: 3.0)
@@ -36,7 +36,7 @@ struct UserSuggestionListItem: View {
if let avatar = avatar {
AvatarImage(avatarData: avatar, size: .medium)
}
VStack(alignment:.leading) {
VStack(alignment: .leading) {
Text(displayName ?? "")
.font(theme.fonts.body)
.foregroundColor(theme.colors.primaryContent)
@@ -33,20 +33,18 @@ struct UserSuggestionListWithInput: View {
var viewModel: UserSuggestionListWithInputViewModel
@State private var inputText: String = ""
var body: some View {
VStack(spacing: 0.0) {
UserSuggestionList(viewModel: viewModel.listViewModel.context)
TextField("Search for user", text: $inputText)
.background(Color.white)
.onChange(of: inputText, perform: { value in
viewModel.callback(value)
})
.border(Color.black)
.onChange(of: inputText, perform:viewModel.callback)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding([.leading, .trailing])
.onAppear(perform: {
.onAppear {
inputText = "@-" // Make the list show all available mock results
})
}
}
}
}