forked from khanhduytran0/LiveContainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCGuestAppConfigViewController.m
72 lines (62 loc) · 2.36 KB
/
LCGuestAppConfigViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import <Foundation/Foundation.h>
#import "LCGuestAppConfigViewController.h"
#import "utils.h"
@implementation LCGuestAppConfigViewController
- (void)viewDidLoad {
self.title = self.info.bundlePath.lastPathComponent;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemClose target:self action:@selector(saveAndClose)];
__weak LCGuestAppConfigViewController *weakSelf = self;
self.prefSectionsVisible = YES;
self.getPreference = ^id(NSString *section, NSString *keys){
for (NSString *key in [keys componentsSeparatedByString:@"|"]) {
if (weakSelf.info.info[key]) return weakSelf.info.info[key];
}
return nil;
};
self.setPreference = ^(NSString *section, NSString *key, id value){
assert(![key containsString:@"|"]);
weakSelf.info.info[key] = value;
};
NSFileManager *fm = NSFileManager.defaultManager;
NSString *dataPath = [NSString stringWithFormat:@"%@/Data/Application",
[fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject.path];
NSMutableArray *dataList = [fm contentsOfDirectoryAtPath:dataPath error:nil].mutableCopy;
self.prefContents = @[
@[
@{@"key": @"CFBundleDisplayName|CFBundleName|CFBundleExecutable",
@"icon": @"tag",
@"title": @"Name",
@"type": self.typeTextField,
@"enableCondition": ^BOOL(){
return NO;
}
},
@{@"key": @"LCDataUUID",
@"icon": @"folder",
@"title": @"Data",
@"type": self.typePickField,
@"pickKeys": dataList,
@"pickList": dataList
},
@{@"key": @"LCTweaksFolder",
@"icon": @"gearshape.2",
@"title": @"Tweaks folder",
@"type": self.typeTextField,
@"placeholder": @"TODO",
@"enableCondition": ^BOOL(){
return NO;
}
}
]
];
[super viewDidLoad];
}
- (void)saveAndClose {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.info save];
[self.presentingViewController viewWillAppear:NO];
}
@end