Commit c88e1ff9 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

library: drop search support when in collection view mode (closes #12901)

parent 9b416362
/*****************************************************************************
* VLCLibraryHeaderView.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface VLCLibraryHeaderView : UICollectionReusableView
+ (CGFloat)headerHeight;
- (id)initWithPredefinedFrame;
@property (strong, nonatomic, readwrite) UISearchBar *searchBar;
@end
/*****************************************************************************
* VLCLibraryHeaderView.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCLibraryHeaderView.h"
@interface VLCLibraryHeaderView ()
{
UISearchBar *_searchbar;
}
@end
@implementation VLCLibraryHeaderView
+ (CGFloat)headerHeight
{
return 40.;
}
- (id)initWithFrame:(CGRect)frame
{
return [self initWithPredefinedFrame];
}
- (id)initWithPredefinedFrame
{
self = [super initWithFrame:CGRectMake(0., 0., 320., [VLCLibraryHeaderView headerHeight])];
if (self)
self.backgroundColor = [UIColor VLCDarkBackgroundColor];
return self;
}
- (void)setSearchBar:(UISearchBar *)searchBar
{
if (searchBar == nil) {
if (_searchbar)
[_searchbar removeFromSuperview];
_searchbar = nil;
return;
}
_searchbar = searchBar;
CGRect contentFrame = self.frame;
_searchbar.frame = contentFrame;
[self addSubview:_searchbar];
}
- (UISearchBar *)searchBar
{
return _searchbar;
}
@end
......@@ -27,7 +27,6 @@
#import "LXReorderableCollectionViewFlowLayout.h"
#import "VLCAlertView.h"
#import "VLCOpenInActivity.h"
#import "VLCLibraryHeaderView.h"
#import <AssetsLibrary/AssetsLibrary.h>
......@@ -110,13 +109,11 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
_tableView.opaque = YES;
_tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
}
self.view = _tableView;
[_tableView reloadData];
} else {
if (!_collectionView) {
_folderLayout = [[VLCFolderCollectionViewFlowLayout alloc] init];
_folderLayout.headerReferenceSize = CGSizeMake(640., [VLCLibraryHeaderView headerHeight]);
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:_folderLayout];
_collectionView.alwaysBounceVertical = YES;
_collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
......@@ -130,7 +127,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
[_collectionView registerNib:[UINib nibWithNibName:@"VLCFuturePlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
else
[_collectionView registerNib:[UINib nibWithNibName:@"VLCPlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
[_collectionView registerClass:[VLCLibraryHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderCell"];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
}
self.view = _collectionView;
......@@ -145,14 +141,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
if (_usingTableViewToShowData)
_tableView.contentInset = UIEdgeInsetsMake(originY, 0, 0, 0);
else {
if (_searchBar.hidden)
_collectionView.contentInset = UIEdgeInsetsMake(originY - [VLCLibraryHeaderView headerHeight], 0, 0, 0);
else {
_collectionView.contentInset = UIEdgeInsetsMake(originY, 0, 0, 0);
[_collectionView scrollRectToVisible:CGRectMake(0., 0., 640., 200.) animated:NO];
}
}
}
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
......@@ -228,9 +216,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
_searchBar.delegate = self;
_searchBar.hidden = YES;
if (!_usingTableViewToShowData)
_collectionView.contentInset = UIEdgeInsetsMake(-[VLCLibraryHeaderView headerHeight], 0, 0, 0);
UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTwiceGestureAction:)];
[tapTwiceGesture setNumberOfTapsRequired:2];
[self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
......@@ -728,18 +713,17 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
- (void)tapTwiceGestureAction:(UIGestureRecognizer *)recognizer
{
_searchBar.hidden = !_searchBar.hidden;
if (!_usingTableViewToShowData)
return;
if (_usingTableViewToShowData) {
if (_searchBar.hidden)
self.tableView.tableHeaderView = nil;
else
self.tableView.tableHeaderView = _searchBar;
_searchBar.hidden = !_searchBar.hidden;
[self.tableView setContentOffset:CGPointMake(0.0f, -self.tableView.contentInset.top) animated:NO];
if (_searchBar.hidden)
self.tableView.tableHeaderView = nil;
else
self.tableView.tableHeaderView = _searchBar;
} else
[self setupContentViewWithContentInset:YES];
[self.tableView setContentOffset:CGPointMake(0.0f, -self.tableView.contentInset.top) animated:NO];
}
#pragma mark - Collection View
......@@ -908,19 +892,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
}
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
VLCLibraryHeaderView *reuseableView;
reuseableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderCell" forIndexPath:indexPath];
if (!reuseableView)
reuseableView = [[VLCLibraryHeaderView alloc] initWithPredefinedFrame];
reuseableView.searchBar = _searchBar;
return reuseableView;
}
#pragma mark - Folder implementation
- (void)rearrangeFolderTrackNumbersForRemovedItem:(MLFile *) mediaObject
......
......@@ -371,7 +371,6 @@
7DC72D6017B7E7C7008A26D0 /* download@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DC72D5D17B7E7C7008A26D0 /* download@2x.png */; };
7DC72D6317B7ED24008A26D0 /* WhiteRaccoon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC72D6217B7ED24008A26D0 /* WhiteRaccoon.m */; };
7DD2A3A9179C04A7003EB537 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7DD2A3A8179C04A6003EB537 /* OpenSans-Regular.ttf */; };
7DD619461A5DC6650056308A /* VLCLibraryHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD619451A5DC6650056308A /* VLCLibraryHeaderView.m */; };
7DDD0429172D98E5005A7B10 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DDD0428172D98E5005A7B10 /* CFNetwork.framework */; };
7DE18629175BA9A5006C0173 /* badgeUnread@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DE1862B175BA9A5006C0173 /* badgeUnread@2x~ipad.png */; };
7DE1862C175BA9A9006C0173 /* badgeUnread@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DE1862E175BA9A9006C0173 /* badgeUnread@2x~iphone.png */; };
......@@ -1141,8 +1140,6 @@
7DD32D24194F1946002510A9 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "zh-Hant"; path = "zh-Hant.lproj/badgeUnread@2x~iphone.png"; sourceTree = "<group>"; };
7DD32D25194F1946002510A9 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "zh-Hant"; path = "zh-Hant.lproj/badgeUnread~ipad.png"; sourceTree = "<group>"; };
7DD32D26194F1946002510A9 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "zh-Hant"; path = "zh-Hant.lproj/badgeUnread~iphone.png"; sourceTree = "<group>"; };
7DD619441A5DC6650056308A /* VLCLibraryHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCLibraryHeaderView.h; path = Sources/VLCLibraryHeaderView.h; sourceTree = SOURCE_ROOT; };
7DD619451A5DC6650056308A /* VLCLibraryHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLibraryHeaderView.m; path = Sources/VLCLibraryHeaderView.m; sourceTree = SOURCE_ROOT; };
7DDD0428172D98E5005A7B10 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
7DE1862A175BA9A5006C0173 /* en */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = en; path = "en.lproj/badgeUnread@2x~ipad.png"; sourceTree = "<group>"; };
7DE1862D175BA9A9006C0173 /* en */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = en; path = "en.lproj/badgeUnread@2x~iphone.png"; sourceTree = "<group>"; };
......@@ -1933,8 +1930,6 @@
8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */,
7D37849C183A98DD009EE944 /* VLCThumbnailsCache.h */,
7D37849D183A98DD009EE944 /* VLCThumbnailsCache.m */,
7DD619441A5DC6650056308A /* VLCLibraryHeaderView.h */,
7DD619451A5DC6650056308A /* VLCLibraryHeaderView.m */,
);
name = "Everything Playlist";
sourceTree = "<group>";
......@@ -3230,7 +3225,6 @@
7D1052EE1A4DCD1E00295F08 /* VLCOneDriveController.m in Sources */,
7D30F3D8183AB2F100FFC021 /* VLCLocalServerFolderListViewController.m in Sources */,
7D30F3D9183AB2F100FFC021 /* VLCLocalServerListViewController.m in Sources */,
7DD619461A5DC6650056308A /* VLCLibraryHeaderView.m in Sources */,
7D30F3DC183AB2F900FFC021 /* VLCNetworkLoginViewController.m in Sources */,
7D30F3DF183AB31E00FFC021 /* VLCWiFiUploadTableViewCell.m in Sources */,
7D30F3E2183AB33200FFC021 /* VLCSidebarViewCell.m in Sources */,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment