Commit 51760d65 authored by Carola Nitz's avatar Carola Nitz

Remove RESideMenu, MenuTableViewController, SidebarViewCell, SidebarController and references

parent fad3d687
......@@ -17,7 +17,6 @@ def iOS_pods
pod 'OBSlider', '1.1.0'
pod 'InAppSettingsKit', :git => 'git://github.com/fkuehne/InAppSettingsKit.git', :commit => '415ea6bb' #tvOS fix
pod 'HockeySDK', '~>5.1.2', :subspecs => ['CrashOnlyLib']
pod 'RESideMenu', '~>4.0.7'
pod 'PAPasscode', '~>1.0'
pod 'GoogleAPIClient/Drive'
pod 'VLC-LXReorderableCollectionViewFlowLayout', '0.1.3v'
......
......@@ -51,7 +51,6 @@ PODS:
- AFNetworking
- xmlrpc
- PAPasscode (1.0)
- RESideMenu (4.0.7)
- SwiftLint (0.25.0)
- TVVLCKit (3.0.2)
- upnpx (1.4.0)
......@@ -79,7 +78,6 @@ DEPENDENCIES:
- OBSlider (= 1.1.0)
- OROpenSubtitleDownloader (from `https://github.com/orta/OROpenSubtitleDownloader.git`, commit `0509eac2`)
- PAPasscode (~> 1.0)
- RESideMenu (~> 4.0.7)
- SwiftLint (~> 0.25.0)
- TVVLCKit (= 3.0.2)
- upnpx (~> 1.4.0)
......@@ -140,7 +138,6 @@ SPEC CHECKSUMS:
OBSlider: 490f108007bfdd5414a38650b211fe403a95b8a0
OROpenSubtitleDownloader: 154b8c08acbf8836b77ac259018dc8b5baef907e
PAPasscode: b408fb87c530cad58a554e26482e87dbb14b7bc2
RESideMenu: f24c508404b49c667344c54aba7e590883533958
SwiftLint: e14651157288e9e01d6e1a71db7014fb5744a8ea
TVVLCKit: 178e4f82f8b57320774821384e42eaac403d2faa
upnpx: c695b99229e08154d23abe5c252cb64f1600f35d
......@@ -150,6 +147,6 @@ SPEC CHECKSUMS:
XKKeychain: 852ef663c56a7194c73d3c68e8d9d4f07b121d4f
xmlrpc: 109bb21d15ed6d108b2c1ac5973a6a223a50f5f4
PODFILE CHECKSUM: 7049ed97875cfde471396ccb609af0afd165ef7d
PODFILE CHECKSUM: c8dbb4c0b180876fb032d297e7e1ca3dbf736b6b
COCOAPODS: 1.4.0
......@@ -54,9 +54,6 @@ Copyright &copy; 2011, Deusty, LLC - <a href="#bsd2clause">2-clause BSD License<
&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/TheHungryBu/dropbox-sdk-obj-c">Dropbox for Objective-C</a><br />
Copyright &copy; 2015-2017 Dropbox Inc. - <a href="#mit">MIT License</a><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/romaonthego/RESideMenu">RESideMenu</a><br />
Copyright &copy; 2013 Roman Efimov - <a href="#mit">MIT License</a><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://code.google.com/p/google-api-objectivec-client/">Google APIs Client Library for Objective-C</a><br />
Copyright &copy; 2011-2017 Google Inc. - <a href="#apache2">Apache 2 License</a><br />
<br />
......@@ -69,9 +66,6 @@ Copyright &copy; 2009-2014 Luc Vandal, Edovia Inc., Ortwin Gentz, FutureTap GmbH
&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/liveservices/LiveSDK-for-iOS">Live SDK for iOS</a><br />
Copyright &copy; 2014 Microsoft Corporation - <a href="#apache2">Apache 2 License</a><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/lxcid/LXReorderableCollectionViewFlowLayout">LXReorderableCollectionViewFlowLayout</a><br />
Copyright &copy; 2012 Stan Chang Khin Boon and contributors - <a href="#mit">MIT License</a><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/ole/OBSlider">OBSlider</a><br />
Copyright &copy; 2011 Ole Begemann and contributors - <a href="#mit">MIT License</a><br />
<br />
......
......@@ -24,7 +24,6 @@
#import "UIColor+Presets.h"
#import "UIBarButtonItem+Theme.h"
#import "VLCAlertView.h"
#import "VLCSidebarController.h"
#import "UIViewController+VLCAlert.h"
#ifndef NDEBUG
......
......@@ -14,7 +14,6 @@
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCMenuTableViewController.h"
#import "VLCWatchCommunication.h"
#import <AppAuth/AppAuth.h>
......
......@@ -409,7 +409,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
[[VLCSidebarController sharedInstance] performActionForShortcutItem:shortcutItem];
//TODO: shortcutItem should be implemented
}
#pragma mark - media discovering
......@@ -467,8 +467,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
fileNameOfMedia:(NSString *)fileName
{
[[VLCDownloadViewController sharedInstance] addURLToDownloadList:url fileNameOfMedia:fileName];
[[VLCSidebarController sharedInstance] selectRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1]
scrollPosition:UITableViewScrollPositionNone];
//TODO: open DownloadViewController
}
#pragma mark - playback
......
......@@ -53,11 +53,6 @@
{
documentPicker.delegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // on iPhone it's done in menu table vc
[[VLCSidebarController sharedInstance] selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
scrollPosition:UITableViewScrollPositionNone];
}
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:documentPicker animated:YES completion:nil];
}
......
/*****************************************************************************
* VLCMenuButton.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Gleb Pinigin <gpinigin # gmail.com>
* Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface VLCMenuButton : UIButton
@end
/*****************************************************************************
* VLCMenuButton.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Gleb Pinigin <gpinigin # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCMenuButton.h"
@implementation VLCMenuButton
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
UIImage *background = [[UIImage imageNamed:@"menuButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
[self setBackgroundImage:background forState:UIControlStateNormal];
}
return self;
}
@end
/*****************************************************************************
* VLCMenuTableViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 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 VLCMenuTableViewController : UIViewController
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
@end
/*****************************************************************************
* VLCMenuTableViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Gleb Pinigin <gpinigin # gmail.com>
* Jean-Romain Prévost <jr # 3on.fr>
* Carola Nitz <nitz.carola # googlemail.com>
* Tamas Timar <ttimar.vlc # gmail.com>
* Pierre Sagaspe <pierre.sagaspe # me.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCMenuTableViewController.h"
#import "VLCSidebarViewCell.h"
#import <QuartzCore/QuartzCore.h>
#import "VLCWiFiUploadTableViewCell.h"
#import "VLCDownloadViewController.h"
#import "VLCServerListViewController.h"
#import "VLCOpenNetworkStreamViewController.h"
#import "VLCSettingsController.h"
#import "VLCAboutViewController.h"
#import "VLCBugreporter.h"
#import "VLCCloudServicesTableViewController.h"
#import "VLC_iOS-Swift.h"
#define ROW_HEIGHT 50.
#define IPAD_ROW_HEIGHT 65.
#define HEADER_HEIGHT 22.
#define MENU_WIDTH 320.
#define TOP_PADDING 20.
#define STANDARD_PADDING 8.
#define MAX_LEFT_INSET 170.
#define COMPACT_INSET 20.
static NSString *CellIdentifier = @"VLCMenuCell";
static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
@interface VLCMenuTableViewController () <UITableViewDataSource, UITableViewDelegate, VLCMediaViewControllerDelegate>
{
NSArray *_sectionHeaderTexts;
NSArray *_menuItemsSectionOne;
NSArray *_menuItemsSectionTwo;
NSArray *_menuItemsSectionThree;
UITableView *_menuTableView;
NSLayoutConstraint *_heightConstraint;
NSLayoutConstraint *_leftTableConstraint;
VLCSettingsController *_settingsController;
VLCMediaViewController *_videoViewController;
}
@end
@implementation VLCMenuTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_sectionHeaderTexts = @[@"SECTION_HEADER_LIBRARY", @"SECTION_HEADER_NETWORK", @"Settings"];
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES", @"LIBRARY_MUSIC", @"LIBRARY_SERIES"];
_menuItemsSectionTwo = @[@"LOCAL_NETWORK", @"NETWORK_TITLE", @"DOWNLOAD_FROM_HTTP", @"WEBINTF_TITLE", @"CLOUD_SERVICES"];
_menuItemsSectionThree = @[@"Settings", @"ABOUT_APP"];
_menuTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_menuTableView.delegate = self;
_menuTableView.dataSource = self;
_menuTableView.backgroundColor = [UIColor VLCMenuBackgroundColor];
_menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_menuTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_menuTableView.rowHeight = UITableViewAutomaticDimension;
_menuTableView.sectionHeaderHeight = UITableViewAutomaticDimension;
_menuTableView.estimatedSectionHeaderHeight = HEADER_HEIGHT;
_menuTableView.estimatedRowHeight = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? IPAD_ROW_HEIGHT : ROW_HEIGHT;
_menuTableView.scrollsToTop = NO;
_menuTableView.translatesAutoresizingMaskIntoConstraints = NO;
_menuTableView.showsHorizontalScrollIndicator = NO;
_menuTableView.showsVerticalScrollIndicator = NO;
[_menuTableView registerClass:[VLCWiFiUploadTableViewCell class] forCellReuseIdentifier:WiFiCellIdentifier];
[_menuTableView registerClass:[VLCSidebarViewCell class] forCellReuseIdentifier:CellIdentifier];
[self.view addSubview:_menuTableView];
NSDictionary *dict;
dict = NSDictionaryOfVariableBindings(_menuTableView);
NSDictionary *metrics = @{@"TopPadding": @(TOP_PADDING),
@"Standard": @(STANDARD_PADDING),
@"menuWidth" : @(MENU_WIDTH)
};
// 20 to avoid seeing the tableview above the first sectionheader
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|->=TopPadding-[_menuTableView]->=Standard-|" options:0 metrics:metrics views:dict]];
_heightConstraint = [NSLayoutConstraint constraintWithItem:_menuTableView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0 constant:0];
_heightConstraint.priority = UILayoutPriorityRequired -1;
[self.view addConstraint:_heightConstraint];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:_menuTableView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
_leftTableConstraint = [NSLayoutConstraint constraintWithItem:_menuTableView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0];
[self.view addConstraint:_leftTableConstraint];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|->=0-[_menuTableView(==menuWidth)]" options:0 metrics:metrics views:dict]];
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
}
- (BOOL)shouldAutorotate
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
return (orientation == UIInterfaceOrientationPortraitUpsideDown) ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) : YES;
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
_heightConstraint.constant = MIN(_menuTableView.contentSize.height, self.view.frame.size.height-TOP_PADDING-STANDARD_PADDING);
_leftTableConstraint.constant = MAX((self.view.frame.size.width*2 /3.0 - _menuTableView.frame.size.width)/2.0, STANDARD_PADDING);
}
#pragma mark - table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) // media
return _menuItemsSectionOne.count;
else if (section == 1) // network
return _menuItemsSectionTwo.count;
else if (section == 2) // settings & co
return _menuItemsSectionThree.count;
else
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *rawTitle;
NSUInteger section = indexPath.section;
if (section == 0)
rawTitle = _menuItemsSectionOne[indexPath.row];
else if(section == 1)
rawTitle = _menuItemsSectionTwo[indexPath.row];
else if(section == 2)
rawTitle = _menuItemsSectionThree[indexPath.row];
UITableViewCell *cell;
if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
cell = (VLCWiFiUploadTableViewCell *)[tableView dequeueReusableCellWithIdentifier:WiFiCellIdentifier];
} else {
cell = (VLCSidebarViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}
if (section == 0) {
if ([rawTitle isEqualToString:@"LIBRARY_ALL_FILES"])
cell.imageView.image = [UIImage imageNamed:@"AllFiles"];
else if ([rawTitle isEqualToString:@"LIBRARY_MUSIC"])
cell.imageView.image = [UIImage imageNamed:@"MusicAlbums"];
else if ([rawTitle isEqualToString:@"LIBRARY_SERIES"])
cell.imageView.image = [UIImage imageNamed:@"TVShowsIcon"];
} else if (section == 1) {
if ([rawTitle isEqualToString:@"LOCAL_NETWORK"])
cell.imageView.image = [UIImage imageNamed:@"Local"];
else if ([rawTitle isEqualToString:@"NETWORK_TITLE"])
cell.imageView.image = [UIImage imageNamed:@"OpenNetStream"];
else if ([rawTitle isEqualToString:@"DOWNLOAD_FROM_HTTP"])
cell.imageView.image = [UIImage imageNamed:@"Downloads"];
else if ([rawTitle isEqualToString:@"CLOUD_SERVICES"])
cell.imageView.image = [UIImage imageNamed:@"iCloudIcon"];
} else if (section == 2) {
if ([rawTitle isEqualToString:@"Settings"])
cell.imageView.image = [UIImage imageNamed:@"Settings"];
else
cell.imageView.image = [UIImage imageNamed:@"menuCone"];
}
if (![rawTitle isEqualToString:@"WEBINTF_TITLE"])
cell.textLabel.text = NSLocalizedString(rawTitle, nil);
return cell;
}
#pragma mark - table view delegation
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *headerText = NSLocalizedString(_sectionHeaderTexts[section], nil);
UIView *headerView = nil;
if (headerText) {
headerView = [[UIView alloc] initWithFrame:CGRectZero];
headerView.backgroundColor = [UIColor VLCMenuBackgroundColor];
UILabel *textLabel = [UILabel new];
textLabel.text = headerText;
textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont systemFontSize]];
textLabel.textColor = [UIColor whiteColor];
textLabel.backgroundColor = [UIColor VLCMenuBackgroundColor];
[textLabel sizeToFit];
textLabel.translatesAutoresizingMaskIntoConstraints = NO;
[headerView addSubview:textLabel];
UIView *bottomLine = [UIView new];
bottomLine.backgroundColor = [UIColor whiteColor];
bottomLine.translatesAutoresizingMaskIntoConstraints = NO;
[headerView addSubview:bottomLine];
NSDictionary *dict = NSDictionaryOfVariableBindings(textLabel,bottomLine);
[headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[bottomLine]|" options:0 metrics:0 views:dict]];
[headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(12)-[textLabel]" options:0 metrics:0 views:dict]];
[headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|->=0-[textLabel(==22)]->=0-[bottomLine(0.5)]|" options:0 metrics:0 views:dict]];
}
return headerView;
}
#pragma mark - menu implementation
- (VLCSettingsController *)settingsController
{
if (!_settingsController){
_settingsController = [[VLCSettingsController alloc] initWithStyle:UITableViewStyleGrouped];
}
return _settingsController;
}
- (VLCMediaViewController *)videoViewController
{
if (!_videoViewController) {
_videoViewController = [[VLCMediaViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
}
return _videoViewController;
}
- (void)_revealItem:(NSUInteger)itemIndex inSection:(NSUInteger)sectionNumber
{
UIViewController *viewController;
if (sectionNumber == 1) {
if (itemIndex == 0)
viewController = [[VLCServerListViewController alloc] init];
else if (itemIndex == 1) {
viewController = [[VLCOpenNetworkStreamViewController alloc] initWithNibName:@"VLCOpenNetworkStreamViewController" bundle:nil];
} else if (itemIndex == 2)
viewController = [VLCDownloadViewController sharedInstance];
else if (itemIndex == 3)
[((VLCWiFiUploadTableViewCell *)[_menuTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:itemIndex inSection:sectionNumber]]) toggleHTTPServer];
else if (itemIndex == 4)
viewController = [[VLCCloudServicesTableViewController alloc] initWithNibName:@"VLCCloudServicesTableViewController" bundle:nil];
} else if (sectionNumber == 2) {
if (itemIndex == 0) {
viewController = self.settingsController;
} else if (itemIndex == 1)
viewController = [[VLCAboutViewController alloc] init];
} else {
viewController = self.videoViewController;
}
if (!viewController) {
APLog(@"no view controller found for menu item");
return;
}
VLCSidebarController *sidebarController = [VLCSidebarController sharedInstance];
if ([sidebarController.contentViewController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navCon = (UINavigationController*)sidebarController.contentViewController;
navCon.viewControllers = @[viewController];
} else
sidebarController.contentViewController = [[UINavigationController alloc] initWithRootViewController:viewController];
[sidebarController hideSidebar];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self _revealItem:indexPath.row inSection:indexPath.section];
}
#pragma mark Public Methods
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
{
[_menuTableView selectRowAtIndexPath:indexPath animated:animated scrollPosition:scrollPosition];
if (scrollPosition == UITableViewScrollPositionNone)
[_menuTableView scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
[self _revealItem:indexPath.row inSection:indexPath.section];
}
#pragma mark - shake for support
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
[[VLCBugreporter sharedInstance] handleBugreportRequest];
}
#pragma mark - VLCMediaViewControllerDelegate
- (void)videoViewControllerDidSelectMediaObjectWithVLCMediaViewController:(VLCMediaViewController *)VLCMediaViewController mediaObject:(NSManagedObject *)mediaObject
{
}
- (void)videoViewControllerDidSelectBackbuttonWithVLCMediaViewController:(VLCMediaViewController *)VLCMediaViewController {
[[VLCSidebarController sharedInstance] toggleSidebar];
}
@end
......@@ -15,7 +15,6 @@
#import "VLCOpenNetworkStreamViewController.h"
#import "VLCPlaybackController.h"
#import "VLCLibraryViewController.h"
#import "VLCMenuTableViewController.h"
#import "VLCStreamingHistoryCell.h"
#import "UIDevice+VLC.h"
#import "VLC_iOS-Swift.h"
......
......@@ -18,7 +18,7 @@
#import <LocalAuthentication/LocalAuthentication.h>
#import "VLC_iOS-Swift.h"
@interface VLCSettingsController ()<PAPasscodeViewControllerDelegate, IASKSettingsDelegate>
@interface VLCSettingsController ()<PAPasscodeViewControllerDelegate>
@end
......@@ -120,10 +120,6 @@
#pragma mark - IASKSettings delegate
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender
{
[[VLCSidebarController sharedInstance] toggleSidebar];
}
#pragma mark - PAPasscode delegate
......
/*****************************************************************************
* VLCSidebarController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Author: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <Foundation/Foundation.h>
@interface VLCSidebarController : NSObject
+ (instancetype)sharedInstance;
- (void)hideSidebar;
- (void)toggleSidebar;
- (void)resizeContentView;
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath scrollPosition:(UITableViewScrollPosition)scrollPosition;
- (void)performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem;
@property (readonly) UIViewController *fullViewController;
@property (readwrite, retain) UIViewController *contentViewController;
@end
/*****************************************************************************
* VLCSidebarController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Author: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCSidebarController.h"
#import "VLCMenuTableViewController.h"
#import "UIViewController+RESideMenu.h"
#import "RESideMenu.h"
#import "UIDevice+VLC.h"
@interface VLCSidebarController() <RESideMenuDelegate>
{
RESideMenu *_sideMenuViewController;
VLCMenuTableViewController *_menuViewController;
UIViewController *_contentViewController;
BOOL _menuVisible;
}
@end
@implementation VLCSidebarController
+ (instancetype)sharedInstance
{
static VLCSidebarController *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCSidebarController new];
});
return sharedInstance;
}
- (instancetype)init
{
self = [super init];
if (!self)
return self;
_menuViewController = [[VLCMenuTableViewController alloc] initWithNibName:nil bundle:nil];
if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
_sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:nil
leftMenuViewController:_menuViewController
rightMenuViewController:nil];
} else {
_sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:nil
leftMenuViewController:nil
rightMenuViewController:_menuViewController];
}
_sideMenuViewController.backgroundImage = [UIImage imageNamed:@"menu-background"];
_sideMenuViewController.delegate = self;
return self;
}
#pragma mark - VC handling
- (UIViewController *)fullViewController
{
return _sideMenuViewController;
}
- (void)setContentViewController:(UIViewController *)contentViewController
{
contentViewController.view.backgroundColor = [UIColor VLCMenuBackgroundColor];
_sideMenuViewController.contentViewController = contentViewController;
}
- (UIViewController *)contentViewController
{
return _sideMenuViewController.contentViewController;
}
#pragma mark - actual work
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath scrollPosition:(UITableViewScrollPosition)scrollPosition
{
[_menuViewController selectRowAtIndexPath:indexPath
animated:NO
scrollPosition:scrollPosition];
}
- (void)hideSidebar
{
_menuVisible = NO;
[_sideMenuViewController hideMenuViewController];
}
- (void)toggleSidebar
{
_menuVisible = YES;
if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
[_sideMenuViewController presentLeftMenuViewController];
} else {
[_sideMenuViewController presentRightMenuViewController];
}
}
- (void)resizeContentView
{
if (_menuVisible) {
[self hideSidebar];
[self toggleSidebar];
}
}
- (void)performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem
{
NSString *itemType = shortcutItem.type;
if ([itemType isEqualToString:kVLCApplicationShortcutLocalLibrary]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutLocalServers]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutOpenNetworkStream]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutClouds]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:4 inSection:1] scrollPosition:UITableViewScrollPositionNone];
}
}
#pragma mark - RESideMenu Delegate
- (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController
{
_menuVisible = NO;
}
@end
/*****************************************************************************
* VLCSidebarViewCell.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 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 VLCSidebarViewCell : UITableViewCell
@end
/*****************************************************************************
* VLCSidebarViewCell.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/