Commit d40031e6 authored by Felix Paul Kühne's avatar Felix Paul Kühne

left menu: fix layout and stuff (closes #15127)

parent 528b4980
......@@ -31,7 +31,9 @@
#import "VLCNavigationController.h"
#define ROW_HEIGHT 50.
#define IPAD_ROW_HEIGHT 65.
#define HEADER_HEIGHT 22.
#define MENU_WIDTH 320.
static NSString *CellIdentifier = @"VLCMenuCell";
static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
......@@ -62,38 +64,64 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
{
[super viewDidLoad];
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"];
_menuTableView = ({
NSUInteger count = _menuItemsSectionOne.count + _menuItemsSectionTwo.count + _menuItemsSectionThree.count;
CGFloat height = (count * ROW_HEIGHT) + (3. * HEADER_HEIGHT);
CGFloat screenheight = [UIScreen mainScreen].bounds.size.height;
if (height > screenheight - 40.)
height = screenheight - 40.;
CGFloat top = (screenheight - 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;
});
NSUInteger count = _menuItemsSectionOne.count + _menuItemsSectionTwo.count + _menuItemsSectionThree.count;
CGFloat screenheight = [UIScreen mainScreen].bounds.size.height;
CGFloat rowHeight;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
rowHeight = IPAD_ROW_HEIGHT;
else
rowHeight = ROW_HEIGHT;
CGFloat height = (count * rowHeight) + (3. * HEADER_HEIGHT);
CGFloat top;
if (height > screenheight - 20.) {
height = screenheight - 20.;
top = 10.;
} else
top = (screenheight - height) / 2.;
CGFloat left;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
left = 170.;
else
left = 20.;
_menuTableView = [[UITableView alloc] initWithFrame:CGRectMake(left, top, 320., height)
style:UITableViewStylePlain];
_menuTableView.delegate = self;
_menuTableView.dataSource = self;
_menuTableView.backgroundColor = [UIColor clearColor];
_menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_menuTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_menuTableView.rowHeight = rowHeight;
_menuTableView.scrollsToTop = NO;
_menuTableView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_menuTableView];
NSDictionary *dict;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIView *spacer1 = [UIView new];
UIView *spacer2 = [UIView new];
spacer1.translatesAutoresizingMaskIntoConstraints = NO;
spacer2.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:spacer1];
[self.view addSubview:spacer2];
dict = NSDictionaryOfVariableBindings(_menuTableView, spacer1, spacer2);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:|[spacer1][_menuTableView(==%i)][spacer2(==spacer1)]|", (int)height] options:0 metrics:0 views:dict]];
} else {
dict = NSDictionaryOfVariableBindings(_menuTableView);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:|-==%i-[_menuTableView(<=%i)]-==%i-|", (int)top, (int)height, (int)top] options:0 metrics:0 views:dict]];
}
dict = NSDictionaryOfVariableBindings(_menuTableView);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"H:|-==%i-[_menuTableView(320)]->=0-|", (int)left] options:0 metrics:0 views:dict]];
[_menuTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
}
......@@ -274,6 +302,7 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self _revealItem:indexPath.row inSection:indexPath.section];
}
......
......@@ -18,10 +18,8 @@
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
self.clipsToBounds = YES;
self.backgroundColor = [UIColor clearColor];
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor colorWithRed:0.1137 green:0.1137 blue:0.1137 alpha:1.0f];
self.selectedBackgroundView = bgView;
self.selectedBackgroundView = [[UIView alloc] init];
self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
self.imageView.contentMode = UIViewContentModeCenter;
......@@ -33,14 +31,6 @@
self.textLabel.minimumScaleFactor = 0.5f;
self.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
topLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
[self.textLabel.superview addSubview:topLine];
UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 50.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
bottomLine.backgroundColor = [UIColor colorWithRed:(23.0f/255.0f) green:(23.0f/255.0f) blue:(23.0f/255.0f) alpha:1.0f];
[self.textLabel.superview addSubview:bottomLine];
UILabel *textLabel = self.textLabel;
textLabel.translatesAutoresizingMaskIntoConstraints = NO;
UIImageView *imageView = self.imageView;
......@@ -48,7 +38,6 @@
NSDictionary *dict = NSDictionaryOfVariableBindings(textLabel,imageView);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[imageView(50)]-==8-[textLabel]|" options:0 metrics:0 views:dict]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[imageView(50)]|" options:0 metrics:0 views:dict]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[textLabel]|" options:0 metrics:0 views:dict]];
}
......
......@@ -2,7 +2,7 @@
* VLCWiFiUploadTableViewCell.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -79,14 +79,6 @@
[self.serverOnButton addTarget:self action:@selector(toggleHTTPServer) forControlEvents:UIControlEventTouchUpInside];
[self.serverOnButton setImage:[UIImage imageNamed:@"WiFiUp"] forState:UIControlStateDisabled];
[self.contentView addSubview:self.serverOnButton];
UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
topLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
[self.contentView addSubview:topLine];
UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 50.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
bottomLine.backgroundColor = [UIColor colorWithRed:(23.0f/255.0f) green:(23.0f/255.0f) blue:(23.0f/255.0f) alpha:1.0f];
[self.contentView addSubview:bottomLine];
}
- (void)setupConstraints
......
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