Commit 7cfe86c6 authored by Tobias's avatar Tobias

server list as collection view instead of table view

parent 0e801d14
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
*****************************************************************************/ *****************************************************************************/
#import "AppleTVAppDelegate.h" #import "AppleTVAppDelegate.h"
#import "VLCServerListTVTableViewController.h" #import "VLCServerListTVViewController.h"
#import "VLCOpenNetworkStreamTVViewController.h" #import "VLCOpenNetworkStreamTVViewController.h"
#import "VLCSettingsTableViewController.h" #import "VLCSettingsTableViewController.h"
#import "VLCCloudServicesTVViewController.h" #import "VLCCloudServicesTVViewController.h"
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
{ {
UITabBarController *_mainViewController; UITabBarController *_mainViewController;
VLCServerListTVTableViewController *_localNetworkVC; VLCServerListTVViewController *_localNetworkVC;
VLCCloudServicesTVViewController *_cloudServicesVC; VLCCloudServicesTVViewController *_cloudServicesVC;
VLCOpenNetworkStreamTVViewController *_openNetworkVC; VLCOpenNetworkStreamTVViewController *_openNetworkVC;
VLCSettingsTableViewController *_settingsTableVC; VLCSettingsTableViewController *_settingsTableVC;
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
[defaults registerDefaults:appDefaults]; [defaults registerDefaults:appDefaults];
} }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_localNetworkVC = [[VLCServerListTVTableViewController alloc] initWithNibName:nil bundle:nil]; _localNetworkVC = [[VLCServerListTVViewController alloc] initWithNibName:nil bundle:nil];
_cloudServicesVC = [[VLCCloudServicesTVViewController alloc] initWithNibName:nil bundle:nil]; _cloudServicesVC = [[VLCCloudServicesTVViewController alloc] initWithNibName:nil bundle:nil];
_openNetworkVC = [[VLCOpenNetworkStreamTVViewController alloc] initWithNibName:nil bundle:nil]; _openNetworkVC = [[VLCOpenNetworkStreamTVViewController alloc] initWithNibName:nil bundle:nil];
_settingsTableVC = [[VLCSettingsTableViewController alloc] initWithNibName:nil bundle:nil]; _settingsTableVC = [[VLCSettingsTableViewController alloc] initWithNibName:nil bundle:nil];
......
...@@ -10,9 +10,10 @@ ...@@ -10,9 +10,10 @@
*****************************************************************************/ *****************************************************************************/
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "VLCRemoteBrowsingCollectionViewController.h"
#import "VLCLocalServerDiscoveryController.h" #import "VLCLocalServerDiscoveryController.h"
@interface VLCServerListTVTableViewController : UITableViewController <VLCLocalServerDiscoveryControllerDelegate> @interface VLCServerListTVViewController : VLCRemoteBrowsingCollectionViewController <VLCLocalServerDiscoveryControllerDelegate>
@property (nonatomic) VLCLocalServerDiscoveryController *discoveryController; @property (nonatomic) VLCLocalServerDiscoveryController *discoveryController;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Refer to the COPYING file of the official project for license. * Refer to the COPYING file of the official project for license.
*****************************************************************************/ *****************************************************************************/
#import "VLCServerListTVTableViewController.h" #import "VLCServerListTVViewController.h"
#import "VLCLocalNetworkServerTVCell.h" #import "VLCLocalNetworkServerTVCell.h"
#import "VLCServerBrowsingTVViewController.h" #import "VLCServerBrowsingTVViewController.h"
#import "VLCNetworkServerLoginInformation.h" #import "VLCNetworkServerLoginInformation.h"
...@@ -29,22 +29,30 @@ ...@@ -29,22 +29,30 @@
#import "VLCLocalNetworkServiceBrowserDSM.h" #import "VLCLocalNetworkServiceBrowserDSM.h"
#import "VLCLocalNetworkServiceBrowserHTTP.h" #import "VLCLocalNetworkServiceBrowserHTTP.h"
@interface VLCServerListTVTableViewController () #import "VLCRemoteBrowsingTVCell.h"
@interface VLCServerListTVViewController ()
{ {
UILabel *_nothingFoundLabel; UILabel *_nothingFoundLabel;
} }
@property (nonatomic) NSArray <NSIndexPath *> *indexPaths;
@end @end
@implementation VLCServerListTVTableViewController @implementation VLCServerListTVViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
return [super initWithNibName:@"VLCRemoteBrowsingCollectionViewController" bundle:nil];
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeAll ^ UIRectEdgeTop; self.edgesForExtendedLayout = UIRectEdgeAll ^ UIRectEdgeTop;
UINib *nib = [UINib nibWithNibName:@"VLCLocalNetworkServerTVCell" bundle:nil]; UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
[self.tableView registerNib:nib forCellReuseIdentifier:VLCLocalServerTVCell]; flowLayout.itemSize = CGSizeMake(200, 300);
self.tableView.rowHeight = 150;
_nothingFoundLabel = [[UILabel alloc] init]; _nothingFoundLabel = [[UILabel alloc] init];
_nothingFoundLabel.text = NSLocalizedString(@"NO_SERVER_FOUND", nil); _nothingFoundLabel.text = NSLocalizedString(@"NO_SERVER_FOUND", nil);
...@@ -103,49 +111,41 @@ ...@@ -103,49 +111,41 @@
[self.discoveryController stopDiscovery]; [self.discoveryController stopDiscovery];
} }
#pragma mark - Table view data source #pragma mark - Collection view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.discoveryController.numberOfSections;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
VLCLocalServerDiscoveryController *discoverer = self.discoveryController; {
if (discoverer.numberOfSections > 1 && [discoverer numberOfItemsInSection:section] > 0) { return self.indexPaths.count;
return [self.discoveryController titleForSection:section];
}
return nil;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath
return [self.discoveryController numberOfItemsInSection:section]; {
} VLCRemoteBrowsingTVCell *browsingCell = (VLCRemoteBrowsingTVCell *) [collectionView dequeueReusableCellWithReuseIdentifier:VLCRemoteBrowsingTVCellIdentifier forIndexPath:indexPath];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *discoveryIndexPath = self.indexPaths[indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:VLCLocalServerTVCell forIndexPath:indexPath]; id<VLCLocalNetworkService> service = [self.discoveryController networkServiceForIndexPath:discoveryIndexPath];
id<VLCLocalNetworkService> service = [self.discoveryController networkServiceForIndexPath:indexPath];
cell.textLabel.text = service.title;
cell.imageView.image = service.icon ? service.icon : [UIImage imageNamed:@"serverIcon"];
return cell;
}
- (void)showWIP:(NSString *)todo { browsingCell.isDirectory = YES;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Work in Progress\nFeature not (yet) implemented." browsingCell.title = service.title;
message:todo browsingCell.subtitle = [self.discoveryController titleForSection:discoveryIndexPath.section];
preferredStyle:UIAlertControllerStyleAlert]; browsingCell.subtitleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
browsingCell.thumbnailImage = service.icon ? service.icon : [UIImage imageNamed:@"serverIcon"];
[alertController addAction:[UIAlertAction actionWithTitle:@"Please fix this!" return browsingCell;
style:UIAlertActionStyleDefault }
handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Nevermind" - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
style:UIAlertActionStyleCancel {
handler:nil]]; NSIndexPath *discoveryIndexPath = self.indexPaths[indexPath.row];
[self presentViewController:alertController animated:YES completion:nil]; id<VLCLocalNetworkService> service = [self.discoveryController networkServiceForIndexPath:discoveryIndexPath];
[self didSelectService:service];
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
id<VLCLocalNetworkService> service = [self.discoveryController networkServiceForIndexPath:indexPath]; #pragma mark - Service specific stuff
- (void)didSelectService:(id<VLCLocalNetworkService>)service
{
if ([service respondsToSelector:@selector(serverBrowser)]) { if ([service respondsToSelector:@selector(serverBrowser)]) {
id <VLCNetworkServerBrowser> browser = [service serverBrowser]; id <VLCNetworkServerBrowser> browser = [service serverBrowser];
if (browser) { if (browser) {
...@@ -264,7 +264,19 @@ ...@@ -264,7 +264,19 @@
#pragma mark - VLCLocalServerDiscoveryController #pragma mark - VLCLocalServerDiscoveryController
- (void)discoveryFoundSomethingNew - (void)discoveryFoundSomethingNew
{ {
[self.tableView reloadData]; NSMutableArray<NSIndexPath *> *indexPaths = [NSMutableArray array];
VLCLocalServerDiscoveryController *discoveryController = self.discoveryController;
NSUInteger sectionCount = [discoveryController numberOfSections];
for (NSUInteger section = 0; section < sectionCount; ++section) {
NSUInteger itemsCount = [discoveryController numberOfItemsInSection:section];
for (NSUInteger index = 0; index < itemsCount; ++index) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:section];
[indexPaths addObject:indexPath];
}
}
self.indexPaths = [indexPaths copy];
[self.collectionView reloadData];
_nothingFoundLabel.hidden = self.discoveryController.foundAnythingAtAll; _nothingFoundLabel.hidden = self.discoveryController.foundAnythingAtAll;
} }
......
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
DDEAECC61BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */; }; DDEAECC61BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */; };
DDEAECC71BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */; }; DDEAECC71BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */; };
DDEAECCD1BDECCB800756C83 /* VLCNetworkListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECCC1BDECCB800756C83 /* VLCNetworkListViewController.m */; }; DDEAECCD1BDECCB800756C83 /* VLCNetworkListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECCC1BDECCB800756C83 /* VLCNetworkListViewController.m */; };
DDEAECF11BDFE9E800756C83 /* VLCServerListTVTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECEC1BDFE99200756C83 /* VLCServerListTVTableViewController.m */; }; DDEAECF11BDFE9E800756C83 /* VLCServerListTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECEC1BDFE99200756C83 /* VLCServerListTVViewController.m */; };
DDEAECF61BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDEAECF51BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib */; }; DDEAECF61BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDEAECF51BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib */; };
DDEAECF71BDFEB0200756C83 /* VLCLocalNetworkServerTVCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECF31BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.m */; }; DDEAECF71BDFEB0200756C83 /* VLCLocalNetworkServerTVCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECF31BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.m */; };
DDEAECFE1BDFFAEE00756C83 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E6183A99E1009EE944 /* Reachability.m */; }; DDEAECFE1BDFFAEE00756C83 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E6183A99E1009EE944 /* Reachability.m */; };
...@@ -1004,8 +1004,8 @@ ...@@ -1004,8 +1004,8 @@
DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLocalNetworkServiceBrowserSAP.m; sourceTree = "<group>"; }; DDEAECC51BDEC79D00756C83 /* VLCLocalNetworkServiceBrowserSAP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLocalNetworkServiceBrowserSAP.m; sourceTree = "<group>"; };
DDEAECCB1BDECCB800756C83 /* VLCNetworkListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkListViewController.h; path = Sources/LocalNetworkConnectivity/VLCNetworkListViewController.h; sourceTree = SOURCE_ROOT; }; DDEAECCB1BDECCB800756C83 /* VLCNetworkListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkListViewController.h; path = Sources/LocalNetworkConnectivity/VLCNetworkListViewController.h; sourceTree = SOURCE_ROOT; };
DDEAECCC1BDECCB800756C83 /* VLCNetworkListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkListViewController.m; path = Sources/LocalNetworkConnectivity/VLCNetworkListViewController.m; sourceTree = SOURCE_ROOT; }; DDEAECCC1BDECCB800756C83 /* VLCNetworkListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkListViewController.m; path = Sources/LocalNetworkConnectivity/VLCNetworkListViewController.m; sourceTree = SOURCE_ROOT; };
DDEAECEB1BDFE99200756C83 /* VLCServerListTVTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCServerListTVTableViewController.h; sourceTree = "<group>"; }; DDEAECEB1BDFE99200756C83 /* VLCServerListTVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCServerListTVViewController.h; sourceTree = "<group>"; };
DDEAECEC1BDFE99200756C83 /* VLCServerListTVTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCServerListTVTableViewController.m; sourceTree = "<group>"; }; DDEAECEC1BDFE99200756C83 /* VLCServerListTVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCServerListTVViewController.m; sourceTree = "<group>"; };
DDEAECF21BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLocalNetworkServerTVCell.h; sourceTree = "<group>"; }; DDEAECF21BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLocalNetworkServerTVCell.h; sourceTree = "<group>"; };
DDEAECF31BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLocalNetworkServerTVCell.m; sourceTree = "<group>"; }; DDEAECF31BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLocalNetworkServerTVCell.m; sourceTree = "<group>"; };
DDEAECF51BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCLocalNetworkServerTVCell.xib; sourceTree = "<group>"; }; DDEAECF51BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCLocalNetworkServerTVCell.xib; sourceTree = "<group>"; };
...@@ -1721,8 +1721,8 @@ ...@@ -1721,8 +1721,8 @@
7DEC8BE31BD68882006E1093 /* Network UI */ = { 7DEC8BE31BD68882006E1093 /* Network UI */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
DDEAECEB1BDFE99200756C83 /* VLCServerListTVTableViewController.h */, DDEAECEB1BDFE99200756C83 /* VLCServerListTVViewController.h */,
DDEAECEC1BDFE99200756C83 /* VLCServerListTVTableViewController.m */, DDEAECEC1BDFE99200756C83 /* VLCServerListTVViewController.m */,
DDDEA6AD1BE027FA000BB7A2 /* VLCServerBrowsingTVViewController.h */, DDDEA6AD1BE027FA000BB7A2 /* VLCServerBrowsingTVViewController.h */,
DDDEA6AE1BE027FA000BB7A2 /* VLCServerBrowsingTVViewController.m */, DDDEA6AE1BE027FA000BB7A2 /* VLCServerBrowsingTVViewController.m */,
DDEAECF21BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.h */, DDEAECF21BDFEAE300756C83 /* VLCLocalNetworkServerTVCell.h */,
...@@ -2647,7 +2647,7 @@ ...@@ -2647,7 +2647,7 @@
DD3EFF361BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserNetService.m in Sources */, DD3EFF361BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserNetService.m in Sources */,
7D51B3B01BF0EEF4005AF4D5 /* VLCPlaybackInfoMediaInfoTVViewController.m in Sources */, 7D51B3B01BF0EEF4005AF4D5 /* VLCPlaybackInfoMediaInfoTVViewController.m in Sources */,
7D13347C1BE132EA0012E919 /* VLCLocalNetworkServiceBrowserUPnP.m in Sources */, 7D13347C1BE132EA0012E919 /* VLCLocalNetworkServiceBrowserUPnP.m in Sources */,
DDEAECF11BDFE9E800756C83 /* VLCServerListTVTableViewController.m in Sources */, DDEAECF11BDFE9E800756C83 /* VLCServerListTVViewController.m in Sources */,
7DEC8BDE1BD67899006E1093 /* VLCFullscreenMovieTVViewController.m in Sources */, 7DEC8BDE1BD67899006E1093 /* VLCFullscreenMovieTVViewController.m in Sources */,
DD3EFF501BDEBCE500B68579 /* VLCPlexParser.m in Sources */, DD3EFF501BDEBCE500B68579 /* VLCPlexParser.m in Sources */,
7D405ED31BEA11CD006ED886 /* VLCHTTPUploaderController.m in Sources */, 7D405ED31BEA11CD006ED886 /* VLCHTTPUploaderController.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