From e96a312ccf51a1b23ebc80875cbd3ca6166dea2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= Date: Tue, 10 Dec 2024 15:12:57 +0100 Subject: [PATCH 1/3] Prevent sending pixel twice during a single dismiss --- DuckDuckGo/MainViewController.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 2ee59fc07f..25df341d2d 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -515,6 +515,7 @@ class MainViewController: UIViewController { var keyboardShowing = false + private var didSendGestureDismissPixel: Bool = false @objc private func keyboardDidShow() { @@ -523,14 +524,16 @@ class MainViewController: UIViewController { @objc private func keyboardWillHide() { - if newTabPageViewController?.isDragging == true, keyboardShowing { + if !didSendGestureDismissPixel, newTabPageViewController?.isDragging == true, keyboardShowing { Pixel.fire(pixel: .addressBarGestureDismiss) + didSendGestureDismissPixel = true } } @objc private func keyboardDidHide() { keyboardShowing = false + didSendGestureDismissPixel = false } private func registerForPageRefreshPatterns() { From f373c3ff0d56169efa9b51713920b12c2cb9e0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= Date: Tue, 10 Dec 2024 15:14:02 +0100 Subject: [PATCH 2/3] Prevent grid stuttering when dismissing keyboard --- DuckDuckGo/NewTabPageView.swift | 2 ++ DuckDuckGo/SimpleNewTabPageView.swift | 2 ++ 2 files changed, 4 insertions(+) diff --git a/DuckDuckGo/NewTabPageView.swift b/DuckDuckGo/NewTabPageView.swift index 219ddd9c27..1d76cdb1b3 100644 --- a/DuckDuckGo/NewTabPageView.swift +++ b/DuckDuckGo/NewTabPageView.swift @@ -154,6 +154,8 @@ private extension NewTabPageView { EmptyView() } } + // Prevent recreating geomery reader when keyboard is shown/hidden. + .ignoresSafeArea(.keyboard) } @ViewBuilder diff --git a/DuckDuckGo/SimpleNewTabPageView.swift b/DuckDuckGo/SimpleNewTabPageView.swift index a228686ef5..264facee3f 100644 --- a/DuckDuckGo/SimpleNewTabPageView.swift +++ b/DuckDuckGo/SimpleNewTabPageView.swift @@ -85,6 +85,8 @@ private extension SimpleNewTabPageView { } .withScrollKeyboardDismiss() } + // Prevent recreating geomery reader when keyboard is shown/hidden. + .ignoresSafeArea(.keyboard) } @ViewBuilder From 6a0bdcbe34fe398b1ebd9ecde13b06cbd97c119a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= Date: Tue, 10 Dec 2024 15:15:07 +0100 Subject: [PATCH 3/3] Set isDragging when scrolling in both vertical directions --- DuckDuckGo/NewTabPageView.swift | 2 +- DuckDuckGo/SimpleNewTabPageView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/NewTabPageView.swift b/DuckDuckGo/NewTabPageView.swift index 1d76cdb1b3..0add43c1c9 100644 --- a/DuckDuckGo/NewTabPageView.swift +++ b/DuckDuckGo/NewTabPageView.swift @@ -76,7 +76,7 @@ struct NewTabPageView: View { .simultaneousGesture( DragGesture() .onChanged({ value in - if value.translation.height > 0 { + if value.translation.height != 0 { viewModel.beginDragging() } }) diff --git a/DuckDuckGo/SimpleNewTabPageView.swift b/DuckDuckGo/SimpleNewTabPageView.swift index 264facee3f..a4fae0632b 100644 --- a/DuckDuckGo/SimpleNewTabPageView.swift +++ b/DuckDuckGo/SimpleNewTabPageView.swift @@ -49,7 +49,7 @@ struct SimpleNewTabPageView: View { .simultaneousGesture( DragGesture() .onChanged({ value in - if value.translation.height > 0 { + if value.translation.height != 0.0 { viewModel.beginDragging() } })