View updated, outsourced, working keyboard and LSK

This commit is contained in:
Kilian Hofmann 2016-03-20 23:17:05 +01:00
parent 1c21a2f0c3
commit c7cf51b2ad
16 changed files with 846 additions and 789 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */; };
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */; };
E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D01C9DB7B3001F5BC0 /* main.m */; };
E22EE9D41C9DB7B3001F5BC0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D31C9DB7B3001F5BC0 /* AppDelegate.m */; };
E22EE9D71C9DB7B3001F5BC0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */; };
@ -35,6 +37,10 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
E227C7811C9F42AB00DE0CA4 /* ViewControllerKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerKeyboard.h; sourceTree = "<group>"; };
E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerKeyboard.m; sourceTree = "<group>"; };
E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerScreen.h; sourceTree = "<group>"; };
E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerScreen.m; sourceTree = "<group>"; };
E22EE9CC1C9DB7B3001F5BC0 /* FMC Planner 2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FMC Planner 2.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E22EE9D01C9DB7B3001F5BC0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E22EE9D21C9DB7B3001F5BC0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -110,6 +116,10 @@
E22EE9DD1C9DB7B3001F5BC0 /* LaunchScreen.storyboard */,
E22EE9E01C9DB7B3001F5BC0 /* Info.plist */,
E22EE9CF1C9DB7B3001F5BC0 /* Supporting Files */,
E227C7811C9F42AB00DE0CA4 /* ViewControllerKeyboard.h */,
E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */,
E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */,
E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */,
);
path = "FMC Planner 2";
sourceTree = "<group>";
@ -276,6 +286,8 @@
E22EE9D71C9DB7B3001F5BC0 /* ViewController.m in Sources */,
E22EE9D41C9DB7B3001F5BC0 /* AppDelegate.m in Sources */,
E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */,
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */,
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -418,6 +430,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = "FMC Planner 2/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.weebly.alikja.FMC-Planner-2";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -431,6 +444,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = "FMC Planner 2/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.weebly.alikja.FMC-Planner-2";
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@ -2,4 +2,54 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewController.m"
timestampString = "480202380.506075"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "20"
endingLineNumber = "20"
landmarkName = "-viewDidLoad"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480202890.028996"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "13"
endingLineNumber = "13"
landmarkName = "-viewDidLoad"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480204314.085838"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "59"
endingLineNumber = "59"
landmarkName = "-findAdaptiveFontForUILabelSize:withMinimumSize:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -59,6 +59,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "iphone",
"filename" : "triSmall.png",
"scale" : "1x"
},
{
"idiom" : "iphone",
"filename" : "trBig.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"filename" : "triBigger.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
@ -15,7 +16,6 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>

File diff suppressed because it is too large Load Diff

View File

@ -6,27 +6,17 @@
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "ViewControllerKeyboard.h"
#import "ViewControllerScreen.h"
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic) BOOL alphaOn;
@property(strong, nonatomic) NSArray *alphabet;
@property(strong, nonatomic) NSArray *numeric;
@property(strong, nonatomic) IBOutletCollection(UIButton) NSArray *Keys;
@property(strong, nonatomic) IBOutlet UIView *backdropKeys;
@property(strong, nonatomic) IBOutlet UIView *backdropScreen;
@property(strong, nonatomic) IBOutletCollection(UILabel) NSArray *ScreenLabels;
@property(strong, nonatomic) IBOutlet UILabel *Scratchpad;
@property(strong, nonatomic) IBOutlet UILabel *Header;
- (IBAction)KeyTaps:(UIButton *)sender;
@property(strong, nonatomic) ViewControllerScreen *screen;
@property(strong, nonatomic) ViewControllerKeyboard *keys;
@end

View File

@ -13,89 +13,22 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_alphaOn = true;
_alphabet = [[NSArray alloc]
initWithObjects:@"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", nil];
_numeric = [[NSArray alloc]
initWithObjects:@"1", @"2", @"3", @"", @"", @"", @"4", @"5", @"6",
@"", @"", @"", @"7", @"8", @"9", @"", @"", @"",
@".", @"0", @"/", @"", @"", @"", @"", @"", @"SP",
@"CLR", @"DEL", @"LET", nil];
// Round corners
_backdropKeys.layer.cornerRadius = 5;
_backdropKeys.layer.masksToBounds = YES;
_backdropScreen.layer.cornerRadius = 5;
_backdropScreen.layer.masksToBounds = YES;
for (UIButton *but in _Keys) {
but.layer.cornerRadius = 5;
but.layer.masksToBounds = YES;
}
// Set Font Size
if (self.view.frame.size.height == 480) {
for (UILabel *label in _ScreenLabels) {
label.font = [UIFont systemFontOfSize:14];
}
_Header.font = [UIFont systemFontOfSize:14];
_Scratchpad.font = [UIFont systemFontOfSize:14];
}
// Init Start Page
[self clearScreen];
_Header.text = @"START";
_Scratchpad.text = @"";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)KeyTaps:(UIButton *)sender {
if ([sender.restorationIdentifier isEqualToString:@"Switch"]) {
_alphaOn = !_alphaOn;
[self switchKeyboard];
} else if ([sender.restorationIdentifier isEqualToString:@"Space"]) {
_Scratchpad.text = [_Scratchpad.text stringByAppendingString:@" "];
} else if ([sender.restorationIdentifier isEqualToString:@"Clear"]) {
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
_Scratchpad.text = @"";
} else if (_Scratchpad.text.length > 0) {
_Scratchpad.text =
[_Scratchpad.text substringToIndex:[_Scratchpad.text length] - 1];
}
} else if ([sender.restorationIdentifier isEqualToString:@"Delete"]) {
_Scratchpad.text = @"DELETE";
} else {
_Scratchpad.text =
[_Scratchpad.text stringByAppendingString:sender.titleLabel.text];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSString *segueName = segue.identifier;
if ([segueName isEqualToString:@"keyboard"]) {
_keys = (ViewControllerKeyboard *)[segue destinationViewController];
_keys.main = self;
}
}
- (void)clearScreen {
for (UILabel *label in _ScreenLabels) {
label.text = @"";
}
_Scratchpad.text = @"";
_Header.text = @"";
}
- (void)switchKeyboard {
if (_alphaOn) {
for (int i = 0; i < _Keys.count; i++) {
[((UIButton *)_Keys[i]) setTitle:_alphabet[i]
forState:UIControlStateNormal];
[((UIButton *)_Keys[i]).titleLabel sizeToFit];
}
} else {
for (int i = 0; i < _Keys.count; i++) {
[((UIButton *)_Keys[i]) setTitle:_numeric[i]
forState:UIControlStateNormal];
[((UIButton *)_Keys[i]).titleLabel sizeToFit];
}
if ([segueName isEqualToString:@"screen"]) {
_screen = (ViewControllerScreen *)[segue destinationViewController];
_screen.main = self;
}
}

View File

@ -0,0 +1,25 @@
//
// ViewControllerKeyboard.h
// FMC Planner 2
//
// Created by Kilian Hofmann on 20.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ViewController;
@interface ViewControllerKeyboard : UIViewController
@property(nonatomic) BOOL alphaOn;
@property(strong, nonatomic) NSArray *alphabet;
@property(strong, nonatomic) NSArray *numeric;
@property(strong, nonatomic) IBOutletCollection(UIButton) NSArray *Keys;
@property(strong, nonatomic) ViewController *main;
- (IBAction)KeyTaps:(UIButton *)sender;
@end

View File

@ -0,0 +1,73 @@
//
// ViewControllerKeyboard.m
// FMC Planner 2
//
// Created by Kilian Hofmann on 20.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "ViewController.h"
#import "ViewControllerKeyboard.h"
@implementation ViewControllerKeyboard
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_alphaOn = true;
_alphabet = [[NSArray alloc]
initWithObjects:@"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", nil];
_numeric = [[NSArray alloc]
initWithObjects:@"1", @"2", @"3", @"", @"", @"", @"4", @"5", @"6",
@"", @"", @"", @"7", @"8", @"9", @"", @"", @"",
@".", @"0", @"/", @"", @"", @"", @"", @"", @"SP",
@"CLR", @"DEL", @"LET", nil];
// Round button corners
for (UIButton *but in _Keys) {
but.layer.cornerRadius = 5;
but.layer.masksToBounds = YES;
}
}
- (IBAction)KeyTaps:(UIButton *)sender {
if ([sender.restorationIdentifier isEqualToString:@"Switch"]) {
_alphaOn = !_alphaOn;
[self switchKeyboard];
} else if ([sender.restorationIdentifier isEqualToString:@"Space"]) {
_main.screen.Scratchpad.text =
[_main.screen.Scratchpad.text stringByAppendingString:@" "];
} else if ([sender.restorationIdentifier isEqualToString:@"Clear"]) {
if ([_main.screen.Scratchpad.text isEqualToString:@"DELETE"]) {
_main.screen.Scratchpad.text = @"";
} else if (_main.screen.Scratchpad.text.length > 0) {
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
substringToIndex:[_main.screen.Scratchpad.text length] - 1];
}
} else if ([sender.restorationIdentifier isEqualToString:@"Delete"]) {
_main.screen.Scratchpad.text = @"DELETE";
} else {
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
stringByAppendingString:sender.titleLabel.text];
}
}
- (void)switchKeyboard {
if (_alphaOn) {
for (int i = 0; i < _Keys.count; i++) {
[((UIButton *)_Keys[i]) setTitle:_alphabet[i]
forState:UIControlStateNormal];
[((UIButton *)_Keys[i]).titleLabel sizeToFit];
}
} else {
for (int i = 0; i < _Keys.count; i++) {
[((UIButton *)_Keys[i]) setTitle:_numeric[i]
forState:UIControlStateNormal];
[((UIButton *)_Keys[i]).titleLabel sizeToFit];
}
}
}
@end

View File

@ -0,0 +1,22 @@
//
// ViewControllerScreen.h
// FMC Planner 2
//
// Created by Kilian Hofmann on 20.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ViewController;
@interface ViewControllerScreen : UIViewController
@property(strong, nonatomic) IBOutletCollection(UILabel) NSArray *LSK;
@property(strong, nonatomic) IBOutlet UILabel *Scratchpad;
@property(strong, nonatomic) IBOutlet UILabel *Header;
@property(strong, nonatomic) ViewController *main;
@end

View File

@ -0,0 +1,95 @@
//
// ViewControllerScreen.m
// FMC Planner 2
//
// Created by Kilian Hofmann on 20.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "ViewControllerScreen.h"
@implementation ViewControllerScreen
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// Init Start Page
[self clearScreen];
_Header.text = @"START";
_Scratchpad.text = @"";
// Tap gesture shit and fitToSize
for (UILabel *label in _LSK) {
label.font = [self findAdaptiveFontForUILabelSize:label.frame.size
withMinimumSize:21];
label.adjustsFontSizeToFitWidth = YES;
label.userInteractionEnabled = YES;
UITapGestureRecognizer *reg =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(enterLSK:)];
[reg setNumberOfTapsRequired:1];
[reg setNumberOfTouchesRequired:1];
[label addGestureRecognizer:reg];
}
_Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size
withMinimumSize:21];
_Header.adjustsFontSizeToFitWidth = YES;
_Scratchpad.font = [self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size
withMinimumSize:21];
_Scratchpad.adjustsFontSizeToFitWidth = YES;
}
- (void)clearScreen {
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 = @"";
}
- (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize
withMinimumSize:(NSInteger)minSize {
UIFont *tempFont = nil;
NSString *testString =
@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
NSInteger tempMin = minSize;
NSInteger tempMax = 256;
NSInteger mid = 0;
NSInteger difference = 0;
while (tempMin <= tempMax) {
mid = tempMin + (tempMax - tempMin) / 2;
tempFont = [UIFont systemFontOfSize:mid];
difference = labelSize.height - [testString sizeWithFont: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