-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the scroll tracking of WKWebView on iOS 17.4 (#630)
* Fix a scroll tracking issue of WKWebView on iOS 17.4 * Add 'Scroll tracking(List CollectionView)' use case in Samples app
- Loading branch information
Showing
6 changed files
with
153 additions
and
4 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
77 changes: 77 additions & 0 deletions
77
Examples/Samples/Sources/ContentViewControllers/DebugListCollectionViewController.swift
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,77 @@ | ||
// Copyright 2018 the FloatingPanel authors. All rights reserved. MIT license. | ||
|
||
import UIKit | ||
|
||
@available(iOS 14, *) | ||
class DebugListCollectionViewController: UIViewController { | ||
|
||
enum Section { | ||
case main | ||
} | ||
|
||
var dataSource: UICollectionViewDiffableDataSource<Section, Int>! = nil | ||
var collectionView: UICollectionView! = nil | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
navigationItem.title = "List" | ||
configureHierarchy() | ||
configureDataSource() | ||
} | ||
} | ||
|
||
@available(iOS 14, *) | ||
extension DebugListCollectionViewController { | ||
/// - Tag: List | ||
private func createLayout() -> UICollectionViewLayout { | ||
var config = UICollectionLayoutListConfiguration(appearance: .insetGrouped) | ||
config.trailingSwipeActionsConfigurationProvider = { indexPath -> UISwipeActionsConfiguration? in | ||
return UISwipeActionsConfiguration( | ||
actions: [UIContextualAction( | ||
style: .destructive, | ||
title: "Delete", | ||
handler: { _, _, completion in | ||
// Do nothing now | ||
} | ||
)] | ||
) | ||
} | ||
return UICollectionViewCompositionalLayout.list(using: config) | ||
} | ||
} | ||
|
||
@available(iOS 14, *) | ||
extension DebugListCollectionViewController { | ||
private func configureHierarchy() { | ||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout()) | ||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
view.addSubview(collectionView) | ||
collectionView.delegate = self | ||
} | ||
private func configureDataSource() { | ||
|
||
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Int> { (cell, indexPath, item) in | ||
var content = cell.defaultContentConfiguration() | ||
content.text = "\(item)" | ||
cell.contentConfiguration = content | ||
} | ||
|
||
dataSource = UICollectionViewDiffableDataSource<Section, Int>(collectionView: collectionView) { | ||
(collectionView: UICollectionView, indexPath: IndexPath, identifier: Int) -> UICollectionViewCell? in | ||
|
||
return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: identifier) | ||
} | ||
|
||
var snapshot = NSDiffableDataSourceSnapshot<Section, Int>() | ||
snapshot.appendSections([.main]) | ||
snapshot.appendItems(Array(0..<94)) | ||
dataSource.apply(snapshot, animatingDifferences: false) | ||
} | ||
} | ||
|
||
@available(iOS 14, *) | ||
extension DebugListCollectionViewController: UICollectionViewDelegate { | ||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
collectionView.deselectItem(at: indexPath, animated: true) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Examples/Samples/Sources/ContentViewControllers/UnavailableViewController.swift
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,24 @@ | ||
// Copyright 2018 the FloatingPanel authors. All rights reserved. MIT license. | ||
|
||
import UIKit | ||
|
||
class UnavailableViewController: UIViewController { | ||
weak var label: UILabel! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
let label = UILabel() | ||
label.text = "Unavailable content" | ||
label.numberOfLines = 0 | ||
label.textAlignment = .center | ||
label.frame = view.bounds | ||
label.autoresizingMask = [ | ||
.flexibleTopMargin, | ||
.flexibleLeftMargin, | ||
.flexibleBottomMargin, | ||
.flexibleRightMargin | ||
] | ||
view.addSubview(label) | ||
self.label = label | ||
} | ||
} |
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
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