VCMainMenuViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #import "VCMainMenuViewController.h"
  2. #import "VCGridOfImagesViewController.h"
  3. #import "DetailViewController.h" // for web loading directly
  4. #import "SVGKSourceURL.h" // for web loading directly
  5. #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!)
  6. @interface VCMainMenuViewController ()
  7. @end
  8. @implementation VCMainMenuViewController
  9. -(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
  10. {
  11. if( [identifier isEqualToString:@"ViewURL"])
  12. {
  13. NSString* s = self.textWebURL.text;
  14. if( s != nil && [[s lowercaseString] hasPrefix:@"http"])
  15. {
  16. return TRUE;
  17. }
  18. else
  19. {
  20. [[[UIAlertView alloc] initWithTitle:@"Enter a URL" message:@"Enter a URL starting 'http://'" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show
  21. ];
  22. return FALSE;
  23. }
  24. }
  25. return TRUE;
  26. }
  27. -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  28. {
  29. if( [segue.identifier isEqualToString:@"ViewURL"])
  30. {
  31. NSString* s = self.textWebURL.text;
  32. if( s != nil && [[s lowercaseString] hasPrefix:@"http"])
  33. {
  34. DetailViewController* nextVC = (DetailViewController*)segue.destinationViewController;
  35. nextVC.detailItem = [SVGKSourceURL sourceFromURL:[NSURL URLWithString:s]];
  36. }
  37. }
  38. else if( [segue.identifier hasPrefix:@"W3CTestSuite"] )
  39. {
  40. VCAllSpecImages* nextVC = (VCAllSpecImages*) segue.destinationViewController;
  41. nextVC.pathInBundleToSVGSpecTestSuiteFolder = @"W3C_SVG_11_TestSuite";
  42. }
  43. else if( [segue.identifier hasPrefix:@"View"] )
  44. {
  45. NSString* sectionName = nil;
  46. if( [segue.identifier isEqualToString:@"ViewSVGSpec"])
  47. {
  48. sectionName = @"SVG Spec";
  49. }
  50. else if( [segue.identifier isEqualToString:@"ViewContributed"])
  51. {
  52. sectionName = @"Contributed";
  53. }
  54. else if( [segue.identifier isEqualToString:@"ViewWeb"])
  55. {
  56. sectionName = @"Online / from Web";
  57. }
  58. else if( [segue.identifier isEqualToString:@"ViewSpecialTests"])
  59. {
  60. sectionName = @"Special";
  61. }
  62. NSString* path = [[NSBundle mainBundle] pathForResource:@"Licenses" ofType:@"plist"];
  63. NSDictionary* allLicenses = [NSDictionary dictionaryWithContentsOfFile:path];
  64. if( sectionName == nil )
  65. [((VCGridOfImagesViewController*)segue.destinationViewController) displayAllSectionsFromDictionary:allLicenses];
  66. else
  67. {
  68. [((VCGridOfImagesViewController*)segue.destinationViewController) displayOneSectionNamed:sectionName fromDictionary:[allLicenses objectForKey:sectionName]];
  69. }
  70. }
  71. }
  72. -(BOOL)textFieldShouldReturn:(UITextField *)textField
  73. {
  74. [textField resignFirstResponder];
  75. [self performSegueWithIdentifier:@"ViewURL" sender:self];
  76. return TRUE;
  77. }
  78. @end