Переглянути джерело

VLCNetworkLoginViewFieldCell: adjust layout for iPhone X

Carola Nitz 7 роки тому
батько
коміт
df0904fde5

+ 0 - 37
Resources/VLCNetworkLoginViewFieldCell.xib

@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="VLCNetworkLoginViewFieldCellIdentifier" id="tLk-x5-WKT" customClass="VLCNetworkLoginViewFieldCell">
-            <rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
-            <autoresizingMask key="autoresizingMask"/>
-            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tLk-x5-WKT" id="RHc-y8-FAl">
-                <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <view contentMode="scaleToFill" id="n31-ec-rUo">
-                        <rect key="frame" x="0.0" y="1" width="320" height="41.5"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" white="0.28999999999999998" alpha="1" colorSpace="calibratedWhite"/>
-                    </view>
-                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" id="63o-Hv-MMw">
-                        <rect key="frame" x="8" y="0.0" width="304" height="44"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                        <textInputTraits key="textInputTraits"/>
-                    </textField>
-                </subviews>
-            </tableViewCellContentView>
-            <connections>
-                <outlet property="textField" destination="63o-Hv-MMw" id="B8N-cz-S5I"/>
-            </connections>
-            <point key="canvasLocation" x="217" y="466"/>
-        </tableViewCell>
-    </objects>
-</document>

+ 2 - 5
Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceLogin.m

@@ -37,10 +37,7 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
 - (void)registerCellsInTableView:(UITableView *)tableView
 {
     [tableView registerClass:[VLCNetworkLoginViewButtonCell class] forCellReuseIdentifier:kVLCNetworkLoginViewButtonCellIdentifier];
-
-    Class fieldClass = [VLCNetworkLoginViewFieldCell class];
-    [tableView registerNib:[UINib nibWithNibName:NSStringFromClass(fieldClass) bundle:[NSBundle bundleForClass:fieldClass]]
-    forCellReuseIdentifier:kVLCNetworkLoginViewFieldCellIdentifier];
+    [tableView registerClass:[VLCNetworkLoginViewFieldCell class] forCellReuseIdentifier:kVLCNetworkLoginViewFieldCellIdentifier];
 }
 
 - (void)setLoginInformation:(VLCNetworkServerLoginInformation *)loginInformation
@@ -152,7 +149,7 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
 
 
 #pragma mark - VLCNetworkLoginDataSourceSection
--(void)configureWithTableView:(UITableView *)tableView
+- (void)configureWithTableView:(UITableView *)tableView
 {
     [self registerCellsInTableView:tableView];
     self.tableView = tableView;

+ 4 - 3
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewButtonCell.m

@@ -20,23 +20,24 @@ NSString * const kVLCNetworkLoginViewButtonCellIdentifier = @"VLCNetworkLoginVie
 {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self) {
-        self.contentView.backgroundColor = [UIColor VLCDarkBackgroundColor];
+        self.backgroundColor = [UIColor VLCDarkBackgroundColor];
         self.textLabel.backgroundColor = [UIColor clearColor];
         self.textLabel.textColor = [UIColor whiteColor];
         self.textLabel.textAlignment = NSTextAlignmentCenter;
         self.accessibilityTraits = UIAccessibilityTraitButton;
 
         UIView *blackView = [[UIView alloc] init];
-        [self.contentView insertSubview:blackView atIndex:0];
+        [self insertSubview:blackView atIndex:0];
         blackView.backgroundColor = [UIColor blackColor];
         self.blackView = blackView;
     }
     return self;
 }
+
 - (void)layoutSubviews
 {
     [super layoutSubviews];
-    self.blackView.frame = CGRectInset(self.contentView.bounds, 0.0, 2.0);
+    self.blackView.frame = CGRectInset(self.bounds, 0.0, 2.0);
 }
 
 - (void)prepareForReuse

+ 1 - 1
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewController.m

@@ -55,7 +55,7 @@
     self.title = NSLocalizedString(@"CONNECT_TO_SERVER", nil);
 
     self.tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
-    self.tableView.separatorColor = [UIColor VLCLightTextColor];
+    self.tableView.separatorColor = [UIColor blackColor];
 
     self.protocolDataSource = [[VLCNetworkLoginDataSourceProtocol alloc] init];
     self.protocolDataSource.delegate = self;

+ 1 - 1
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewFieldCell.h

@@ -19,7 +19,7 @@ extern NSString * const kVLCNetworkLoginViewFieldCellIdentifier;
 
 @interface VLCNetworkLoginViewFieldCell : UITableViewCell
 @property (nonatomic, weak) id<VLCNetworkLoginViewFieldCellDelegate> delegate;
-@property (nonatomic, weak) IBOutlet UITextField *textField;
+@property (nonatomic, retain) UITextField *textField;
 @property (nonatomic, nullable, copy) NSString *placeholderString;
 @end
 

+ 34 - 4
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewFieldCell.m

@@ -9,7 +9,6 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-
 #import "VLCNetworkLoginViewFieldCell.h"
 NSString * const kVLCNetworkLoginViewFieldCellIdentifier = @"VLCNetworkLoginViewFieldCellIdentifier";
 
@@ -18,11 +17,42 @@ NSString * const kVLCNetworkLoginViewFieldCellIdentifier = @"VLCNetworkLoginView
 
 @implementation VLCNetworkLoginViewFieldCell
 
-- (void)awakeFromNib
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
+{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if (self) {
+        self.backgroundColor = [UIColor blackColor];
+        [self setupSubviews];
+    }
+    return self;
+}
+
+- (void)setupSubviews
 {
-    [super awakeFromNib];
-    self.contentView.backgroundColor = [UIColor VLCDarkBackgroundColor];
+    UIView *darkView = [[UIView alloc] init];
+    darkView.translatesAutoresizingMaskIntoConstraints = NO;
+    [self addSubview:darkView];
+    darkView.backgroundColor = [UIColor colorWithRed:57.0/256.0 green:57.0/256.0 blue:57.0/256.0 alpha:1.0];
+    self.textField = [[UITextField alloc] initWithFrame:CGRectZero];
+    self.textField.translatesAutoresizingMaskIntoConstraints = NO;
     self.textField.delegate = self;
+    self.textField.textColor = [UIColor whiteColor];
+    [self addSubview:_textField];
+    
+    UILayoutGuide *guide = self.layoutGuides.firstObject;
+    if (@available(iOS 11.0, *)) {
+        guide = self.safeAreaLayoutGuide;
+    }
+    [NSLayoutConstraint activateConstraints:@[
+                                              [darkView.leftAnchor constraintEqualToAnchor:self.leftAnchor],
+                                              [darkView.topAnchor constraintEqualToAnchor:self.topAnchor],
+                                              [darkView.rightAnchor constraintEqualToAnchor:self.rightAnchor],
+                                              [darkView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-1],
+                                              [self.textField.leftAnchor constraintEqualToAnchor:guide.leftAnchor constant:8.0],
+                                              [self.textField.topAnchor constraintEqualToAnchor:guide.topAnchor],
+                                              [self.textField.rightAnchor constraintEqualToAnchor:guide.rightAnchor constant:8.0],
+                                              [self.textField.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor],
+                                              ]];
 }
 
 - (void)prepareForReuse

+ 0 - 6
VLC.xcodeproj/project.pbxproj

@@ -8,7 +8,6 @@
 
 /* Begin PBXBuildFile section */
 		1D72DC00CD4A06E8789BD8F7 /* libPods-VLC-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FE1DEC7096649D63A308D86C /* libPods-VLC-tvOS.a */; };
-		2678432A1D3D5B9500BF36EE /* VLCNetworkLoginViewFieldCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDF908DB1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib */; };
 		26D2F0651D3D3CC8003F7417 /* VLCNetworkLoginDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD846BDE1D1FCCCD00699D17 /* VLCNetworkLoginDataSource.m */; };
 		26D2F06E1D3D3CCE003F7417 /* VLCNetworkLoginDataSourceProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */; };
 		26D2F06F1D3D3CD4003F7417 /* VLCNetworkLoginDataSourceLogin.m in Sources */ = {isa = PBXBuildFile; fileRef = DD870E941CEF78D800BBD4FE /* VLCNetworkLoginDataSourceLogin.m */; };
@@ -928,7 +927,6 @@
 		DDEAECF11BDFE9E800756C83 /* VLCServerListTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEAECEC1BDFE99200756C83 /* VLCServerListTVViewController.m */; };
 		DDEAECFE1BDFFAEE00756C83 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E6183A99E1009EE944 /* Reachability.m */; };
 		DDF908D01CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908CF1CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m */; };
-		DDF908DC1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDF908DB1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib */; };
 		DDF908E01CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908DF1CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m */; };
 		DDF908E41CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */; };
 		E0C04F951A25B4410080331A /* VLCDocumentPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */; };
@@ -1809,7 +1807,6 @@
 		DDF157B31ACB169B00AAFBC6 /* WatchKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WatchKit.framework; path = System/Library/Frameworks/WatchKit.framework; sourceTree = SDKROOT; };
 		DDF908CE1CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginViewButtonCell.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginViewButtonCell.h; sourceTree = SOURCE_ROOT; };
 		DDF908CF1CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkLoginViewButtonCell.m; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginViewButtonCell.m; sourceTree = SOURCE_ROOT; };
-		DDF908DB1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = VLCNetworkLoginViewFieldCell.xib; path = Resources/VLCNetworkLoginViewFieldCell.xib; sourceTree = SOURCE_ROOT; };
 		DDF908DE1CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginDataSourceSavedLogins.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceSavedLogins.h; sourceTree = SOURCE_ROOT; };
 		DDF908DF1CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkLoginDataSourceSavedLogins.m; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceSavedLogins.m; sourceTree = SOURCE_ROOT; };
 		DDF908E11CF4E70900108B70 /* VLCNetworkLoginDataSourceSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginDataSourceSection.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceSection.h; sourceTree = SOURCE_ROOT; };
@@ -2394,7 +2391,6 @@
 				7D89786E185DED88009BAB5D /* VLCDownloadViewController.xib */,
 				7DBBF18F183AB4300009A339 /* VLCNetworkListCell.xib */,
 				9B9231C3185A703700F89498 /* VLCNetworkLoginViewController.xib */,
-				DDF908DB1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib */,
 				7D89787C185DF794009BAB5D /* VLCOpenNetworkStreamViewController.xib */,
 			);
 			name = "Download & Network";
@@ -3817,7 +3813,6 @@
 				7D9870691A3E03D5009CF27D /* papasscode_marker@2x.png in Resources */,
 				7D5DD5C717590ABF001421E3 /* About Contents.html in Resources */,
 				7DBBF19B183AB4300009A339 /* VLCCloudStorageTableViewCell~iphone.xib in Resources */,
-				DDF908DC1CF4CEE700108B70 /* VLCNetworkLoginViewFieldCell.xib in Resources */,
 				7D92897B1877467E009108FD /* VLCFirstStepsFourthPageViewController~iphone.xib in Resources */,
 				7D1516461868D7E0004B18F3 /* VLCFirstStepsSixthPageViewController~iphone.xib in Resources */,
 				41273A3D1A955C4100A2EF77 /* VLCMigrationViewController.xib in Resources */,
@@ -3880,7 +3875,6 @@
 				7DC550591C046615007B4E42 /* papasscode_marker@2x.png in Resources */,
 				7DC5505A1C046615007B4E42 /* About Contents.html in Resources */,
 				7DC5505B1C046615007B4E42 /* VLCCloudStorageTableViewCell~iphone.xib in Resources */,
-				2678432A1D3D5B9500BF36EE /* VLCNetworkLoginViewFieldCell.xib in Resources */,
 				7DC5505D1C046615007B4E42 /* VLCFirstStepsFourthPageViewController~iphone.xib in Resources */,
 				7DC5505E1C046615007B4E42 /* VLCFirstStepsSixthPageViewController~iphone.xib in Resources */,
 				7DC5505F1C046615007B4E42 /* VLCMigrationViewController.xib in Resources */,