diff --git a/FMC Planner 2.xcodeproj/project.pbxproj b/FMC Planner 2.xcodeproj/project.pbxproj index fd6cb5c..d0e6430 100644 --- a/FMC Planner 2.xcodeproj/project.pbxproj +++ b/FMC Planner 2.xcodeproj/project.pbxproj @@ -17,6 +17,10 @@ E22EE9DF1C9DB7B3001F5BC0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E22EE9DD1C9DB7B3001F5BC0 /* LaunchScreen.storyboard */; }; E22EE9EA1C9DB7B4001F5BC0 /* FMC_Planner_2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9E91C9DB7B4001F5BC0 /* FMC_Planner_2Tests.m */; }; E22EE9F51C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9F41C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m */; }; + 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 */; }; + E28E10751CA037F2006E2C6B /* Perf Init.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10741CA037F2006E2C6B /* Perf Init.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -57,6 +61,10 @@ E22EE9F01C9DB7B4001F5BC0 /* FMC Planner 2UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "FMC Planner 2UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; E22EE9F41C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FMC_Planner_2UITests.m; sourceTree = ""; }; E22EE9F61C9DB7B4001F5BC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 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 = ""; }; + E28E10721CA0375F006E2C6B /* Route.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Route.plist; sourceTree = ""; }; + E28E10741CA037F2006E2C6B /* Perf Init.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Perf Init.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -64,6 +72,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -87,6 +96,7 @@ E22EE9C31C9DB7B3001F5BC0 = { isa = PBXGroup; children = ( + E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */, E22EE9CE1C9DB7B3001F5BC0 /* FMC Planner 2 */, E22EE9E81C9DB7B4001F5BC0 /* FMC Planner 2Tests */, E22EE9F31C9DB7B4001F5BC0 /* FMC Planner 2UITests */, @@ -107,19 +117,15 @@ E22EE9CE1C9DB7B3001F5BC0 /* FMC Planner 2 */ = { isa = PBXGroup; children = ( + E28E106F1CA01EA1006E2C6B /* Screens */, + E28E106E1CA01E34006E2C6B /* ViewControllers */, E22EE9D21C9DB7B3001F5BC0 /* AppDelegate.h */, E22EE9D31C9DB7B3001F5BC0 /* AppDelegate.m */, - E22EE9D51C9DB7B3001F5BC0 /* ViewController.h */, - E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */, E22EE9D81C9DB7B3001F5BC0 /* Main.storyboard */, E22EE9DB1C9DB7B3001F5BC0 /* Assets.xcassets */, 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 = ""; @@ -150,6 +156,29 @@ path = "FMC Planner 2UITests"; sourceTree = ""; }; + E28E106E1CA01E34006E2C6B /* ViewControllers */ = { + isa = PBXGroup; + children = ( + E22EE9D51C9DB7B3001F5BC0 /* ViewController.h */, + E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */, + E227C7811C9F42AB00DE0CA4 /* ViewControllerKeyboard.h */, + E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */, + E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */, + E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */, + ); + name = ViewControllers; + sourceTree = ""; + }; + E28E106F1CA01EA1006E2C6B /* Screens */ = { + isa = PBXGroup; + children = ( + E28E10701CA01EC9006E2C6B /* Menu.plist */, + E28E10721CA0375F006E2C6B /* Route.plist */, + E28E10741CA037F2006E2C6B /* Perf Init.plist */, + ); + name = Screens; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -256,8 +285,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + E28E10751CA037F2006E2C6B /* Perf Init.plist in Resources */, E22EE9DF1C9DB7B3001F5BC0 /* LaunchScreen.storyboard in Resources */, + E28E10711CA01EC9006E2C6B /* Menu.plist in Resources */, E22EE9DC1C9DB7B3001F5BC0 /* Assets.xcassets in Resources */, + E28E10731CA0375F006E2C6B /* Route.plist in Resources */, E22EE9DA1C9DB7B3001F5BC0 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 89fcce2..178f847 100644 --- a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,22 +3,6 @@ type = "1" version = "2.0"> - - - - @@ -42,12 +26,12 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "FMC Planner 2/ViewControllerScreen.m" - timestampString = "480204314.085838" + timestampString = "480272640.14232" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "59" - endingLineNumber = "59" - landmarkName = "-findAdaptiveFontForUILabelSize:withMinimumSize:" + startingLineNumber = "78" + endingLineNumber = "78" + landmarkName = "-enterLSK:" landmarkType = "5"> diff --git a/FMC Planner 2/Base.lproj/Main.storyboard b/FMC Planner 2/Base.lproj/Main.storyboard index 01ddbc7..6c559ce 100644 --- a/FMC Planner 2/Base.lproj/Main.storyboard +++ b/FMC Planner 2/Base.lproj/Main.storyboard @@ -58,10 +58,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + + + + - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + - - + + + + + + + + + + - - + + + - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + - - - + + + + + + + - - + + + - - + + + @@ -258,12 +384,16 @@ - + + + + + @@ -271,7 +401,9 @@ + + + @@ -542,6 +765,9 @@ + + + @@ -549,4 +775,8 @@ + + + + diff --git a/FMC Planner 2/Menu.plist b/FMC Planner 2/Menu.plist new file mode 100644 index 0000000..8fad2f4 --- /dev/null +++ b/FMC Planner 2/Menu.plist @@ -0,0 +1,18 @@ + + + + + Departure + Arrival + Aircraft + + + + + + + + + + + diff --git a/FMC Planner 2/Perf Init.plist b/FMC Planner 2/Perf Init.plist new file mode 100644 index 0000000..08046bb --- /dev/null +++ b/FMC Planner 2/Perf Init.plist @@ -0,0 +1,18 @@ + + + + + PAYLOAD + ZFW + FUEL + GROSS WEIGHT + + + COST INDEX + FLIGHT LVL + TO FLAPS + V1 + Vr + V2 + + diff --git a/FMC Planner 2/Route.plist b/FMC Planner 2/Route.plist new file mode 100644 index 0000000..e5fb159 --- /dev/null +++ b/FMC Planner 2/Route.plist @@ -0,0 +1,18 @@ + + + + + VIA + + + + + + TO + + + + + + + diff --git a/FMC Planner 2/ViewControllerKeyboard.m b/FMC Planner 2/ViewControllerKeyboard.m index dfc931f..6fb7066 100644 --- a/FMC Planner 2/ViewControllerKeyboard.m +++ b/FMC Planner 2/ViewControllerKeyboard.m @@ -19,12 +19,16 @@ 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]; + @"CLR", @"DEL", @"NUM", @"M\nE\nN\nU", @"P\nE\nR\nF", + @"R\nT\nE", nil]; _numeric = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"", @"", @"", @"4", @"5", @"6", @"", @"", @"", @"7", @"8", @"9", @"", @"", @"", @".", @"0", @"/", @"", @"", @"", @"", @"", @"SP", - @"CLR", @"DEL", @"LET", nil]; + @"CLR", @"DEL", @"LET", @"M\nE\nN\nU", @"P\nE\nR\nF", + @"R\nT\nE", nil]; + // Init Board + [self switchKeyboard]; // Round button corners for (UIButton *but in _Keys) { but.layer.cornerRadius = 5; @@ -48,6 +52,12 @@ } } else if ([sender.restorationIdentifier isEqualToString:@"Delete"]) { _main.screen.Scratchpad.text = @"DELETE"; + } else if ([sender.restorationIdentifier isEqualToString:@"Top"]) { + [_main.screen loadScreen:@"Menu"]; + } else if ([sender.restorationIdentifier isEqualToString:@"Mid"]) { + [_main.screen loadScreen:@"Perf Init"]; + } else if ([sender.restorationIdentifier isEqualToString:@"Bot"]) { + [_main.screen loadScreen:@"Route"]; } else { _main.screen.Scratchpad.text = [_main.screen.Scratchpad.text stringByAppendingString:sender.titleLabel.text]; @@ -57,12 +67,18 @@ - (void)switchKeyboard { if (_alphaOn) { for (int i = 0; i < _Keys.count; i++) { + ((UIButton *)_Keys[i]).titleLabel.numberOfLines = 0; + ((UIButton *)_Keys[i]).titleLabel.lineBreakMode = + NSLineBreakByCharWrapping; [((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]).titleLabel.numberOfLines = 0; + ((UIButton *)_Keys[i]).titleLabel.lineBreakMode = + NSLineBreakByCharWrapping; [((UIButton *)_Keys[i]) setTitle:_numeric[i] forState:UIControlStateNormal]; [((UIButton *)_Keys[i]).titleLabel sizeToFit]; diff --git a/FMC Planner 2/ViewControllerScreen.h b/FMC Planner 2/ViewControllerScreen.h index 509ad7c..c6ecd07 100644 --- a/FMC Planner 2/ViewControllerScreen.h +++ b/FMC Planner 2/ViewControllerScreen.h @@ -19,4 +19,6 @@ @property(strong, nonatomic) ViewController *main; +- (void)loadScreen:(NSString *)screenName; + @end diff --git a/FMC Planner 2/ViewControllerScreen.m b/FMC Planner 2/ViewControllerScreen.m index a8965cd..ad745da 100644 --- a/FMC Planner 2/ViewControllerScreen.m +++ b/FMC Planner 2/ViewControllerScreen.m @@ -18,10 +18,8 @@ _Header.text = @"START"; _Scratchpad.text = @""; - // Tap gesture shit and fitToSize + // Tap gesture shit for (UILabel *label in _LSK) { - label.font = [self findAdaptiveFontForUILabelSize:label.frame.size - withMinimumSize:21]; label.adjustsFontSizeToFitWidth = YES; label.userInteractionEnabled = YES; UITapGestureRecognizer *reg = @@ -31,11 +29,21 @@ [reg setNumberOfTouchesRequired:1]; [label addGestureRecognizer:reg]; } +} + +- (void)viewDidAppear:(BOOL)animated { + [self loadScreen:@"Menu"]; +} + +- (void)viewDidLayoutSubviews { + // Size and LineBreak _Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size - withMinimumSize:21]; + withMinimumSize:5 + withMod:1]; _Header.adjustsFontSizeToFitWidth = YES; _Scratchpad.font = [self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size - withMinimumSize:21]; + withMinimumSize:5 + withMod:1]; _Scratchpad.adjustsFontSizeToFitWidth = YES; } @@ -48,21 +56,59 @@ } - (void)enterLSK:(UITapGestureRecognizer *)tapReg { + UILabel *label = ((UILabel *)tapReg.view); + BOOL append = false; + NSMutableAttributedString *attSOld = [label.attributedText mutableCopy]; + NSRange rangeDesc = [[attSOld string] + rangeOfString:[[[attSOld string] componentsSeparatedByString:@"\n"] + firstObject]]; + NSRange rangeEntry = [[attSOld string] + rangeOfString:[[[attSOld string] componentsSeparatedByString:@"\n"] + lastObject]]; + append = rangeDesc.length + 1 == attSOld.length; + if ([_Scratchpad.text isEqualToString:@"DELETE"]) { - ((UILabel *)tapReg.view).text = @""; + if (append) { + } else { + NSRange new = NSMakeRange(rangeDesc.length + 1, rangeEntry.length); + [attSOld replaceCharactersInRange:new withString:@""]; + label.attributedText = attSOld; + } } else { - ((UILabel *)tapReg.view).text = _Scratchpad.text; + if (!append) { + [attSOld replaceCharactersInRange:NSMakeRange(rangeDesc.length + 1, + rangeEntry.length) + withString:_Scratchpad.text]; + [attSOld + addAttribute:NSFontAttributeName + value:[self findAdaptiveFontForUILabelSize:label.frame.size + withMinimumSize:5 + withMod:2] + range:NSMakeRange(rangeDesc.length + 1, rangeEntry.length)]; + } else { + NSMutableAttributedString *attSNew = + [[NSMutableAttributedString alloc] initWithString:_Scratchpad.text]; + [attSNew + addAttribute:NSFontAttributeName + value:[self findAdaptiveFontForUILabelSize:label.frame.size + withMinimumSize:5 + withMod:2] + range:NSMakeRange(0, attSNew.length)]; + [attSOld appendAttributedString:attSNew]; + } + label.attributedText = attSOld; } _Scratchpad.text = @""; } - (UIFont *)findAdaptiveFontForUILabelSize:(CGSize)labelSize - withMinimumSize:(NSInteger)minSize { + withMinimumSize:(NSInteger)minSize + withMod:(float)mod { UIFont *tempFont = nil; NSString *testString = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - NSInteger tempMin = minSize; + NSInteger tempMin = minSize / mod; NSInteger tempMax = 256; NSInteger mid = 0; NSInteger difference = 0; @@ -70,7 +116,13 @@ while (tempMin <= tempMax) { mid = tempMin + (tempMax - tempMin) / 2; tempFont = [UIFont systemFontOfSize:mid]; - difference = labelSize.height - [testString sizeWithFont:tempFont].height; + difference = + labelSize.height / mod - + [testString + sizeWithAttributes:[NSDictionary + dictionaryWithObject:tempFont + forKey:NSFontAttributeName]] + .height; if (mid == tempMin || mid == tempMax) { if (difference < 0) { @@ -92,4 +144,23 @@ return [UIFont systemFontOfSize:mid]; } +- (void)loadScreen:(NSString *)screenName { + _Header.text = screenName; + NSArray *screen = [[NSArray alloc] + initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:screenName + ofType:@"plist"]]; + for (int i = 0; i < _LSK.count; i++) { + NSMutableAttributedString *attS = [[NSMutableAttributedString alloc] + initWithString:[NSString stringWithFormat:@"%@\n", screen[i]]]; + NSRange range = [[attS string] rangeOfString:screen[i]]; + [attS addAttribute:NSFontAttributeName + value:[self findAdaptiveFontForUILabelSize:((UILabel *)_LSK[i]) + .frame.size + withMinimumSize:5 + withMod:2.5] + range:range]; + ((UILabel *)_LSK[i]).attributedText = attS; + } +} + @end