Commit 33e8e303 authored by Carola's avatar Carola

medialibrary: toggle between collectionView and tableview datastructure on ipad closes #11237

parent 79be922b
......@@ -88,42 +88,59 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
- (void)loadView
{
_usingTableViewToShowData = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone;
[self setupContentViewWithContentInset:NO];
_libraryMode = VLCLibraryModeAllFiles;
self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
_emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
_emptyLibraryView.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
}
- (void)setupContentViewWithContentInset:(BOOL)setInset
{
if (_usingTableViewToShowData) {
_tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
_tableView.rowHeight = [VLCPlaylistTableViewCell heightOfCell];
_tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.opaque = YES;
_tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
if(!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
_tableView.rowHeight = [VLCPlaylistTableViewCell heightOfCell];
_tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.opaque = YES;
_tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
}
self.view = _tableView;
[_tableView reloadData];
if (setInset) {
CGFloat originY = self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height;
_tableView.contentInset = UIEdgeInsetsMake(originY, 0, 0, 0);
}
} else {
_folderLayout = [[VLCFolderCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:_folderLayout];
_collectionView.alwaysBounceVertical = YES;
_collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.opaque = YES;
_collectionView.backgroundColor = [UIColor VLCDarkBackgroundColor];
if (!_collectionView) {
_folderLayout = [[VLCFolderCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:_folderLayout];
_collectionView.alwaysBounceVertical = YES;
_collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.opaque = YES;
_collectionView.backgroundColor = [UIColor VLCDarkBackgroundColor];
_longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_collectionViewHandleLongPressGesture:)];
[_collectionView addGestureRecognizer:_longPressGestureRecognizer];
if (SYSTEM_RUNS_IOS7_OR_LATER)
[_collectionView registerNib:[UINib nibWithNibName:@"VLCFuturePlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
else
[_collectionView registerNib:[UINib nibWithNibName:@"VLCPlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
}
self.view = _collectionView;
_longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_collectionViewHandleLongPressGesture:)];
[_collectionView addGestureRecognizer:_longPressGestureRecognizer];
if (SYSTEM_RUNS_IOS7_OR_LATER)
[_collectionView registerNib:[UINib nibWithNibName:@"VLCFuturePlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
else
[_collectionView registerNib:[UINib nibWithNibName:@"VLCPlaylistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"PlaylistCell"];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
[_collectionView reloadData];
if (setInset) {
CGFloat originY = self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height;
_collectionView.contentInset = UIEdgeInsetsMake(originY, 0, 0, 0);
}
}
_libraryMode = VLCLibraryModeAllFiles;
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
_emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
_emptyLibraryView.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
}
#pragma mark -
......@@ -397,9 +414,14 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
self.emptyLibraryView.frame = self.view.bounds;
[self.view addSubview:self.emptyLibraryView];
self.navigationItem.rightBarButtonItem = nil;
} else
self.navigationItem.rightBarButtonItem = self.editButtonItem;
} else {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIBarButtonItem *toggleDisplayedView = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tableViewIcon"] style:UIBarButtonItemStylePlain target:self action:@selector(toggleDisplayedView:)];
self.navigationItem.rightBarButtonItems = @[toggleDisplayedView, self.editButtonItem];
} else {
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
}
if (_usingTableViewToShowData)
_tableView.separatorStyle = (_foundMedia.count > 0)? UITableViewCellSeparatorStyleSingleLine:
UITableViewCellSeparatorStyleNone;
......@@ -1067,6 +1089,14 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
self.navigationController.toolbarHidden = !editing;
}
- (void)toggleDisplayedView:(UIBarButtonItem *)button
{
_usingTableViewToShowData = !_usingTableViewToShowData;
UIImage *newButtonImage = [UIImage imageNamed: _usingTableViewToShowData ? @"collectionViewIcon" : @"tableViewIcon"];
[button setImage:newButtonImage];
[self setupContentViewWithContentInset:YES];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
......
......@@ -40,6 +40,10 @@
2915544117490B9C00B86CAD /* WebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 2915543A17490B9C00B86CAD /* WebSocket.m */; };
2915544317490D4A00B86CAD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2915544217490D4A00B86CAD /* Security.framework */; };
293DF2F417494F8200BB880F /* DropboxSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D05ADEA174945CE0087550C /* DropboxSDK.framework */; };
4115E5FE197977850071C4B9 /* tableViewIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4115E5FC197977850071C4B9 /* tableViewIcon.png */; };
4115E5FF197977850071C4B9 /* tableViewIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4115E5FD197977850071C4B9 /* tableViewIcon@2x.png */; };
4115E60219797B660071C4B9 /* collectionViewIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4115E60019797B660071C4B9 /* collectionViewIcon.png */; };
4115E60319797B660071C4B9 /* collectionViewIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4115E60119797B660071C4B9 /* collectionViewIcon@2x.png */; };
4171D35018A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */; };
4171D35818A2D90200A16EF9 /* LXReorderableCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 4171D35718A2D90200A16EF9 /* LXReorderableCollectionViewFlowLayout.m */; };
41F475D21899A438001B919F /* folderIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 41F475CE1899A438001B919F /* folderIcon.png */; };
......@@ -485,6 +489,10 @@
2915543917490B9C00B86CAD /* WebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocket.h; path = ImportedSources/CocoaHTTPServer/Core/WebSocket.h; sourceTree = SOURCE_ROOT; };
2915543A17490B9C00B86CAD /* WebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebSocket.m; path = ImportedSources/CocoaHTTPServer/Core/WebSocket.m; sourceTree = SOURCE_ROOT; };
2915544217490D4A00B86CAD /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
4115E5FC197977850071C4B9 /* tableViewIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tableViewIcon.png; sourceTree = "<group>"; };
4115E5FD197977850071C4B9 /* tableViewIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tableViewIcon@2x.png"; sourceTree = "<group>"; };
4115E60019797B660071C4B9 /* collectionViewIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = collectionViewIcon.png; sourceTree = "<group>"; };
4115E60119797B660071C4B9 /* collectionViewIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "collectionViewIcon@2x.png"; sourceTree = "<group>"; };
4171D34E18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCFolderCollectionViewFlowLayout.h; path = Sources/VLCFolderCollectionViewFlowLayout.h; sourceTree = SOURCE_ROOT; };
4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCFolderCollectionViewFlowLayout.m; path = Sources/VLCFolderCollectionViewFlowLayout.m; sourceTree = SOURCE_ROOT; };
4171D35618A2D90200A16EF9 /* LXReorderableCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LXReorderableCollectionViewFlowLayout.h; sourceTree = "<group>"; };
......@@ -2064,6 +2072,10 @@
7DEB3B7B1764A4080038FC70 /* menu */ = {
isa = PBXGroup;
children = (
4115E60019797B660071C4B9 /* collectionViewIcon.png */,
4115E60119797B660071C4B9 /* collectionViewIcon@2x.png */,
4115E5FC197977850071C4B9 /* tableViewIcon.png */,
4115E5FD197977850071C4B9 /* tableViewIcon@2x.png */,
7DA7C902186324FA00B56120 /* serverIcon@1x.png */,
7DA7C903186324FA00B56120 /* serverIcon@2x.png */,
7DA7C904186324FA00B56120 /* serverIcon@4x.png */,
......@@ -2404,6 +2416,7 @@
CC1BBC431704935E00A20CBF /* MediaLibrary.mom in Resources */,
26FAE63B19240C2E00A43737 /* PlexServerIcon@4x.png in Resources */,
7D2A34A51805CDBA004078AA /* gradient-cell-ios7@2x.png in Resources */,
4115E60319797B660071C4B9 /* collectionViewIcon@2x.png in Resources */,
7D66225F1871F29000CA9496 /* checkbox-legacy@2x.png in Resources */,
7D897884185E00C3009BAB5D /* checkboxEmpty.png in Resources */,
7D53D525187729EC00A1BA97 /* cloud.png in Resources */,
......@@ -2423,6 +2436,7 @@
7DA8B0FB173318E80029698C /* SourceCodePro-Regular.ttf in Resources */,
A7FF9F3E17428C1900999819 /* DeleteButton.png in Resources */,
A7FF9F4017428C3800999819 /* DeleteButton@2x.png in Resources */,
4115E60219797B660071C4B9 /* collectionViewIcon.png in Resources */,
A7035BBE174519600057DFA7 /* iTunesArtwork in Resources */,
7D53D521187729EC00A1BA97 /* pad@2x.png in Resources */,
29125E5617492219003F03E5 /* index.html in Resources */,
......@@ -2474,6 +2488,7 @@
7DE1862F175BA9AC006C0173 /* badgeUnread~ipad.png in Resources */,
26FAE63919240C2E00A43737 /* PlexServerIcon@1x.png in Resources */,
7DBBF19B183AB4300009A339 /* VLCCloudStorageTableViewCell~iphone.xib in Resources */,
4115E5FE197977850071C4B9 /* tableViewIcon.png in Resources */,
7DE18632175BA9AF006C0173 /* badgeUnread~iphone.png in Resources */,
7D47D6F91760CD8700E86BAD /* subtitleIcon.png in Resources */,
7D47D6FA1760CD8700E86BAD /* subtitleIcon@2x.png in Resources */,
......@@ -2588,6 +2603,7 @@
7D53D520187729EC00A1BA97 /* phone.png in Resources */,
7DEB3B8D1764A4F40038FC70 /* blank@2x.png in Resources */,
7D63C1C8187767AF00BD5256 /* fsarrow-position@2x.png in Resources */,
4115E5FF197977850071C4B9 /* tableViewIcon@2x.png in Resources */,
7D223E1B181EC56E00B36798 /* gradient-cell-ios7-ipad@2x.png in Resources */,
7D53D51B187729EC00A1BA97 /* uploadarrow@2x.png in Resources */,
7AC8629D1765DC560011611A /* style.css in Resources */,
......
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