VLCRemoteBrowsingCollectionViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "VLCPlaybackController.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. }
  28. - (void)viewDidLayoutSubviews
  29. {
  30. [super viewDidLayoutSubviews];
  31. UICollectionView *collectionView = self.collectionView;
  32. VLCMaskView *maskView = (VLCMaskView *)collectionView.maskView;
  33. maskView.maskEnd = self.topLayoutGuide.length * 0.8;
  34. /*
  35. Update the position from where the collection view's content should
  36. start to fade out. The size of the fade increases as the collection
  37. view scrolls to a maximum of half the navigation bar's height.
  38. */
  39. CGFloat maximumMaskStart = maskView.maskEnd + (self.topLayoutGuide.length * 0.5);
  40. CGFloat verticalScrollPosition = MAX(0, collectionView.contentOffset.y + collectionView.contentInset.top);
  41. maskView.maskStart = MIN(maximumMaskStart, maskView.maskEnd + verticalScrollPosition);
  42. /*
  43. Position the mask view so that it is always fills the visible area of
  44. the collection view.
  45. */
  46. CGSize collectionViewSize = self.collectionView.bounds.size;
  47. maskView.frame = CGRectMake(0, collectionView.contentOffset.y, collectionViewSize.width, collectionViewSize.height);
  48. }
  49. #pragma mark - collection view data source
  50. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  51. {
  52. VLCRemoteBrowsingTVCell *cell = (VLCRemoteBrowsingTVCell *)[collectionView dequeueReusableCellWithReuseIdentifier:VLCRemoteBrowsingTVCellIdentifier forIndexPath:indexPath];
  53. return cell;
  54. }
  55. @end