Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor WMFLocationManager to Swift #3

Open
wants to merge 19 commits into
base: develop
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Move non-delegate code out of the delegate extension

  • Loading branch information
jantimar authored and VojtaStavik committed Feb 28, 2020
commit aa44b4bc2ea500556ab5478a2e3c2dbbf4c0437a
@@ -107,6 +107,15 @@ class ArticleLocationCollectionViewController: ColumnarCollectionViewController,
ReadingListsFunnel.shared.logUnsaveInFeed(context: context, articleURL: articleURL, index: previewedIndexPath?.item)
}
}

func updateLocationOnVisibleCells() {
for cell in collectionView.visibleCells {
guard let locationCell = cell as? ArticleLocationCollectionViewCell else {
continue
}
locationCell.update(userLocation: locationManager.location, heading: locationManager.heading)
}
}
}

// MARK: - UICollectionViewDataSource
@@ -156,15 +165,6 @@ extension ArticleLocationCollectionViewController {

// MARK: - WMFLocationManagerDelegate
extension ArticleLocationCollectionViewController: WMFLocationManagerDelegate {
func updateLocationOnVisibleCells() {
for cell in collectionView.visibleCells {
guard let locationCell = cell as? ArticleLocationCollectionViewCell else {
continue
}
locationCell.update(userLocation: locationManager.location, heading: locationManager.heading)
}
}

func locationManager(_ controller: WMFLocationManager, didUpdate location: CLLocation) {
updateLocationOnVisibleCells()
}
@@ -371,7 +371,18 @@ class ExploreCardViewController: UIViewController, UICollectionViewDataSource, U
}
cell.layoutMargins = layout.itemLayoutMargins
}


func updateLocationCells() {
let userLocation = locationManager.location
let heading = locationManager.heading
for cell in collectionView.visibleCells {
guard let cell = cell as? ArticleLocationExploreCollectionViewCell else {
return
}
cell.update(userLocation: userLocation, heading: heading)
}
}

// MARK - UICollectionViewDataSource
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
@@ -641,17 +652,6 @@ extension ExploreCardViewController: ArticleLocationAuthorizationCollectionViewC
}

extension ExploreCardViewController: WMFLocationManagerDelegate {
func updateLocationCells() {
let userLocation = locationManager.location
let heading = locationManager.heading
for cell in collectionView.visibleCells {
guard let cell = cell as? ArticleLocationExploreCollectionViewCell else {
return
}
cell.update(userLocation: userLocation, heading: heading)
}
}

func locationManager(_ controller: WMFLocationManager, didUpdate location: CLLocation) {
updateLocationCells()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.