Skip to content

Commit

Permalink
FavoriteListViewController: Rename the files
Browse files Browse the repository at this point in the history
The VLCFavoriteListViewController files now drop the "VLC" prefix
to conform to the Swift standards.

The proper changes in other files according to this rename have also
been made.
  • Loading branch information
Diogo Simao Marques authored and fkuehne committed Sep 15, 2024
1 parent 1f1df71 commit a231a51
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****************************************************************************
* VLCFavoriteListViewController.swift
* FavoriteListViewController.swift
* VLC for iOS
*****************************************************************************
* Copyright (c) 2023-2024 VideoLAN. All rights reserved.
Expand All @@ -15,7 +15,7 @@

import UIKit

class VLCFavoriteListViewController: UIViewController {
class FavoriteListViewController: UIViewController {

init() {
super.init(nibName: nil, bundle: nil)
Expand Down Expand Up @@ -184,7 +184,7 @@ class VLCFavoriteListViewController: UIViewController {
}
}

extension VLCFavoriteListViewController: UITableViewDelegate, UITableViewDataSource {
extension FavoriteListViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return isSearching ? 1 : favoriteService.numberOfFavoritedServers
}
Expand Down Expand Up @@ -272,15 +272,15 @@ extension VLCFavoriteListViewController: UITableViewDelegate, UITableViewDataSou
}
}

extension VLCFavoriteListViewController: FavoriteSectionHeaderDelegate {
extension FavoriteListViewController: FavoriteSectionHeaderDelegate {
func reloadData() {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}

extension VLCFavoriteListViewController: UISearchBarDelegate {
extension FavoriteListViewController: UISearchBarDelegate {
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
if searchText.isEmpty {
searchResults = searchDataSource
Expand All @@ -304,7 +304,7 @@ extension VLCFavoriteListViewController: UISearchBarDelegate {
}
}

extension VLCFavoriteListViewController: UIScrollViewDelegate {
extension FavoriteListViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// This ensures that the search bar is always visible like a sticky while searching
if isSearching {
Expand All @@ -327,7 +327,7 @@ extension VLCFavoriteListViewController: UIScrollViewDelegate {
}
}

extension VLCFavoriteListViewController {
extension FavoriteListViewController {
private func showCloudFavVC(fav: VLCFavorite) {
let favURL = fav.url
var cloudVC: VLCCloudStorageTableViewController?
Expand Down Expand Up @@ -357,4 +357,3 @@ extension VLCFavoriteListViewController {
}
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****************************************************************************
* VLCFavoriteListViewController.swift
* FavoriteListViewController.swift
* VLC for iOS
*****************************************************************************
* Copyright (c) 2024 VideoLAN. All rights reserved.
Expand All @@ -14,36 +14,36 @@

import Foundation

class VLCFavoriteListViewController: VLCRemoteBrowsingCollectionViewController {
class FavoriteListViewController: VLCRemoteBrowsingCollectionViewController {

let favoriteService: VLCFavoriteService = VLCAppCoordinator.sharedInstance().favoriteService

// For delete operations
private var currentlyFocusedIndexPath: IndexPath?
private var isAnyCellFocused: Bool = false

init() {
super.init(nibName: "VLCRemoteBrowsingCollectionViewController", bundle: nil)
title = NSLocalizedString("FAVORITES", comment: "")
super.collectionView.register(FavoriteSectionHeader.self, forSupplementaryViewOfKind:
UICollectionView.elementKindSectionHeader, withReuseIdentifier: FavoriteSectionHeader.identifier)

let deleteRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(startEditMode))
deleteRecognizer.allowedPressTypes = [NSNumber(value: UIPress.PressType.select.rawValue)]
deleteRecognizer.minimumPressDuration = 1.0
self.view.addGestureRecognizer(deleteRecognizer)

let cancelRecognizer = UITapGestureRecognizer(target: self, action: #selector(endEditMode))
cancelRecognizer.allowedPressTypes = [NSNumber(value: UIPress.PressType.select.rawValue), NSNumber(value: UIPress.PressType.menu.rawValue)]
cancelRecognizer.isEnabled = self.isEditing
self.view.addGestureRecognizer(cancelRecognizer)
showEmptyViewIfNeeded()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func showEmptyViewIfNeeded() {
if favoriteService.numberOfFavoritedServers == 0 {
self.nothingFoundLabel.text = NSLocalizedString("NO_FAVORITES_DESCRIPTION", comment: "")
Expand All @@ -52,7 +52,7 @@ class VLCFavoriteListViewController: VLCRemoteBrowsingCollectionViewController {
nothingFoundView!.sizeToFit()
nothingFoundView!.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(nothingFoundView!)

let yConstraint = NSLayoutConstraint(item: nothingFoundView as Any,
attribute: .centerY,
relatedBy: .equal,
Expand All @@ -61,7 +61,7 @@ class VLCFavoriteListViewController: VLCRemoteBrowsingCollectionViewController {
multiplier: 1.0,
constant: 0.0)
self.view.addConstraint(yConstraint)

let xConstraint = NSLayoutConstraint(item: nothingFoundView as Any,
attribute: .centerX,
relatedBy: .equal,
Expand All @@ -73,16 +73,17 @@ class VLCFavoriteListViewController: VLCRemoteBrowsingCollectionViewController {
}
}
}

// MARK: - UICollectionView
extension VLCFavoriteListViewController {
extension FavoriteListViewController {
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return favoriteService.numberOfFavoritesOfServer(at: section)
}

override func numberOfSections(in collectionView: UICollectionView) -> Int {
return favoriteService.numberOfFavoritedServers
}

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "VLCRemoteBrowsingTVCell", for: indexPath) as! VLCRemoteBrowsingTVCell
if let favorite = favoriteService.favoriteOfServer(with: indexPath.section, at: indexPath.row) {
Expand All @@ -92,7 +93,7 @@ extension VLCFavoriteListViewController {
cell.thumbnailImage = UIImage(named: "folder")
return cell
}

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let favorite = favoriteService.favoriteOfServer(with: indexPath.section, at: indexPath.row) {

Expand Down Expand Up @@ -126,7 +127,7 @@ extension VLCFavoriteListViewController {
self.navigationController?.pushViewController(serverBrowserVC, animated: true)
}
}

override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: FavoriteSectionHeader.identifier, for: indexPath) as! FavoriteSectionHeader
Expand All @@ -138,10 +139,10 @@ extension VLCFavoriteListViewController {
}
return UICollectionReusableView()
}

}

// MARK: - Deletion
extension VLCFavoriteListViewController {
extension FavoriteListViewController {
@objc private func startEditMode() {
self.isEditing = true
let alertController = UIAlertController(title: NSLocalizedString("UNFAVORITE_ALERT_TITLE", comment: ""), message: nil, preferredStyle: .alert)
Expand All @@ -159,21 +160,22 @@ extension VLCFavoriteListViewController {
if self.isAnyCellFocused {
present(alertController, animated: true, completion: nil)
}

}

@objc private func endEditMode() {
self.isEditing = false
}
}

// MARK: - Rename Delegate
extension VLCFavoriteListViewController: FavoriteSectionHeaderDelegate {
extension FavoriteListViewController: FavoriteSectionHeaderDelegate {
func reloadData() {
self.collectionView.reloadData()
}
}

// MARK: - UICollectionViewFlowLayout
extension VLCFavoriteListViewController {
extension FavoriteListViewController {
override func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
guard let nextFocusedIndexPath = context.nextFocusedIndexPath else {
// Handle the case where nextFocusedIndexPath is nil, if needed.
Expand All @@ -189,40 +191,40 @@ extension VLCFavoriteListViewController {
}
}

extension VLCFavoriteListViewController: UICollectionViewDelegateFlowLayout {
extension FavoriteListViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: collectionView.bounds.width, height: FavoriteSectionHeader.height)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 50, left: 100, bottom: 50, right: 100)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 100.00
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 48
}

}

public extension IndexPath {
func isLastRow(at collectionView: UICollectionView) -> Bool {
return row == (collectionView.numberOfItems(inSection: section) - 1)
}
func isLastRow(at collectionView: UICollectionView) -> Bool {
return row == (collectionView.numberOfItems(inSection: section) - 1)
}
}

// MARK: - Focus Engine Guide for Header's Rename Button
extension VLCFavoriteListViewController {
extension FavoriteListViewController {
private func setupFocusGuide(for header: FavoriteSectionHeader, at indexPath: IndexPath, in collectionView: UICollectionView) {
let focusGuide = UIFocusGuide()
self.view.addLayoutGuide(focusGuide)
focusGuide.isEnabled = true
focusGuide.preferredFocusEnvironments = [header.headerView.renameButton]

let cell = collectionView.cellForItem(at: indexPath)

focusGuide.widthAnchor.constraint(equalTo: cell?.widthAnchor ?? focusGuide.widthAnchor).isActive = true
focusGuide.heightAnchor.constraint(equalTo: cell?.heightAnchor ?? focusGuide.heightAnchor).isActive = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ - (void)didSelectService:(id<VLCLocalNetworkService>)service
{
if (login.protocolIdentifier) {
if ([login.protocolIdentifier isEqualToString:@"favorites"]) {
VLCFavoriteListViewController *favoriteListViewController = [[VLCFavoriteListViewController alloc] init];
FavoriteListViewController *favoriteListViewController = [[FavoriteListViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:favoriteListViewController];
navController.view.window.translatesAutoresizingMaskIntoConstraints = NO;
[self presentViewController: navController animated:YES completion:nil];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableViewDeleg
let cloudVC = VLCCloudServicesTableViewController(nibName: "VLCCloudServicesTableViewController", bundle: Bundle.main)
let streamingVC = VLCOpenNetworkStreamViewController(nibName: "VLCOpenNetworkStreamViewController", bundle: Bundle.main)
let downloadVC = VLCDownloadViewController(nibName: "VLCDownloadViewController", bundle: Bundle.main)
let favoriteVC = VLCFavoriteListViewController()
let favoriteVC = FavoriteListViewController()

@objc weak var delegate: RemoteNetworkDataSourceDelegate?

Expand Down
16 changes: 8 additions & 8 deletions VLC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
226D57E12B42FE060090AD88 /* FavoriteHeaderContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226D57E02B42FE060090AD88 /* FavoriteHeaderContentView.swift */; };
226D57E22B42FE060090AD88 /* FavoriteHeaderContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226D57E02B42FE060090AD88 /* FavoriteHeaderContentView.swift */; };
226D57EA2B4439080090AD88 /* FavoriteSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226D57E82B4439080090AD88 /* FavoriteSectionHeader.swift */; };
226D57ED2B4439880090AD88 /* VLCFavoriteListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226D57EB2B4439880090AD88 /* VLCFavoriteListViewController.swift */; };
226D57ED2B4439880090AD88 /* FavoriteListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226D57EB2B4439880090AD88 /* FavoriteListViewController.swift */; };
2663ACB422497D47000FBB95 /* VLCNetworkLoginTVViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2663ACB322497D47000FBB95 /* VLCNetworkLoginTVViewController.xib */; };
26F1BFD01A770408001DF30C /* libMediaVLC.xml in Resources */ = {isa = PBXBuildFile; fileRef = 26F1BFCF1A770408001DF30C /* libMediaVLC.xml */; };
277943252A6176170010D5EA /* FavoriteSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277943242A6176170010D5EA /* FavoriteSectionHeader.swift */; };
27CE104F2A3C5ECF0061C92B /* VLCFavoriteListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27CE104E2A3C5ECF0061C92B /* VLCFavoriteListViewController.swift */; };
27CE104F2A3C5ECF0061C92B /* FavoriteListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27CE104E2A3C5ECF0061C92B /* FavoriteListViewController.swift */; };
29125E5617492219003F03E5 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 29125E5417492219003F03E5 /* index.html */; };
2915544317490D4A00B86CAD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2915544217490D4A00B86CAD /* Security.framework */; };
4072A777258791B8006EA498 /* VideoFiltersView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4072A776258791B8006EA498 /* VideoFiltersView.xib */; };
Expand Down Expand Up @@ -536,13 +536,13 @@
1B2DEE8F2C63D57300E414B4 /* NSURLSessionConfiguration+default.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSURLSessionConfiguration+default.m"; sourceTree = "<group>"; };
226D57E02B42FE060090AD88 /* FavoriteHeaderContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteHeaderContentView.swift; sourceTree = "<group>"; };
226D57E82B4439080090AD88 /* FavoriteSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSectionHeader.swift; sourceTree = "<group>"; };
226D57EB2B4439880090AD88 /* VLCFavoriteListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCFavoriteListViewController.swift; sourceTree = "<group>"; };
226D57EB2B4439880090AD88 /* FavoriteListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteListViewController.swift; sourceTree = "<group>"; };
2629C887223991A400F8D080 /* VLCMediaThumbnailerCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCMediaThumbnailerCache.swift; sourceTree = "<group>"; };
2663ACB122497D21000FBB95 /* VLCNetworkLoginTVViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCNetworkLoginTVViewController.swift; sourceTree = "<group>"; };
2663ACB322497D47000FBB95 /* VLCNetworkLoginTVViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCNetworkLoginTVViewController.xib; sourceTree = "<group>"; };
26F1BFCF1A770408001DF30C /* libMediaVLC.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = libMediaVLC.xml; sourceTree = "<group>"; };
277943242A6176170010D5EA /* FavoriteSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSectionHeader.swift; sourceTree = "<group>"; };
27CE104E2A3C5ECF0061C92B /* VLCFavoriteListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCFavoriteListViewController.swift; sourceTree = "<group>"; };
27CE104E2A3C5ECF0061C92B /* FavoriteListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteListViewController.swift; sourceTree = "<group>"; };
29125E5417492219003F03E5 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
2915544217490D4A00B86CAD /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
2E995114543D1E41A5A82486 /* Pods-VLC-iOS-Screenshots.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOS-Screenshots.release.xcconfig"; path = "Target Support Files/Pods-VLC-iOS-Screenshots/Pods-VLC-iOS-Screenshots.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1401,7 +1401,7 @@
isa = PBXGroup;
children = (
277943242A6176170010D5EA /* FavoriteSectionHeader.swift */,
27CE104E2A3C5ECF0061C92B /* VLCFavoriteListViewController.swift */,
27CE104E2A3C5ECF0061C92B /* FavoriteListViewController.swift */,
);
path = iOS;
sourceTree = "<group>";
Expand All @@ -1410,7 +1410,7 @@
isa = PBXGroup;
children = (
226D57E82B4439080090AD88 /* FavoriteSectionHeader.swift */,
226D57EB2B4439880090AD88 /* VLCFavoriteListViewController.swift */,
226D57EB2B4439880090AD88 /* FavoriteListViewController.swift */,
);
path = tvOS;
sourceTree = "<group>";
Expand Down Expand Up @@ -3623,7 +3623,7 @@
7D405ED31BEA11CD006ED886 /* VLCHTTPUploaderController.m in Sources */,
7DC869C328CB7E5700EE99F8 /* VLCNetworkLoginTVViewController.swift in Sources */,
7DF90B4B1BE7A8110059C0E3 /* IASKSpecifier.m in Sources */,
226D57ED2B4439880090AD88 /* VLCFavoriteListViewController.swift in Sources */,
226D57ED2B4439880090AD88 /* FavoriteListViewController.swift in Sources */,
DD3EFF4E1BDEBCE500B68579 /* VLCNetworkServerBrowserPlex.m in Sources */,
7DC7BA7E28C894EC00109F28 /* GRKArrayDiff+UICollectionView.m in Sources */,
7DC7BAB828C8958900109F28 /* LayoutAnchorContainer.swift in Sources */,
Expand Down Expand Up @@ -3764,7 +3764,7 @@
8DE1887621089BB100A091D2 /* VideoModel.swift in Sources */,
7D1471712B88A45B00AB642B /* VLCSubscription.m in Sources */,
DD3EFF351BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserNetService.m in Sources */,
27CE104F2A3C5ECF0061C92B /* VLCFavoriteListViewController.swift in Sources */,
27CE104F2A3C5ECF0061C92B /* FavoriteListViewController.swift in Sources */,
413EC987201A329D00BF412F /* SortModel.swift in Sources */,
41B93C011A53833B00102E8B /* VLCProgressView.m in Sources */,
44C8BBB224AF36F4003F8940 /* SettingsCell.swift in Sources */,
Expand Down

0 comments on commit a231a51

Please sign in to comment.