UI overhaul

This commit is contained in:
Kilian Hofmann 2016-03-20 14:26:52 +01:00
parent 8c31d7ad36
commit 1c21a2f0c3
4 changed files with 762 additions and 656 deletions

View File

@ -2,22 +2,4 @@
<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 = "480101910.937694"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "21"
endingLineNumber = "21"
landmarkName = "-viewDidLoad"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,23 @@
@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;
@end

View File

@ -8,19 +8,45 @@
#import "ViewController.h"
int SPACING = 10;
int NUM_BUTTONS_PER_ROW = 5;
int NUM_ROWS_OF_BUTTON = 6;
@interface ViewController ()
@end
@implementation ViewController
- (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 {
@ -28,4 +54,49 @@ int NUM_ROWS_OF_BUTTON = 6;
// 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)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];
}
}
}
@end