refactoring, addition of dynamic route page adjust

This commit is contained in:
Kilian Hofmann 2016-03-23 19:34:51 +01:00
parent cf88fe4205
commit 18d73bd264
10 changed files with 307 additions and 81 deletions

View File

@ -19,6 +19,7 @@
E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */; };
E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10701CA01EC9006E2C6B /* MENU.plist */; };
E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10721CA0375F006E2C6B /* ROUTE.plist */; };
E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */ = {isa = PBXBuildFile; fileRef = E2A927151CA30CEE00606E07 /* SharedDeclerations.m */; };
E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */; };
/* End PBXBuildFile section */
@ -62,6 +63,8 @@
E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
E28E10701CA01EC9006E2C6B /* MENU.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MENU.plist; sourceTree = "<group>"; };
E28E10721CA0375F006E2C6B /* ROUTE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ROUTE.plist; sourceTree = "<group>"; };
E2A927141CA30CEE00606E07 /* SharedDeclerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedDeclerations.h; sourceTree = "<group>"; };
E2A927151CA30CEE00606E07 /* SharedDeclerations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedDeclerations.m; sourceTree = "<group>"; };
E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PERF INIT.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -202,6 +205,7 @@
E2A9270E1CA2FE5200606E07 /* Header */ = {
isa = PBXGroup;
children = (
E2A927141CA30CEE00606E07 /* SharedDeclerations.h */,
E22EE9D21C9DB7B3001F5BC0 /* AppDelegate.h */,
);
name = Header;
@ -210,6 +214,7 @@
E2A9270F1CA2FE5900606E07 /* Implementation */ = {
isa = PBXGroup;
children = (
E2A927151CA30CEE00606E07 /* SharedDeclerations.m */,
E22EE9D31C9DB7B3001F5BC0 /* AppDelegate.m */,
E22EE9D01C9DB7B3001F5BC0 /* main.m */,
);
@ -354,6 +359,7 @@
E22EE9D71C9DB7B3001F5BC0 /* ViewController.m in Sources */,
E22EE9D41C9DB7B3001F5BC0 /* AppDelegate.m in Sources */,
E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */,
E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */,
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */,
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */,
);

View File

@ -2,4 +2,86 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480450634.41493"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
landmarkName = "-loadScreen:withOptions:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480450634.41493"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "109"
endingLineNumber = "109"
landmarkName = "-loadScreen:withOptions:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480449290.841766"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "72"
endingLineNumber = "72"
landmarkName = "-enterLSK:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerKeyboard.m"
timestampString = "480449369.755953"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "117"
endingLineNumber = "117"
landmarkName = "-KeyTaps:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerKeyboard.m"
timestampString = "480449401.34365"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "97"
endingLineNumber = "97"
landmarkName = "-KeyTaps:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -487,13 +487,13 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zec-2v-VfE">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL2" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zec-2v-VfE">
<rect key="frame" x="10" y="65" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mXy-bk-ceo">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR2" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mXy-bk-ceo">
<rect key="frame" x="140" y="65" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -511,13 +511,13 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jWW-bv-Dfp">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL3" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jWW-bv-Dfp">
<rect key="frame" x="10" y="97" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Re-H9-pwK">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR3" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Re-H9-pwK">
<rect key="frame" x="140" y="97" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -535,13 +535,13 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="idt-HJ-NT3">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL4" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="idt-HJ-NT3">
<rect key="frame" x="10" y="129" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yj4-ZZ-gxG">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR4" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yj4-ZZ-gxG">
<rect key="frame" x="140" y="129" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -559,13 +559,13 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MdV-Xi-BKR">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL5" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MdV-Xi-BKR">
<rect key="frame" x="10" y="161" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BXf-ft-vHl">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR5" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BXf-ft-vHl">
<rect key="frame" x="140" y="161" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -583,13 +583,13 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="m3e-KD-2Cx">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL6" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="m3e-KD-2Cx">
<rect key="frame" x="10" y="193" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fQz-BB-LrD">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR6" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fQz-BB-LrD">
<rect key="frame" x="140" y="193" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -605,13 +605,13 @@
<rect key="frame" x="10" y="209" width="260" height="1"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="k64-uO-je8">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKL1" text="LSK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="k64-uO-je8">
<rect key="frame" x="10" y="33" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sro-Ep-8wL">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="LSKR1" text="LSK" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sro-Ep-8wL">
<rect key="frame" x="140" y="33" width="130" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>

View File

@ -0,0 +1,25 @@
//
// SharedDecleartions.h
// FMC Planner 2
//
// Created by Kilian Hofmann on 23.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import <UIKit/UIKit.h>
#define FOO1 NEXTRTEPAGE
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define FMCNEXTRTEPAGE @STRINGIZE2(FOO1)
#define FOO2 FIRSTRTEPAGE
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define FMCFIRSTRTEPAGE @STRINGIZE2(FOO2)
@interface SharedDeclerations : NSObject
+ (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize
withMinimumSize:(NSInteger)minSize
withMod:(float)mod;
@end

View File

@ -0,0 +1,52 @@
//
// SharedDecleartions.m
// FMC Planner 2
//
// Created by Kilian Hofmann on 23.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "SharedDeclerations.h"
@implementation SharedDeclerations
+ (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize
withMinimumSize:(NSInteger)minSize
withMod:(float)mod {
UIFont *tempFont = nil;
NSString *testString =
@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
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:@{
NSFontAttributeName : tempFont
}].height;
if (mid == tempMin || mid == tempMax) {
if (difference < 0) {
return [UIFont systemFontOfSize:(mid - 1)];
}
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];
}
@end

View File

@ -6,6 +6,7 @@
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "SharedDeclerations.h"
#import "ViewControllerKeyboard.h"
#import "ViewControllerScreen.h"
#import <UIKit/UIKit.h>

View File

@ -6,6 +6,7 @@
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "SharedDeclerations.h"
#import <UIKit/UIKit.h>
@class ViewController;

View File

@ -15,16 +15,76 @@
[super viewDidLoad];
// Do any additional setup after loading the view.
_alphaOn = true;
_alphabet = @[@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I",
@"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R",
@"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", @"SP",
@"CLR", @"DEL", @"NUM", @"M\nE\nN\nU", @"P\nE\nR\nF",
@"R\nT\nE"];
_numeric = @[@"1", @"2", @"3", @"", @"", @"", @"4", @"5", @"6",
@"", @"", @"", @"7", @"8", @"9", @"", @"", @"",
@".", @"0", @"/", @"", @"", @"", @"", @"", @"SP",
@"CLR", @"DEL", @"LET", @"M\nE\nN\nU", @"P\nE\nR\nF",
@"R\nT\nE"];
_alphabet = @[
@"A",
@"B",
@"C",
@"D",
@"E",
@"F",
@"G",
@"H",
@"I",
@"J",
@"K",
@"L",
@"M",
@"N",
@"O",
@"P",
@"Q",
@"R",
@"S",
@"T",
@"U",
@"V",
@"W",
@"X",
@"Y",
@"Z",
@"SP",
@"CLR",
@"DEL",
@"NUM",
@"M\nE\nN\nU",
@"P\nE\nR\nF",
@"R\nT\nE"
];
_numeric = @[
@"1",
@"2",
@"3",
@"",
@"",
@"",
@"4",
@"5",
@"6",
@"",
@"",
@"",
@"7",
@"8",
@"9",
@"",
@"",
@"",
@".",
@"0",
@"/",
@"",
@"",
@"",
@"",
@"",
@"SP",
@"CLR",
@"DEL",
@"LET",
@"M\nE\nN\nU",
@"P\nE\nR\nF",
@"R\nT\nE"
];
// Init Board
[self switchKeyboard];
// Round button corners
@ -51,11 +111,17 @@
} 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" withOptions:nil];
} else if ([sender.restorationIdentifier isEqualToString:@"Mid"]) {
[_main.screen loadScreen:@"PERF INIT"];
[_main.screen loadScreen:@"PERF INIT" withOptions:nil];
} else if ([sender.restorationIdentifier isEqualToString:@"Bot"]) {
[_main.screen loadScreen:@"ROUTE"];
if (_main.screen.maxNumRoutePages > _main.screen.numRoutePage &&
([[_main.screen.Header.text substringToIndex:3]
isEqualToString:@"ROU"])) {
[_main.screen loadScreen:@"ROUTE" withOptions:@[ FMCNEXTRTEPAGE ]];
} else {
[_main.screen loadScreen:@"ROUTE" withOptions:@[ FMCFIRSTRTEPAGE ]];
}
} else {
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
stringByAppendingString:sender.titleLabel.text];

View File

@ -6,12 +6,14 @@
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "SharedDeclerations.h"
#import <UIKit/UIKit.h>
@class ViewController;
@interface ViewControllerScreen : UIViewController
@property(strong, nonatomic) ViewController *main;
@property(nonatomic) NSUInteger maxNumRoutePages;
@property(nonatomic) NSUInteger numRoutePage;
@property(strong, nonatomic) IBOutletCollection(UILabel) NSArray *LSK;
@ -23,6 +25,6 @@
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight;
- (void)loadScreen:(NSString *)screenName;
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options;
@end

View File

@ -15,9 +15,13 @@
// Do any additional setup after loading the view.
// Init Start Page
[self clearScreen];
_Header.text = @"START";
_Scratchpad.text = @"";
_numRoutePage = 1;
// ADJUST BASED ON SAVE
_maxNumRoutePages = 1;
// Tap gesture shit
for (UILabel *label in _LSK) {
@ -33,24 +37,25 @@
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:YES];
[self loadScreen:@"MENU"];
[self loadScreen:@"MENU" withOptions:nil];
}
- (void)viewDidLayoutSubviews {
_FrameHeight.constant = self.view.frame.size.height / 14.5;
// Size and LineBreak
_Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
_Header.font =
[SharedDeclerations findAdaptiveFontForUILabelSize:_Header.frame.size
withMinimumSize:5
withMod:0.7];
_Header.adjustsFontSizeToFitWidth = YES;
_Scratchpad.font =
[self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size
_Scratchpad.font = [SharedDeclerations
findAdaptiveFontForUILabelSize:_Scratchpad.frame.size
withMinimumSize:5
withMod:0.7];
_Scratchpad.adjustsFontSizeToFitWidth = YES;
for (UILabel *label in _LSK) {
label.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
label.font = [SharedDeclerations
findAdaptiveFontForUILabelSize:_Header.frame.size
withMinimumSize:5
withMod:0.6];
}
@ -70,52 +75,26 @@
} else {
((UILabel *)tapReg.view).text = _Scratchpad.text;
}
if ([((UILabel *)tapReg.view)
.restorationIdentifier
isEqualToString:@"LSKR6"] &&_numRoutePage = _maxNumRoutePages) {
_maxNumRoutePages += 1;
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
_Header.text = [_Header.text
stringByReplacingCharactersInRange:NSMakeRange(
indexSlash.location,
_Header.text.length -
indexSlash.location)
withString:[NSString
stringWithFormat:
@"/%u",
_maxNumRoutePages]];
}
_Scratchpad.text = @"";
}
- (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize
withMinimumSize:(NSInteger)minSize
withMod:(float)mod {
UIFont *tempFont = nil;
NSString *testString =
@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
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:
@{NSFontAttributeName: tempFont}]
.height;
if (mid == tempMin || mid == tempMax) {
if (difference < 0) {
return [UIFont systemFontOfSize:(mid - 1)];
}
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];
}
- (void)loadScreen:(NSString *)screenName {
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options {
[self clearScreen];
_Header.text = screenName;
NSArray *screen =
[[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle]
@ -129,6 +108,18 @@
((UILabel *)_LSK[i]).userInteractionEnabled = YES;
}
}
for (NSString *opt in options) {
if ([opt isEqualToString:FMCNEXTRTEPAGE]) {
_numRoutePage += 1;
} else if ([opt isEqualToString:FMCFIRSTRTEPAGE]) {
_numRoutePage = 1;
}
_Header.text = [_Header.text
stringByAppendingString:[NSString
stringWithFormat:@" %u/%u",
_numRoutePage,
_maxNumRoutePages]];
}
}
@end