refactor, init Service menu, clear screen function added to main menu

This commit is contained in:
2016-03-26 18:10:39 +01:00
parent de303aab0d
commit 62438ae206
9 changed files with 182 additions and 61 deletions
+35
View File
@@ -54,6 +54,41 @@
</objects>
<point key="canvasLocation" x="132" y="344"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="f8n-Nj-rQS">
<objects>
<navigationController storyboardIdentifier="ServiceMenu" id="xrf-YY-4pi" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="N7x-bS-wc3">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="NBp-hT-qnu" kind="relationship" relationship="rootViewController" id="Lj0-Sp-DNS"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="t3o-xk-B5M" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="477" y="344"/>
</scene>
<!--View Controller Service Menu-->
<scene sceneID="7iP-Kr-lDf">
<objects>
<viewController id="NBp-hT-qnu" customClass="ViewControllerServiceMenu" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="ggM-lD-yT2"/>
<viewControllerLayoutGuide type="bottom" id="QF0-31-pd2"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Q1M-LV-Smi">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="74M-cv-MGw"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="PNG-bU-UDR" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="883" y="346"/>
</scene>
<!--View Controller Keyboard-->
<scene sceneID="L6e-QQ-dPq">
<objects>
+1 -1
View File
@@ -13,7 +13,7 @@
<string></string>
<string></string>
<string></string>
<string></string>
<string>CLEAR ENTRY</string>
<string>EXPORT</string>
<string>SERVICE</string>
</array>
+1
View File
@@ -9,6 +9,7 @@
#import "SharedDeclerations.h"
#import "ViewControllerKeyboard.h"
#import "ViewControllerScreen.h"
#import "ViewControllerServiceMenu.h"
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIAlertViewDelegate>
+51 -60
View File
@@ -21,6 +21,7 @@
// Setup save system
_save = [[NSMutableDictionary alloc] init];
_firstLoad = true;
self.title = @"FMC";
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
@@ -36,69 +37,19 @@
}
- (void)saveToFile:(NSDictionary *)save {
NSString *file =
[SharedDeclerations savePathForFile:[_save valueForKey:@"MENU@LSKR1"]];
if (_firstLoad) {
if ([[NSFileManager defaultManager]
fileExistsAtPath:
[SharedDeclerations
savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]]) {
if ([UIAlertController class]) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Load or replace?"
message:
@"The entered CO ROUTE alreay exists. "
@"Do you want to load or replace it?"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *defaultAction =
[UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
UIAlertAction *loadAction = [UIAlertAction
actionWithTitle:@"Load"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self
loadSave:[_save valueForKey:@"MENU@LSKR1"]];
}];
UIAlertAction *replaceAction = [UIAlertAction
actionWithTitle:@"Replace"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[_save
writeToFile:
[SharedDeclerations
savePathForFile:
[_save
valueForKey:@"MENU@LSKR1"]]
atomically:YES];
}];
[alert addAction:defaultAction];
[alert addAction:loadAction];
[alert addAction:replaceAction];
[self presentViewController:alert animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Load or replace?"
message:@"The entered CO ROUTE alreay exists. Do "
@"you want to load "
@"or replace it?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Load", @"Replace", nil];
[alert show];
}
} else if (!([[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
[_save
writeToFile:[SharedDeclerations
savePathForFile:[_save
valueForKey:@"MENU@LSKR1"]]
atomically:YES];
if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
[self alertViewiOS7:file];
} else if (!([[_save valueForKey:@"MENU@LSKR1"]
isEqualToString:@""]) &&
[_save valueForKey:@"MENU@LSKR1"] != nil) {
[_save writeToFile:file atomically:YES];
}
} else if (!([_save valueForKey:@"MENU@LSKR1"] == nil ||
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
[_save
writeToFile:[SharedDeclerations
savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]
atomically:YES];
[_save writeToFile:file atomically:YES];
}
_firstLoad = false;
}
@@ -113,7 +64,7 @@
}
}
#pragma mark - Delegate vo UIAlertView
#pragma mark - Delegate for UIAlertView and UIAlertController outsource
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
@@ -129,4 +80,44 @@
}
}
- (void)alertViewiOS7:(NSString *)file {
if ([UIAlertController class]) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Load or replace?"
message:@"The entered CO ROUTE alreay exists. "
@"Do you want to load or replace it?"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *defaultAction =
[UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
UIAlertAction *loadAction = [UIAlertAction
actionWithTitle:@"Load"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self loadSave:[_save valueForKey:@"MENU@LSKR1"]];
}];
UIAlertAction *replaceAction =
[UIAlertAction actionWithTitle:@"Replace"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[_save writeToFile:file atomically:YES];
}];
[alert addAction:defaultAction];
[alert addAction:loadAction];
[alert addAction:replaceAction];
[self presentViewController:alert animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Load or replace?"
message:@"The entered CO ROUTE alreay exists. Do "
@"you want to load "
@"or replace it?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Load", @"Replace", nil];
[alert show];
}
}
@end
+26
View File
@@ -82,12 +82,38 @@
}
_main.backupCoRte = ((UILabel *)tapReg.view).text;
((UILabel *)tapReg.view).text = _Scratchpad.text;
} else if ([((UILabel *)tapReg.view)
.restorationIdentifier isEqualToString:@"LSKR4"]) {
[_main saveToFile:_main.save];
_main.save = [[NSMutableDictionary alloc] init];
[self clearScreen];
NSArray *optional = [[[NSDictionary alloc]
initWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:@"LSKs"
ofType:@"plist"]]
valueForKey:_Header.text];
for (UILabel *label in _LSK) {
for (int i = 0; i < optional.count; i++) {
if (label.tag == i && [label.text isEqualToString:@""]) {
label.text = optional[i];
if (!([optional[i] isEqualToString:@""])) {
label.userInteractionEnabled = YES;
}
}
}
}
} else if ([((UILabel *)tapReg.view)
.restorationIdentifier isEqualToString:@"LSKR5"]) {
#warning EXPORT TO PMDG GOES HERE
} else if ([((UILabel *)tapReg.view)
.restorationIdentifier isEqualToString:@"LSKR6"]) {
#warning SERVICE MENU GOES HERE
[self
presentViewController:
[self.storyboard
instantiateViewControllerWithIdentifier:@"ServiceMenu"]
animated:YES
completion:nil];
} else {
((UILabel *)tapReg.view).text = _Scratchpad.text;
}
+17
View File
@@ -0,0 +1,17 @@
//
// ViewControllerServiceMenu.h
// FMC Planner 2
//
// Created by Kilian Hofmann on 26.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "SharedDeclerations.h"
#import "ViewController.h"
#import <UIKit/UIKit.h>
@interface ViewControllerServiceMenu : UIViewController
@property(strong, nonatomic) ViewController *main;
@end
+27
View File
@@ -0,0 +1,27 @@
//
// ViewControllerServiceMenu.m
// FMC Planner 2
//
// Created by Kilian Hofmann on 26.03.16.
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "ViewControllerServiceMenu.h"
@implementation ViewControllerServiceMenu
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Service Menu";
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"FMC"
style:UIBarButtonItemStyleDone
target:self
action:@selector(back)];
}
- (void)back {
[self dismissViewControllerAnimated:YES completion:nil];
}
@end