VLCRemoteBrowsingCollectionViewController.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "VLCRemoteBrowsingCollectionViewController.h"
  12. #import "VLCRemoteBrowsingTVCell.h"
  13. #import "VLCPlayerDisplayController.h"
  14. #import "VLCPlaybackService.h"
  15. #import "VLCServerBrowsingController.h"
  16. #import "VLCMaskView.h"
  17. @implementation VLCRemoteBrowsingCollectionViewController
  18. - (void)viewDidLoad
  19. {
  20. [super viewDidLoad];
  21. UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
  22. const CGFloat inset = 50;
  23. flowLayout.sectionInset = UIEdgeInsetsMake(inset, inset, inset, inset);
  24. [self.collectionView registerNib:[UINib nibWithNibName:@"VLCRemoteBrowsingTVCell" bundle:nil]
  25. forCellWithReuseIdentifier:VLCRemoteBrowsingTVCellIdentifier];
  26. self.collectionView.maskView = [[VLCMaskView alloc] initWithFrame:self.collectionView.bounds];
  27. /* After day 354 of the year, the usual VLC cone is replaced by another cone
  28. * wearing a Father Xmas hat.
  29. * Note: this icon doesn't represent an endorsement of The Coca-Cola Company
  30. * and should not be confused with the idea of religious statements or propagation there off
  31. */
  32. NSCalendar *gregorian =
  33. [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  34. NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitYear forDate:[NSDate date]];
  35. if (dayOfYear >= 354)
  36. self.nothingFoundConeImageView.image = [UIImage imageNamed:@"xmas-cone"];
  37. }
  38. - (void)viewDidLayoutSubviews
  39. {
  40. [super viewDidLayoutSubviews];
  41. UICollectionView *collectionView = self.collectionView;
  42. VLCMaskView *maskView = (VLCMaskView *)collectionView.maskView;
  43. maskView.maskEnd = self.topLayoutGuide.length * 0.8;
  44. /*
  45. Update the position from where the collection view's content should
  46. start to fade out. The size of the fade increases as the collection
  47. view scrolls to a maximum of half the navigation bar's height.
  48. */
  49. CGFloat maximumMaskStart = maskView.maskEnd + (self.topLayoutGuide.length * 0.5);
  50. CGFloat verticalScrollPosition = MAX(0, collectionView.contentOffset.y + collectionView.contentInset.top);
  51. maskView.maskStart = MIN(maximumMaskStart, maskView.maskEnd + verticalScrollPosition);
  52. /*
  53. Position the mask view so that it is always fills the visible area of
  54. the collection view.
  55. */
  56. CGSize collectionViewSize = self.collectionView.bounds.size;
  57. maskView.frame = CGRectMake(0, collectionView.contentOffset.y, collectionViewSize.width, collectionViewSize.height);
  58. }
  59. #pragma mark - collection view data source
  60. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  61. {
  62. VLCRemoteBrowsingTVCell *cell = (VLCRemoteBrowsingTVCell *)[collectionView dequeueReusableCellWithReuseIdentifier:VLCRemoteBrowsingTVCellIdentifier forIndexPath:indexPath];
  63. return cell;
  64. }
  65. @end