Skip to content

Commit 278b27a

Browse files
authored
Add FXIOS-13525 - [Minimal Address Bar] - Animate minimal address bar to full size on tap (#29386)
Animate address bar to full size on tap.
1 parent b99c194 commit 278b27a

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ class BrowserViewController: UIViewController,
862862

863863
if let tab = tabManager.selectedTab, !tab.isFindInPageMode {
864864
// Re-show toolbar which might have been hidden during scrolling (prior to app moving into the background)
865-
scrollController.showToolbars(animated: false)
865+
if !isMinimalAddressBarEnabled { scrollController.showToolbars(animated: false) }
866866
}
867867
navigationHandler?.showTermsOfUse(context: .appBecameActive)
868868
browserDidBecomeActive()

firefox-ios/Client/Frontend/Browser/TabScrollController/LegacyTabScrollController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,21 @@ final class LegacyTabScrollController: NSObject,
266266
func configureToolbarViews(overKeyboardContainer: BaseAlphaStackView?,
267267
bottomContainer: BaseAlphaStackView?,
268268
headerContainer: BaseAlphaStackView?) {
269+
let tapHandler = createToolbarTapHandler()
270+
overKeyboardContainer?.onTap = tapHandler
271+
headerContainer?.onTap = tapHandler
269272
self.overKeyboardContainer = overKeyboardContainer
270273
self.bottomContainer = bottomContainer
271274
self.headerContainer = headerContainer
272275
}
273276

277+
private func createToolbarTapHandler() -> (() -> Void) {
278+
return { [unowned self] in
279+
guard isMinimalAddressBarEnabled && toolbarState == .collapsed else { return }
280+
showToolbars(animated: true)
281+
}
282+
}
283+
274284
@MainActor
275285
private func handleOnTabContentLoading() {
276286
if tabIsLoading() || (tab?.isFxHomeTab ?? false) {

firefox-ios/Client/Frontend/Components/BaseAlphaStackView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class BaseAlphaStackView: UIStackView, AlphaDimmable, ThemeApplicable {
1414
var isClearBackground = false
1515
var isSpacerClearBackground = false
1616
lazy var toolbarHelper: ToolbarHelperInterface = ToolbarHelper()
17+
var onTap: (() -> Void)?
1718

1819
private var isToolbarRefactorEnabled: Bool {
1920
return FxNimbus.shared.features.toolbarRefactorFeature.value().enabled
@@ -27,6 +28,7 @@ class BaseAlphaStackView: UIStackView, AlphaDimmable, ThemeApplicable {
2728
super.init(frame: frame)
2829

2930
setupStyle()
31+
setupTapGesture()
3032
}
3133

3234
required init(coder: NSCoder) {
@@ -46,6 +48,16 @@ class BaseAlphaStackView: UIStackView, AlphaDimmable, ThemeApplicable {
4648
alignment = .fill
4749
}
4850

51+
private func setupTapGesture() {
52+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap))
53+
addGestureRecognizer(tapGesture)
54+
}
55+
56+
@objc
57+
private func handleTap() {
58+
onTap?()
59+
}
60+
4961
// MARK: - Spacer view
5062

5163
private var keyboardSpacerHeight: NSLayoutConstraint?

firefox-ios/firefox-ios-tests/Tests/ClientTests/Frontend/Browser/LegacyTabScrollControllerTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,26 @@ final class LegacyTabScrollControllerTests: XCTestCase {
300300
XCTAssertEqual(result, .zero)
301301
}
302302

303+
func testToolbarTapHandler_WhenMinimalAddressBarEnabledAndCollapsed_ShowsToolbar() {
304+
let subject = createSubject()
305+
setupTabScroll(with: subject)
306+
307+
subject.toolbarState = .collapsed
308+
overKeyboardContainer.onTap?()
309+
310+
XCTAssertEqual(subject.toolbarState, .visible)
311+
}
312+
313+
func testToolbarTapHandler_WhenToolbarVisible_DoesNothing() {
314+
let subject = createSubject()
315+
setupTabScroll(with: subject)
316+
317+
subject.toolbarState = .visible
318+
overKeyboardContainer.onTap?()
319+
320+
XCTAssertEqual(subject.toolbarState, .visible)
321+
}
322+
303323
// MARK: - Setup
304324
private func setupTabScroll(with subject: LegacyTabScrollController) {
305325
tab.createWebview(configuration: .init())

0 commit comments

Comments
 (0)