Commit 5fb0f5b3 authored by Carola Nitz's avatar Carola Nitz

WifiUploadCell: adjust design to fit in the new UI closes (#190)

parent b353b297
......@@ -104,14 +104,14 @@
if (_httpServer.isRunning) {
if (_httpServer.listeningPort != 80) {
return [NSString stringWithFormat:@"http://%@:%i\nhttp://%@:%i",
[self currentIPAddress],
_httpServer.listeningPort,
[self hostname],
_httpServer.listeningPort,
[self currentIPAddress],
_httpServer.listeningPort];
} else {
return [NSString stringWithFormat:@"http://%@\nhttp://%@",
[self currentIPAddress],
[self hostname]];
[self hostname],
[self currentIPAddress]];
}
} else {
return NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
......
......@@ -14,7 +14,6 @@
@interface VLCWiFiUploadTableViewCell : UITableViewCell
- (void)toggleHTTPServer;
+ (NSString *)cellIdentifier;
@end
......@@ -2,10 +2,11 @@
* VLCWiFiUploadTableViewCell.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* Copyright (c) 2013-2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Carola Nitz <caro # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -13,12 +14,11 @@
#import "VLCWiFiUploadTableViewCell.h"
#import "Reachability.h"
#import "VLCHTTPUploaderController.h"
#import "VLC_iOS-Swift.h"
@interface VLCWiFiUploadTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *uploadAddressLabel;
@property (nonatomic, strong) UIButton *serverOnButton;
@property (nonatomic, strong) UISwitch *serverToggle;
@property (nonatomic, strong) Reachability *reachability;
@end
......@@ -27,12 +27,12 @@
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
if (self) {
[self setupCell];
[self setupConstraints];
[self updateHTTPServerAddress];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged) name:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTheme) name:kVLCThemeDidChangeNotification object:nil];
}
return self;
}
......@@ -51,60 +51,27 @@
{
self.reachability = [Reachability reachabilityForLocalWiFi];
[self.reachability startNotifier];
self.titleLabel = [UILabel new];
self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:self.titleLabel];
self.titleLabel.text = NSLocalizedString(@"WEBINTF_TITLE", nil);
self.titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
self.titleLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
self.titleLabel.textColor = [UIColor whiteColor];
self.titleLabel.font = [UIFont systemFontOfSize:16.0];
self.titleLabel.superview.backgroundColor = [UIColor colorWithRed:(43.0f/255.0f) green:(43.0f/255.0f) blue:(43.0f/255.0f) alpha:1.0f];
[self.titleLabel sizeToFit];
self.clipsToBounds = YES;
self.backgroundColor = [UIColor VLCMenuBackgroundColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.uploadAddressLabel = [UILabel new];
self.uploadAddressLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.uploadAddressLabel.numberOfLines = 0;
[self.contentView addSubview:self.uploadAddressLabel];
self.uploadAddressLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
self.uploadAddressLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
self.uploadAddressLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
self.uploadAddressLabel.textColor = [UIColor whiteColor];
self.uploadAddressLabel.font = [UIFont systemFontOfSize:12.0];
self.serverOnButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.serverOnButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.serverOnButton addTarget:self action:@selector(toggleHTTPServer) forControlEvents:UIControlEventTouchUpInside];
[self.serverOnButton setImage:[UIImage imageNamed:@"WiFiUp"] forState:UIControlStateDisabled];
[self.contentView addSubview:self.serverOnButton];
self.textLabel.text = NSLocalizedString(@"WEBINTF_TITLE", nil);
self.detailTextLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
self.serverToggle = [[UISwitch alloc] init];
[self.serverToggle addTarget:self action:@selector(toggleHTTPServer) forControlEvents:UIControlEventTouchUpInside];
self.accessoryView = self.serverToggle;
self.imageView.image = [UIImage imageNamed:@"WifiIcon"];
[self updateTheme];
}
- (void)setupConstraints
- (void)updateTheme
{
UIView *spacer1 = [UIView new];
UIView *spacer2 = [UIView new];
UIView *spacer3 = [UIView new];
UIView *spacer4 = [UIView new];
spacer1.translatesAutoresizingMaskIntoConstraints = NO;
spacer2.translatesAutoresizingMaskIntoConstraints = NO;
spacer3.translatesAutoresizingMaskIntoConstraints = NO;
spacer4.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:spacer1];
[self.contentView addSubview:spacer2];
[self.contentView addSubview:spacer3];
[self.contentView addSubview:spacer4];
NSDictionary *dict = NSDictionaryOfVariableBindings(_titleLabel, _uploadAddressLabel, _serverOnButton, spacer1, spacer2, spacer3, spacer4);
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_serverOnButton(50)]-==8-[_titleLabel]" options:0 metrics:0 views:dict]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_serverOnButton(50)]-==8-[_uploadAddressLabel]" options:0 metrics:0 views:dict]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[spacer1][_titleLabel]-==0-[_uploadAddressLabel(>=0)][spacer2(==spacer1)]|" options:0 metrics:0 views:dict]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[spacer3][_serverOnButton(50)][spacer4]|" options:0 metrics:0 views:dict]];
self.textLabel.textColor = PresentationTheme.current.colors.cellTextColor;
self.detailTextLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor;
self.backgroundColor = PresentationTheme.current.colors.background;
self.serverToggle.thumbTintColor = PresentationTheme.current.colors.background;
}
- (void)netReachabilityChanged
......@@ -114,15 +81,12 @@
- (void)updateHTTPServerAddress
{
[self.serverOnButton setImage:[UIImage imageNamed:@"WifiUp"] forState:UIControlStateNormal];
BOOL connectedViaWifi = [[VLCHTTPUploaderController sharedInstance] isReachable];
self.serverOnButton.enabled = connectedViaWifi;
self.serverToggle.enabled = connectedViaWifi;
NSString *uploadText = connectedViaWifi ? [[VLCHTTPUploaderController sharedInstance] httpStatus] : NSLocalizedString(@"HTTP_UPLOAD_NO_CONNECTIVITY", nil);
self.uploadAddressLabel.text = uploadText;
if (connectedViaWifi && [VLCHTTPUploaderController sharedInstance].isServerRunning) {
[self.serverOnButton setImage:[UIImage imageNamed:@"WifiUpOn"] forState:UIControlStateNormal];
}
self.detailTextLabel.text = uploadText;
self.serverToggle.on = connectedViaWifi && [VLCHTTPUploaderController sharedInstance].isServerRunning;
}
- (void)toggleHTTPServer
......
......@@ -2,18 +2,18 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "WifiUp.png"
"filename" : "icnWifi.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "WifiUp@2x.png"
"filename" : "icnWifi@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "WifiUp@3x.png"
"filename" : "icnWifi@3x.png",
"scale" : "3x"
}
],
"info" : {
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "WifiUpOn.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "WifiUpOn@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "WifiUpOn@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
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