forked from SVGKit/SVGKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVCMainMenuViewController.m
More file actions
96 lines (78 loc) · 2.67 KB
/
Copy pathVCMainMenuViewController.m
File metadata and controls
96 lines (78 loc) · 2.67 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#import "VCMainMenuViewController.h"
#import "VCGridOfImagesViewController.h"
#import "DetailViewController.h" // for web loading directly
#import "SVGKSourceURL.h" // for web loading directly
#import "VCAllSpecImages.h" // spec images have special settings in their VC, to wokraround XCode Groups/Folder References/Virtual folder build bugs (UNFIXED BY APPLE FOR 8+ years!)
@interface VCMainMenuViewController ()
@end
@implementation VCMainMenuViewController
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if( [identifier isEqualToString:@"ViewURL"])
{
NSString* s = self.textWebURL.text;
if( s != nil && [[s lowercaseString] hasPrefix:@"http"])
{
return TRUE;
}
else
{
[[[UIAlertView alloc] initWithTitle:@"Enter a URL" message:@"Enter a URL starting 'http://'" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show
];
return FALSE;
}
}
return TRUE;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if( [segue.identifier isEqualToString:@"ViewURL"])
{
NSString* s = self.textWebURL.text;
if( s != nil && [[s lowercaseString] hasPrefix:@"http"])
{
DetailViewController* nextVC = (DetailViewController*)segue.destinationViewController;
nextVC.detailItem = [SVGKSourceURL sourceFromURL:[NSURL URLWithString:s]];
}
}
else if( [segue.identifier hasPrefix:@"W3CTestSuite"] )
{
VCAllSpecImages* nextVC = (VCAllSpecImages*) segue.destinationViewController;
nextVC.pathInBundleToSVGSpecTestSuiteFolder = @"W3C_SVG_11_TestSuite";
}
else if( [segue.identifier hasPrefix:@"View"] )
{
NSString* sectionName = nil;
if( [segue.identifier isEqualToString:@"ViewSVGSpec"])
{
sectionName = @"SVG Spec";
}
else if( [segue.identifier isEqualToString:@"ViewContributed"])
{
sectionName = @"Contributed";
}
else if( [segue.identifier isEqualToString:@"ViewWeb"])
{
sectionName = @"Online / from Web";
}
else if( [segue.identifier isEqualToString:@"ViewSpecialTests"])
{
sectionName = @"Special";
}
NSString* path = [[NSBundle mainBundle] pathForResource:@"Licenses" ofType:@"plist"];
NSDictionary* allLicenses = [NSDictionary dictionaryWithContentsOfFile:path];
if( sectionName == nil )
[((VCGridOfImagesViewController*)segue.destinationViewController) displayAllSectionsFromDictionary:allLicenses];
else
{
[((VCGridOfImagesViewController*)segue.destinationViewController) displayOneSectionNamed:sectionName fromDictionary:[allLicenses objectForKey:sectionName]];
}
}
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[self performSegueWithIdentifier:@"ViewURL" sender:self];
return TRUE;
}
@end