-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor FXIOS-6922 [v120] Create a tab display view to share with re…
…gular and private tabs screens (#16646)
- Loading branch information
Showing
4 changed files
with
96 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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/ | ||
|
||
import Common | ||
import UIKit | ||
|
||
class TabDisplayView: UIView, | ||
ThemeApplicable, | ||
UICollectionViewDataSource, | ||
UICollectionViewDelegate, | ||
UICollectionViewDragDelegate, | ||
UICollectionViewDropDelegate { | ||
enum UX {} | ||
|
||
lazy var collectionView: UICollectionView = { | ||
let collectionView = UICollectionView(frame: .zero, | ||
collectionViewLayout: UICollectionViewFlowLayout()) | ||
collectionView.register(cellType: LegacyTabCell.self) | ||
|
||
collectionView.alwaysBounceVertical = true | ||
collectionView.keyboardDismissMode = .onDrag | ||
collectionView.dragInteractionEnabled = true | ||
// TODO: FXIOS-6926 Create TabDisplayManager and update delegates | ||
collectionView.dragDelegate = self | ||
collectionView.dropDelegate = self | ||
collectionView.dataSource = self | ||
collectionView.delegate = self | ||
return collectionView | ||
}() | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupLayout() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupLayout() { | ||
addSubview(collectionView) | ||
|
||
NSLayoutConstraint.activate([ | ||
collectionView.topAnchor.constraint(equalTo: topAnchor), | ||
collectionView.leadingAnchor.constraint(equalTo: leadingAnchor), | ||
collectionView.bottomAnchor.constraint(equalTo: bottomAnchor), | ||
collectionView.trailingAnchor.constraint(equalTo: trailingAnchor) | ||
]) | ||
} | ||
|
||
func applyTheme(theme: Theme) { | ||
collectionView.backgroundColor = theme.colors.layer3 | ||
} | ||
|
||
// MARK: UICollectionViewDataSource | ||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return 1 | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: LegacyTabCell.cellIdentifier, for: indexPath) | ||
|
||
return cell | ||
} | ||
|
||
// MARK: UICollectionViewDragDelegate | ||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { | ||
let itemProvider = NSItemProvider() | ||
|
||
let dragItem = UIDragItem(itemProvider: itemProvider) | ||
return [dragItem] | ||
} | ||
|
||
// MARK: UICollectionViewDropDelegate | ||
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters