Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LMN-1700] Fix the keyboard dismisses automatically while typing in App Search Modal #2064

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct AppSearchModalContentView: View {
var body: some View {

ObservableScrollView { point in
if point != .zero {
if !CGPoint.compare(point, .zero, decimalPlaces: 5) {
onScroll(point)
}
} content: {
Expand Down Expand Up @@ -148,3 +148,27 @@ struct AppSearchModalContentView_Previews: PreviewProvider {
return .init(text: "Shortcut \(index + 1)", icon: .landmark, onShortcutSelected: { })
}
}

private extension CGFloat {
// Function to round a CGFloat to a specified number of decimal places
func roundToDecimal(places: Int) -> CGFloat {
let divisor = pow(10.0, CGFloat(places))
return (self * divisor).rounded() / divisor
}
}

private extension CGPoint {
// Function to round a CGPoint to a certain number of decimal places
func roundToDecimal(_ point: CGPoint, decimalPlaces: Int) -> CGPoint {
let roundedX = point.x.roundToDecimal(places: decimalPlaces)
let roundedY = point.y.roundToDecimal(places: decimalPlaces)
return CGPoint(x: roundedX, y: roundedY)
}

// Function to compare two CGPoint values with precision
static func compare(_ lhs: CGPoint, _ rhs: CGPoint, decimalPlaces: Int) -> Bool {
let roundedPoint1 = lhs.roundToDecimal(lhs, decimalPlaces: decimalPlaces)
let roundedPoint2 = rhs.roundToDecimal(rhs, decimalPlaces: decimalPlaces)
return roundedPoint1 == roundedPoint2
}
}
Loading