Fix scrambled screen when searchinfg (#2191)

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Mauro
2023-11-30 18:47:44 +01:00
committed by GitHub
parent edbac5fe85
commit b7ecb07d2f
3 changed files with 37 additions and 28 deletions
@@ -33,33 +33,35 @@ struct InviteUsersScreen: View {
.searchableConfiguration(hidesNavigationBar: false) .searchableConfiguration(hidesNavigationBar: false)
.compoundSearchField() .compoundSearchField()
.alert(item: $context.alertInfo) .alert(item: $context.alertInfo)
.readFrame($frame)
} }
// MARK: - Private // MARK: - Private
private var mainContent: some View { private var mainContent: some View {
Form { GeometryReader { proxy in
// this is a fix for having the carousel not clipped, and inside the form, so when the search is dismissed, it wont break the design Form {
Section { // this is a fix for having the carousel not clipped, and inside the form, so when the search is dismissed, it wont break the design
EmptyView() Section {
} header: { EmptyView()
VStack(spacing: 8) { } header: {
selectedUsersSection VStack(spacing: 8) {
.textCase(.none) selectedUsersSection
.textCase(.none)
if context.viewState.isSearching { .frame(width: proxy.size.width)
ProgressView()
.frame(maxWidth: .infinity, alignment: .center) if context.viewState.isSearching {
.listRowBackground(Color.clear) ProgressView()
.frame(maxWidth: .infinity, alignment: .center)
.listRowBackground(Color.clear)
}
} }
} }
}
if context.viewState.hasEmptySearchResults {
if context.viewState.hasEmptySearchResults { noResultsContent
noResultsContent } else {
} else { usersSection
usersSection }
} }
} }
} }
@@ -97,7 +99,6 @@ struct InviteUsersScreen: View {
} }
} }
@State private var frame: CGRect = .zero
@ScaledMetric private var cellWidth: CGFloat = 72 @ScaledMetric private var cellWidth: CGFloat = 72
private var selectedUsersSection: some View { private var selectedUsersSection: some View {
@@ -120,7 +121,6 @@ struct InviteUsersScreen: View {
.padding(.horizontal, 14) .padding(.horizontal, 14)
} }
} }
.frame(width: frame.width)
} }
@ToolbarContentBuilder @ToolbarContentBuilder
@@ -28,13 +28,15 @@ struct MessageForwardingScreen: View {
} }
// Replace these with ScrollView's `scrollPosition` when dropping iOS 16. // Replace these with ScrollView's `scrollPosition` when dropping iOS 16.
} header: { } header: {
Rectangle().hidden().onAppear { emptyRectangle
context.send(viewAction: .reachedTop) .onAppear {
} context.send(viewAction: .reachedTop)
}
} footer: { } footer: {
Rectangle().hidden().onAppear { emptyRectangle
context.send(viewAction: .reachedBottom) .onAppear {
} context.send(viewAction: .reachedBottom)
}
} }
.compoundFormSection() .compoundFormSection()
} }
@@ -59,6 +61,12 @@ struct MessageForwardingScreen: View {
.compoundSearchField() .compoundSearchField()
.disableAutocorrection(true) .disableAutocorrection(true)
} }
/// The greedy size of Rectangle can create an issue with the navigation bar when the search is highlighted, so is best to use a fixed frame instead of hidden() or EmptyView()
private var emptyRectangle: some View {
Rectangle()
.frame(width: 0, height: 0)
}
} }
private struct MessageForwardingRoomCell: View { private struct MessageForwardingRoomCell: View {
@@ -37,6 +37,7 @@ struct StartChatScreen: View {
.disableInteractiveDismissOnSearch() .disableInteractiveDismissOnSearch()
.dismissSearchOnDisappear() .dismissSearchOnDisappear()
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: L10n.commonSearchForSomeone) .searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: L10n.commonSearchForSomeone)
.searchableConfiguration(hidesNavigationBar: false)
.compoundSearchField() .compoundSearchField()
.alert(item: $context.alertInfo) .alert(item: $context.alertInfo)
} }