Commit 8156da2c authored by Carola Nitz's avatar Carola Nitz Committed by Felix Paul Kühne

Replace existing sidebar menu with a modern approach (refs #15127)

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent b4cb5a44
......@@ -7,7 +7,6 @@ inhibit_all_warnings!
target 'vlc-ios' do
pod 'OBSlider', '1.1.0'
pod 'GHSidebarNav', '1.0.0'
pod 'InAppSettingsKit', '2.2.2'
pod 'upnpx', '~>1.3.4'
pod 'HockeySDK', '~>3.6.4'
......
......@@ -2,7 +2,6 @@ PODS:
- box-ios-sdk-v2 (1.2.2):
- box-ios-sdk-v2/no-arc (= 1.2.2)
- box-ios-sdk-v2/no-arc (1.2.2)
- GHSidebarNav (1.0.0)
- HockeySDK (3.6.4)
- InAppSettingsKit (2.2.2)
- OBSlider (1.1.0)
......@@ -13,7 +12,6 @@ PODS:
DEPENDENCIES:
- box-ios-sdk-v2 (from `git://github.com/carolanitz/box-ios-sdk-v2.git`, commit
`d2df30aa5f76d30910e06f3ef5aff49025de3cf1`)
- GHSidebarNav (= 1.0.0)
- HockeySDK (~> 3.6.4)
- InAppSettingsKit (= 2.2.2)
- OBSlider (= 1.1.0)
......@@ -33,7 +31,6 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
box-ios-sdk-v2: e6833ca786bf93da1dbe63e3d0a945b1e1fe1f42
GHSidebarNav: b0c7937f3fdc2889025d307036223bc0dd7c3a0d
HockeySDK: c07cdd580296737edcd0963e292c19885a53f563
InAppSettingsKit: 76d5cfbaa3e3f8aa53fe3628516da7eb1aa6a5cb
OBSlider: 490f108007bfdd5414a38650b211fe403a95b8a0
......
......@@ -12,16 +12,8 @@
#import <UIKit/UIKit.h>
@class VLCSettingsController;
@class IASKAppSettingsViewController;
@interface VLCMenuTableViewController : UIViewController
@property (strong, nonatomic) IASKAppSettingsViewController *settingsViewController;
@property (strong, nonatomic) VLCSettingsController *settingsController;
@property (nonatomic, strong) UITableView *tableView;
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
@end
......@@ -29,9 +29,10 @@
#import "VLCBugreporter.h"
#import "VLCCloudServicesTableViewController.h"
#import "VLCNavigationController.h"
#import "GHRevealViewController.h"
#define ROW_HEIGHT 50
#define ROW_HEIGHT 50.
#define HEADER_HEIGHT 22.
static NSString *CellIdentifier = @"VLCMenuCell";
static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
......@@ -42,8 +43,11 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
NSArray *_menuItemsSectionTwo;
NSArray *_menuItemsSectionThree;
NSMutableSet *_hiddenSettingKeys;
UITableView *_menuTableView;
}
@property (strong, nonatomic) IASKAppSettingsViewController *settingsViewController;
@property (strong, nonatomic) VLCSettingsController *settingsController;
@end
......@@ -58,48 +62,36 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
{
[super viewDidLoad];
self.view.frame = CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds));
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
CGRect viewRect = self.view.frame;
_sectionHeaderTexts = @[@"SECTION_HEADER_LIBRARY", @"SECTION_HEADER_NETWORK", @"Settings"];
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES", @"LIBRARY_MUSIC", @"LIBRARY_SERIES"];
_menuItemsSectionTwo = @[@"LOCAL_NETWORK", @"OPEN_NETWORK", @"DOWNLOAD_FROM_HTTP", @"WEBINTF_TITLE", @"CLOUD_SERVICES"];
_menuItemsSectionThree = @[@"Settings", @"ABOUT_APP"];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 44.0f + 20.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds) - (44.0f + 20.0f)) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
_tableView.backgroundColor = [UIColor colorWithRed:(43.0f/255.0f) green:(43.0f/255.0f) blue:(43.0f/255.0f) alpha:1.0f];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_tableView.rowHeight = ROW_HEIGHT;
_tableView.scrollsToTop = NO;
[_tableView registerClass:[VLCWiFiUploadTableViewCell class] forCellReuseIdentifier:WiFiCellIdentifier];
self.view = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds))];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view addSubview:_tableView];
UIView *brandingBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, 64.0f)];
brandingBackgroundView.backgroundColor = [UIColor colorWithRed:0.1608 green:0.1608 blue:0.1608 alpha:1.0000];
[self.view addSubview:brandingBackgroundView];
UIImageView *brandingImageView;
brandingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, 44.0f + 40.0f)];
brandingImageView.contentMode = UIViewContentModeCenter;
brandingImageView.image = [UIImage imageNamed:@"title"];
[self.view addSubview:brandingImageView];
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.view.frame = CGRectMake(0.0f, 0.0f,kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds));
_menuTableView = ({
NSUInteger count = _menuItemsSectionOne.count + _menuItemsSectionTwo.count + _menuItemsSectionThree.count;
CGFloat height = (count * ROW_HEIGHT) + (3. * HEADER_HEIGHT);
CGFloat top = ([UIScreen mainScreen].bounds.size.height - height) / 2.;
UITableView *tableView = [[UITableView alloc] initWithFrame:
CGRectMake(20., top, viewRect.size.width - 20., height)
style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundColor = [UIColor clearColor];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
tableView.rowHeight = ROW_HEIGHT;
tableView.scrollsToTop = NO;
tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
tableView;
});
[self.view addSubview:_menuTableView];
[_menuTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
}
- (BOOL)shouldAutorotate
......@@ -134,7 +126,6 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *rawTitle;
NSUInteger section = indexPath.section;
if (section == 0)
......@@ -147,6 +138,9 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
UITableViewCell *cell;
if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
cell = (VLCWiFiUploadTableViewCell *)[tableView dequeueReusableCellWithIdentifier:WiFiCellIdentifier];
if (cell == nil) {
cell = [[VLCWiFiUploadTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:WiFiCellIdentifier];
}
} else {
cell = (VLCSidebarViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
......@@ -186,34 +180,35 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section < 3)
return 21.f;
return 22.f;
return 0.;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSObject *headerText = NSLocalizedString(_sectionHeaderTexts[section], nil);
NSString *headerText = NSLocalizedString(_sectionHeaderTexts[section], nil);
UIView *headerView = nil;
if (headerText != [NSNull null]) {
headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 21.0f)];
headerView.backgroundColor = [UIColor VLCDarkBackgroundColor];
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectInset(headerView.bounds, 12.0f, 5.0f)];
textLabel.text = (NSString *) headerText;
textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:([UIFont systemFontSize] * 0.8f)];
textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
textLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
textLabel.textColor = [UIColor colorWithRed:(118.0f/255.0f) green:(118.0f/255.0f) blue:(118.0f/255.0f) alpha:1.0f];
if (headerText) {
headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, HEADER_HEIGHT)];
UILabel *textLabel = [UILabel new];
textLabel.text = headerText;
textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont systemFontSize]];
textLabel.textColor = [UIColor whiteColor];
textLabel.backgroundColor = [UIColor clearColor];
[textLabel sizeToFit];
textLabel.translatesAutoresizingMaskIntoConstraints = NO;
[headerView addSubview:textLabel];
UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
topLine.backgroundColor = [UIColor colorWithRed:(95.0f/255.0f) green:(95.0f/255.0f) blue:(95.0f/255.0f) alpha:1.0f];
[headerView addSubview:topLine];
UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 21.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
bottomLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
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]->=0-[bottomLine(0.5)]|" options:0 metrics:0 views:dict]];
}
return headerView;
}
......@@ -232,7 +227,7 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
} else if (itemIndex == 2)
viewController = [VLCDownloadViewController sharedInstance];
else if (itemIndex == 3)
[((VLCWiFiUploadTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:itemIndex inSection:sectionNumber]]) toggleHTTPServer];
[((VLCWiFiUploadTableViewCell *)[_menuTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:itemIndex inSection:sectionNumber]]) toggleHTTPServer];
else if (itemIndex == 4)
viewController = [[VLCCloudServicesTableViewController alloc] initWithNibName:@"VLCCloudServicesTableViewController" bundle:nil];
} else if (sectionNumber == 2) {
......@@ -281,10 +276,9 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
#pragma mark Public Methods
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
{
UITableView *tableView = self.tableView;
[tableView selectRowAtIndexPath:indexPath animated:animated scrollPosition:scrollPosition];
[_menuTableView selectRowAtIndexPath:indexPath animated:animated scrollPosition:scrollPosition];
if (scrollPosition == UITableViewScrollPositionNone)
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
[_menuTableView scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
[self _revealItem:indexPath.row inSection:indexPath.section];
}
......
......@@ -11,12 +11,13 @@
*****************************************************************************/
#import "VLCSidebarController.h"
#import "GHRevealViewController.h"
#import "VLCMenuTableViewController.h"
#import "UIViewController+RESideMenu.h"
#import "RESideMenu.h"
@interface VLCSidebarController()
{
GHRevealViewController *_revealController;
RESideMenu *_sideMenuViewController;
VLCMenuTableViewController *_menuViewController;
UIViewController *_contentViewController;
}
......@@ -43,13 +44,16 @@
if (!self)
return self;
_revealController = [[GHRevealViewController alloc] initWithNibName:nil bundle:nil];
_revealController.extendedLayoutIncludesOpaqueBars = YES;
_revealController.edgesForExtendedLayout = UIRectEdgeAll;
_menuViewController = [[VLCMenuTableViewController alloc] initWithNibName:nil bundle:nil];
_revealController.sidebarViewController = _menuViewController;
if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
_sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:nil
leftMenuViewController:_menuViewController
rightMenuViewController:[UIViewController new]];
} else {
_sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:nil
leftMenuViewController:[UIViewController new]
rightMenuViewController:_menuViewController];
}
return self;
}
......@@ -58,18 +62,18 @@
- (UIViewController *)fullViewController
{
return _revealController;
return _sideMenuViewController;
}
- (void)setContentViewController:(UIViewController *)contentViewController
{
contentViewController.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
_revealController.contentViewController = contentViewController;
_sideMenuViewController.contentViewController = contentViewController;
}
- (UIViewController *)contentViewController
{
return _revealController.contentViewController;
return _sideMenuViewController.contentViewController;
}
#pragma mark - actual work
......@@ -83,12 +87,16 @@
- (void)hideSidebar
{
[_revealController toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
[_sideMenuViewController hideMenuViewController];
}
- (void)toggleSidebar
{
[_revealController toggleSidebar:!_revealController.sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
[_sideMenuViewController presentLeftMenuViewController];
} else {
[_sideMenuViewController presentRightMenuViewController];
}
}
@end
......@@ -1814,7 +1814,7 @@
F2C5CAE560C074258A574B08 /* Copy Pods Resources */,
4173AEC21ABF1B860004101D /* Embed App Extensions */,
DD3567881B6760BF00338947 /* Embed Watch Content */,
EF695E012B3C222ED11192E3 /* Embed Pods Frameworks */,
1B073E97C4037EA19D77093D /* Embed Pods Frameworks */,
);
buildRules = (
);
......@@ -2086,7 +2086,7 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
EF695E012B3C222ED11192E3 /* Embed Pods Frameworks */ = {
1B073E97C4037EA19D77093D /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
......
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