Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@
8A6B799B2CDBCF3D003C3077 /* TopSitesManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6B79992CDBCE2E003C3077 /* TopSitesManagerTests.swift */; };
8A6B799D2CDBDAE4003C3077 /* MockContileProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6B799C2CDBDAE4003C3077 /* MockContileProvider.swift */; };
8A6B79A02CDBDB0C003C3077 /* MockGoogleTopSiteManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6B799F2CDBDB0C003C3077 /* MockGoogleTopSiteManager.swift */; };
8A6CDB472DF9E78400F11139 /* MockTabDisplayViewDragAndDropInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6CDB462DF9E78400F11139 /* MockTabDisplayViewDragAndDropInteraction.swift */; };
8A6E13982A71BA4E00A88FA8 /* TabWebViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6E13972A71BA4E00A88FA8 /* TabWebViewTests.swift */; };
8A6E63C52D4946760040D355 /* JumpBackInCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6E63C42D49466C0040D355 /* JumpBackInCell.swift */; };
8A6E63C72D4946B90040D355 /* JumpBackInSectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A6E63C62D4946B40040D355 /* JumpBackInSectionState.swift */; };
Expand Down Expand Up @@ -8347,6 +8348,7 @@
8A6B79992CDBCE2E003C3077 /* TopSitesManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSitesManagerTests.swift; sourceTree = "<group>"; };
8A6B799C2CDBDAE4003C3077 /* MockContileProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockContileProvider.swift; sourceTree = "<group>"; };
8A6B799F2CDBDB0C003C3077 /* MockGoogleTopSiteManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockGoogleTopSiteManager.swift; sourceTree = "<group>"; };
8A6CDB462DF9E78400F11139 /* MockTabDisplayViewDragAndDropInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTabDisplayViewDragAndDropInteraction.swift; sourceTree = "<group>"; };
8A6E13972A71BA4E00A88FA8 /* TabWebViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabWebViewTests.swift; sourceTree = "<group>"; };
8A6E63C42D49466C0040D355 /* JumpBackInCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JumpBackInCell.swift; sourceTree = "<group>"; };
8A6E63C62D4946B40040D355 /* JumpBackInSectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JumpBackInSectionState.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13893,6 +13895,7 @@
C889D7D22858C85200121E1D /* Mocks */ = {
isa = PBXGroup;
children = (
8A6CDB462DF9E78400F11139 /* MockTabDisplayViewDragAndDropInteraction.swift */,
8A01FE3F2DF0CE49002C483B /* MockDateProvider.swift */,
8A9F4F042DC8F4ED004644B9 /* MockRemoteTabs.swift */,
8A9F4F022DC8F4E6004644B9 /* MockPlaces.swift */,
Expand Down Expand Up @@ -18622,6 +18625,7 @@
21FA8FB22AE856EB0013B815 /* MockTabTrayCoordinatorDelegate.swift in Sources */,
8A87B4382CC1A92D003A9239 /* MockPocketManager.swift in Sources */,
C8699152289177F5007ACC5C /* WallpaperNetworkingTests.swift in Sources */,
8A6CDB472DF9E78400F11139 /* MockTabDisplayViewDragAndDropInteraction.swift in Sources */,
C818AD452A2100BA007F30BC /* OnboardingNotificationCardHelperTests.swift in Sources */,
E1AEC178286E0CF500062E29 /* LegacyHomepageViewControllerTests.swift in Sources */,
8A4EA0D42C01100200E4E4F1 /* MicrosurveySurfaceManagerTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TabTrayCoordinator: BaseCoordinator,
let tabTrayViewController = TabTrayViewController(panelType: panelType, windowUUID: tabManager.windowUUID)
router.setRootViewController(tabTrayViewController)
self.tabTrayViewController = tabTrayViewController
tabTrayViewController.childPanelControllers = makeChildPanels()
tabTrayViewController.childPanelControllers = makeChildPanels(dragAndDropDelegate: tabTrayViewController)
tabTrayViewController.childPanelThemes = makeChildPanelThemes()
tabTrayViewController.delegate = self
tabTrayViewController.navigationHandler = self
Expand All @@ -58,10 +58,14 @@ class TabTrayCoordinator: BaseCoordinator,
tabTrayViewController?.setupOpenPanel(panelType: tabTraySection)
}

private func makeChildPanels() -> [UINavigationController] {
private func makeChildPanels(dragAndDropDelegate: TabDisplayViewDragAndDropInteraction) -> [UINavigationController] {
let windowUUID = tabManager.windowUUID
let regularTabsPanel = TabDisplayPanelViewController(isPrivateMode: false, windowUUID: windowUUID)
let privateTabsPanel = TabDisplayPanelViewController(isPrivateMode: true, windowUUID: windowUUID)
let regularTabsPanel = TabDisplayPanelViewController(isPrivateMode: false,
windowUUID: windowUUID,
dragAndDropDelegate: dragAndDropDelegate)
let privateTabsPanel = TabDisplayPanelViewController(isPrivateMode: true,
windowUUID: windowUUID,
dragAndDropDelegate: dragAndDropDelegate)
let syncTabs = RemoteTabsPanel(windowUUID: windowUUID)

let panels: [UIViewController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ class TabDisplayPanelViewController: UIViewController,
init(isPrivateMode: Bool,
windowUUID: WindowUUID,
notificationCenter: NotificationProtocol = NotificationCenter.default,
themeManager: ThemeManager = AppContainer.shared.resolve()) {
themeManager: ThemeManager = AppContainer.shared.resolve(),
dragAndDropDelegate: TabDisplayViewDragAndDropInteraction) {
self.panelType = isPrivateMode ? .privateTabs : .tabs
self.tabsState = TabsPanelState(windowUUID: windowUUID, isPrivateMode: isPrivateMode)
self.notificationCenter = notificationCenter
self.themeManager = themeManager
self.windowUUID = windowUUID
super.init(nibName: nil, bundle: nil)
tabDisplayView.dragAndDropDelegate = dragAndDropDelegate
}

required init?(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import Common
import Redux
import UIKit

protocol TabDisplayViewDragAndDropInteraction: AnyObject {
func dragAndDropStarted()
func dragAndDropEnded()
}

class TabDisplayView: UIView,
ThemeApplicable,
UICollectionViewDelegate,
Expand All @@ -26,6 +31,7 @@ class TabDisplayView: UIView,
private let windowUUID: WindowUUID
private let inactiveTabsTelemetry = InactiveTabsTelemetry()
var theme: Theme?
weak var dragAndDropDelegate: TabDisplayViewDragAndDropInteraction?

lazy var dataSource =
TabDisplayDiffableDataSource(
Expand Down Expand Up @@ -457,4 +463,12 @@ extension TabDisplayView: UICollectionViewDragDelegate, UICollectionViewDropDele

store.dispatch(action)
}

func collectionView(_ collectionView: UICollectionView, dragSessionWillBegin session: UIDragSession) {
dragAndDropDelegate?.dragAndDropStarted()
}

func collectionView(_ collectionView: UICollectionView, dragSessionDidEnd session: UIDragSession) {
dragAndDropDelegate?.dragAndDropEnded()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class TabTrayViewController: UIViewController,
StoreSubscriber,
FeatureFlaggable,
TabTraySelectorDelegate,
TabTrayAnimationDelegate {
TabTrayAnimationDelegate,
TabDisplayViewDragAndDropInteraction {
typealias SubscriberStateType = TabTrayState
private struct UX {
struct NavigationMenu {
Expand Down Expand Up @@ -64,6 +65,7 @@ class TabTrayViewController: UIViewController,

private lazy var panelContainer: UIView = .build { _ in }
private var pageViewController: UIPageViewController?
private weak var pageScrollView: UIScrollView?
private var swipeFromIndex: Int?
private lazy var themeAnimator = TabTrayThemeAnimator()

Expand Down Expand Up @@ -718,6 +720,7 @@ class TabTrayViewController: UIViewController,

if let scrollView = pageVC.view.subviews.first(where: { $0 is UIScrollView }) as? UIScrollView {
scrollView.delegate = self
self.pageScrollView = scrollView
}

self.pageViewController = pageVC
Expand Down Expand Up @@ -995,4 +998,14 @@ class TabTrayViewController: UIViewController,
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
swipeFromIndex = nil
}

// MARK: TabDisplayViewDragAndDropInteraction

func dragAndDropStarted() {
pageScrollView?.isScrollEnabled = false
}

func dragAndDropEnded() {
pageScrollView?.isScrollEnabled = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

@testable import Client

class MockTabDisplayViewDragAndDropInteraction: TabDisplayViewDragAndDropInteraction {
var dragAndDropStartedCalled = 0
var dragAndDropEndedCalled = 0

func dragAndDropStarted() {
dragAndDropStartedCalled += 1
}

func dragAndDropEnded() {
dragAndDropEndedCalled += 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ final class TabDisplayPanelTests: XCTestCase {
let subjectState = createSubjectState(isPrivateMode: isPrivateMode,
emptyTabs: emptyTabs,
emptyInactiveTabs: emptyInactiveTabs)
let subject = TabDisplayPanelViewController(isPrivateMode: isPrivateMode, windowUUID: .XCTestDefaultUUID)
let delegate = MockTabDisplayViewDragAndDropInteraction()
let subject = TabDisplayPanelViewController(isPrivateMode: isPrivateMode,
windowUUID: .XCTestDefaultUUID,
dragAndDropDelegate: delegate)
subject.newState(state: subjectState)

trackForMemoryLeaks(subject, file: file, line: line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ final class TabTrayViewControllerTests: XCTestCase {
}

private func makeChildPanels() -> [UINavigationController] {
let regularTabsPanel = TabDisplayPanelViewController(isPrivateMode: false, windowUUID: .XCTestDefaultUUID)
let privateTabsPanel = TabDisplayPanelViewController(isPrivateMode: true, windowUUID: .XCTestDefaultUUID)
let delegate = MockTabDisplayViewDragAndDropInteraction()
let regularTabsPanel = TabDisplayPanelViewController(isPrivateMode: false,
windowUUID: .XCTestDefaultUUID,
dragAndDropDelegate: delegate)
let privateTabsPanel = TabDisplayPanelViewController(isPrivateMode: true,
windowUUID: .XCTestDefaultUUID,
dragAndDropDelegate: delegate)
let syncTabs = RemoteTabsPanel(windowUUID: .XCTestDefaultUUID)
return [
ThemedNavigationController(rootViewController: regularTabsPanel, windowUUID: windowUUID),
Expand Down