clang format, interaction updates.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
@@ -21,8 +21,8 @@
|
||||
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6JY-wx-fWz">
|
||||
<rect key="frame" x="20" y="348" width="280" height="205"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="280" id="e41-RH-0Kp"/>
|
||||
<constraint firstAttribute="height" constant="205" id="gDi-3X-8ir"/>
|
||||
<constraint firstAttribute="width" constant="280" id="AFD-aL-Jhp"/>
|
||||
<constraint firstAttribute="height" constant="205" id="jsn-LS-C1H"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<segue destination="wIq-rl-lQa" kind="embed" identifier="keyboard" id="iRf-Lv-WlY"/>
|
||||
@@ -37,11 +37,11 @@
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.33000000000000002" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="6JY-wx-fWz" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="BoO-h6-sdM"/>
|
||||
<constraint firstItem="uVT-4Z-zN6" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="20" id="PSi-Ow-TcU"/>
|
||||
<constraint firstItem="uVT-4Z-zN6" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="RA4-ch-Czz"/>
|
||||
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="6JY-wx-fWz" secondAttribute="bottom" constant="15" id="W0b-Iv-8Gf"/>
|
||||
<constraint firstItem="6JY-wx-fWz" firstAttribute="top" secondItem="uVT-4Z-zN6" secondAttribute="bottom" constant="8" id="ixg-ql-E0A"/>
|
||||
<constraint firstItem="6JY-wx-fWz" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="kbH-th-QDl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="uVT-4Z-zN6" secondAttribute="trailing" constant="20" id="v0r-d2-OoH"/>
|
||||
</constraints>
|
||||
</view>
|
||||
@@ -446,6 +446,10 @@
|
||||
<scene sceneID="yrV-d4-XU2">
|
||||
<objects>
|
||||
<viewController id="Ugt-3C-LsO" customClass="ViewControllerScreen" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="bgX-Bo-CkS"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="gQe-JE-c2y"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="2YN-Dg-9F2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="280" height="320"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
||||
@@ -53,11 +53,11 @@
|
||||
} else if ([sender.restorationIdentifier isEqualToString:@"Delete"]) {
|
||||
_main.screen.Scratchpad.text = @"DELETE";
|
||||
} else if ([sender.restorationIdentifier isEqualToString:@"Top"]) {
|
||||
[_main.screen loadScreen:@"Menu"];
|
||||
[_main.screen loadScreen:@"MENU"];
|
||||
} else if ([sender.restorationIdentifier isEqualToString:@"Mid"]) {
|
||||
[_main.screen loadScreen:@"Perf Init"];
|
||||
[_main.screen loadScreen:@"PERF INIT"];
|
||||
} else if ([sender.restorationIdentifier isEqualToString:@"Bot"]) {
|
||||
[_main.screen loadScreen:@"Route"];
|
||||
[_main.screen loadScreen:@"ROUTE"];
|
||||
} else {
|
||||
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
|
||||
stringByAppendingString:sender.titleLabel.text];
|
||||
|
||||
@@ -11,119 +11,125 @@
|
||||
@implementation ViewControllerScreen
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[super viewDidLoad];
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
// Init Start Page
|
||||
[self clearScreen];
|
||||
_Header.text = @"START";
|
||||
_Scratchpad.text = @"";
|
||||
// Do any additional setup after loading the view.
|
||||
// Init Start Page
|
||||
[self clearScreen];
|
||||
_Header.text = @"START";
|
||||
_Scratchpad.text = @"";
|
||||
|
||||
// Tap gesture shit
|
||||
for (UILabel *label in _LSK) {
|
||||
label.adjustsFontSizeToFitWidth = YES;
|
||||
label.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *reg =
|
||||
[[UITapGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(enterLSK:)];
|
||||
[reg setNumberOfTapsRequired:1];
|
||||
[reg setNumberOfTouchesRequired:1];
|
||||
[label addGestureRecognizer:reg];
|
||||
}
|
||||
// Tap gesture shit
|
||||
for (UILabel *label in _LSK) {
|
||||
label.adjustsFontSizeToFitWidth = YES;
|
||||
UITapGestureRecognizer *reg = [[UITapGestureRecognizer alloc]
|
||||
initWithTarget:self
|
||||
action:@selector(enterLSK:)];
|
||||
[reg setNumberOfTapsRequired:1];
|
||||
[reg setNumberOfTouchesRequired:1];
|
||||
[label addGestureRecognizer:reg];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:YES];
|
||||
[self loadScreen:@"Menu"];
|
||||
[super viewDidAppear:YES];
|
||||
[self loadScreen:@"MENU"];
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
_FrameHeight.constant = self.view.frame.size.height / 14.5;
|
||||
// Size and LineBreak
|
||||
_FrameHeight.constant = self.view.frame.size.height / 14.5;
|
||||
// Size and LineBreak
|
||||
|
||||
_Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
|
||||
withMinimumSize:5
|
||||
withMod:0.7];
|
||||
_Header.adjustsFontSizeToFitWidth = YES;
|
||||
_Scratchpad.font = [self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size
|
||||
_Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
|
||||
withMinimumSize:5
|
||||
withMod:0.7];
|
||||
_Header.adjustsFontSizeToFitWidth = YES;
|
||||
_Scratchpad.font =
|
||||
[self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size
|
||||
withMinimumSize:5
|
||||
withMod:0.7];
|
||||
_Scratchpad.adjustsFontSizeToFitWidth = YES;
|
||||
for (UILabel *label in _LSK) {
|
||||
label.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
|
||||
withMinimumSize:5
|
||||
withMod:0.7];
|
||||
_Scratchpad.adjustsFontSizeToFitWidth = YES;
|
||||
for (UILabel *label in _LSK) {
|
||||
label.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
|
||||
withMinimumSize:5
|
||||
withMod:0.6];
|
||||
}
|
||||
withMod:0.6];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearScreen {
|
||||
for (UILabel *label in _LSK) {
|
||||
label.text = @"";
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
_Header.text = @"";
|
||||
for (UILabel *label in _LSK) {
|
||||
label.text = @"";
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
_Header.text = @"";
|
||||
}
|
||||
|
||||
- (void)enterLSK:(UITapGestureRecognizer *)tapReg {
|
||||
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
((UILabel *)tapReg.view).text = @"";
|
||||
} else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
((UILabel *)tapReg.view).text = @"";
|
||||
} else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
|
||||
- (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize
|
||||
withMinimumSize:(NSInteger)minSize
|
||||
withMod:(float)mod {
|
||||
UIFont *tempFont = nil;
|
||||
NSString *testString =
|
||||
@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
UIFont *tempFont = nil;
|
||||
NSString *testString =
|
||||
@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
NSInteger tempMin = minSize / mod;
|
||||
NSInteger tempMax = 256;
|
||||
NSInteger mid = 0;
|
||||
NSInteger difference = 0;
|
||||
NSInteger tempMin = minSize / mod;
|
||||
NSInteger tempMax = 256;
|
||||
NSInteger mid = 0;
|
||||
NSInteger difference = 0;
|
||||
|
||||
while (tempMin <= tempMax) {
|
||||
mid = tempMin + (tempMax - tempMin) / 2;
|
||||
tempFont = [UIFont systemFontOfSize:mid];
|
||||
difference =
|
||||
labelSize.height / mod -
|
||||
[testString
|
||||
sizeWithAttributes:[NSDictionary
|
||||
dictionaryWithObject:tempFont
|
||||
forKey:NSFontAttributeName]]
|
||||
.height;
|
||||
while (tempMin <= tempMax) {
|
||||
mid = tempMin + (tempMax - tempMin) / 2;
|
||||
tempFont = [UIFont systemFontOfSize:mid];
|
||||
difference =
|
||||
labelSize.height / mod -
|
||||
[testString
|
||||
sizeWithAttributes:
|
||||
[NSDictionary dictionaryWithObject:tempFont
|
||||
forKey:NSFontAttributeName]]
|
||||
.height;
|
||||
|
||||
if (mid == tempMin || mid == tempMax) {
|
||||
if (difference < 0) {
|
||||
return [UIFont systemFontOfSize:(mid - 1)];
|
||||
}
|
||||
if (mid == tempMin || mid == tempMax) {
|
||||
if (difference < 0) {
|
||||
return [UIFont systemFontOfSize:(mid - 1)];
|
||||
}
|
||||
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
}
|
||||
|
||||
if (difference < 0) {
|
||||
tempMax = mid - 1;
|
||||
} else if (difference > 0) {
|
||||
tempMin = mid + 1;
|
||||
} else {
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
}
|
||||
}
|
||||
|
||||
if (difference < 0) {
|
||||
tempMax = mid - 1;
|
||||
} else if (difference > 0) {
|
||||
tempMin = mid + 1;
|
||||
} else {
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
}
|
||||
}
|
||||
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
return [UIFont systemFontOfSize:mid];
|
||||
}
|
||||
|
||||
- (void)loadScreen:(NSString *)screenName {
|
||||
_Header.text = screenName;
|
||||
NSArray *screen = [[NSArray alloc]
|
||||
initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:screenName
|
||||
_Header.text = screenName;
|
||||
NSArray *screen =
|
||||
[[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle]
|
||||
pathForResource:screenName
|
||||
ofType:@"plist"]];
|
||||
for (int i = 0; i < _Desc.count; i++) {
|
||||
((UILabel *)_Desc[i]).text = [NSString stringWithFormat:@"%@\n", screen[i]];
|
||||
}
|
||||
for (int i = 0; i < _Desc.count; i++) {
|
||||
((UILabel *)_Desc[i]).text =
|
||||
[NSString stringWithFormat:@"%@\n", screen[i]];
|
||||
if (![screen[i] isEqualToString:@""] ||
|
||||
[_Header.text isEqualToString:@"ROUTE"]) {
|
||||
((UILabel *)_LSK[i]).userInteractionEnabled = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user