Basic saving done (save on every LSK entry, no saving on empty CO RTE -> (TODO: possibly more dynamic for more than one leading whitespace, delete leading whitespace))
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
<string>Departure</string>
|
||||
<string>Arrival</string>
|
||||
<string>Aircraft</string>
|
||||
<string></string>
|
||||
<string>DEPARTURE</string>
|
||||
<string>ARRIVAL</string>
|
||||
<string>AIRCRAFT</string>
|
||||
<string></string>
|
||||
<string></string>
|
||||
<string></string>
|
||||
<string>CO RTE</string>
|
||||
<string></string>
|
||||
<string></string>
|
||||
<string></string>
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
|
||||
@property(strong, nonatomic) ViewControllerScreen *screen;
|
||||
@property(strong, nonatomic) ViewControllerKeyboard *keys;
|
||||
@property(strong, nonatomic) NSMutableDictionary *save;
|
||||
|
||||
@property(strong, nonatomic) IBOutlet UIView *backdropKeys;
|
||||
|
||||
@property(strong, nonatomic) IBOutlet UIView *backdropScreen;
|
||||
|
||||
- (void)loadSave:(NSString *)file;
|
||||
- (void)saveToFile:(NSDictionary *)save;
|
||||
|
||||
@end
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
_backdropKeys.layer.masksToBounds = YES;
|
||||
_backdropScreen.layer.cornerRadius = 5;
|
||||
_backdropScreen.layer.masksToBounds = YES;
|
||||
// Setup save system
|
||||
_save = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
@@ -32,4 +34,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
#warning TODO: check if file already exists -- load or replace
|
||||
#warning TODO: else -> jump to file browsing for load/delete
|
||||
- (void)saveToFile:(NSDictionary *)save {
|
||||
if (!([_save valueForKey:@"MENU@LSKR1"] == nil ||
|
||||
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(
|
||||
NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *documentsPath = [paths objectAtIndex:0];
|
||||
[_save writeToFile:[documentsPath
|
||||
stringByAppendingString:
|
||||
[NSString
|
||||
stringWithFormat:
|
||||
@"/%@",
|
||||
[_save valueForKey:@"MENU@LSKR1"]]]
|
||||
atomically:YES];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerKeyboard.h"
|
||||
#import "ViewController.h"
|
||||
|
||||
@implementation ViewControllerKeyboard
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SharedDeclerations.h"
|
||||
#import "ViewController.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class ViewController;
|
||||
@@ -26,5 +27,6 @@
|
||||
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight;
|
||||
|
||||
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options;
|
||||
- (void)loadDataToScreen;
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerScreen.h"
|
||||
|
||||
@implementation ViewControllerScreen
|
||||
@@ -65,8 +66,6 @@
|
||||
for (UILabel *label in _LSK) {
|
||||
label.text = @"";
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
_Header.text = @"";
|
||||
}
|
||||
|
||||
- (void)enterLSK:(UITapGestureRecognizer *)tapReg {
|
||||
@@ -76,8 +75,8 @@
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier
|
||||
isEqualToString:@"LSKR6"] &&_numRoutePage = _maxNumRoutePages) {
|
||||
.restorationIdentifier isEqualToString:@"LSKR6"] &&
|
||||
_numRoutePage == _maxNumRoutePages) {
|
||||
_maxNumRoutePages += 1;
|
||||
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
|
||||
_Header.text = [_Header.text
|
||||
@@ -91,6 +90,12 @@
|
||||
_maxNumRoutePages]];
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
[_main.save
|
||||
setObject:((UILabel *)tapReg.view).text
|
||||
forKey:[NSString stringWithFormat:@"%@@%@", _Header.text,
|
||||
((UILabel *)tapReg.view)
|
||||
.restorationIdentifier]];
|
||||
[_main saveToFile:_main.save];
|
||||
}
|
||||
|
||||
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options {
|
||||
@@ -120,6 +125,24 @@
|
||||
_numRoutePage,
|
||||
_maxNumRoutePages]];
|
||||
}
|
||||
[self loadDataToScreen];
|
||||
}
|
||||
|
||||
- (void)loadDataToScreen {
|
||||
for (NSString *ident in _main.save) {
|
||||
NSRange range = [ident rangeOfString:@"@"];
|
||||
if ([[ident substringToIndex:range.location]
|
||||
isEqualToString:_Header.text]) {
|
||||
for (UILabel *label in _LSK) {
|
||||
if ([label.restorationIdentifier
|
||||
isEqualToString:[ident
|
||||
substringFromIndex:range.location +
|
||||
1]]) {
|
||||
label.text = [_main.save valueForKey:ident];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user