VLCAboutViewController.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // VLCAboutViewController.m
  3. // AspenProject
  4. //
  5. // Created by Felix Paul Kühne on 07.04.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCAboutViewController.h"
  11. @implementation VLCAboutViewController
  12. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  13. {
  14. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  15. return self;
  16. }
  17. - (void)viewDidLoad
  18. {
  19. [super viewDidLoad];
  20. [self.webView loadHTMLString:[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil] baseURL:nil];
  21. self.webView.delegate = self;
  22. self.aspenVersion.text = [[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@" %@", kVLCVersionCodename];
  23. self.vlckitVersion.text = [NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]];
  24. UIBarButtonItem *dismissButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_DONE", @"")
  25. style:UIBarButtonItemStyleBordered
  26. target:self
  27. action:@selector(dismiss)];
  28. [dismissButton setBackgroundImage:[UIImage imageNamed:@"doneButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  29. [dismissButton setBackgroundImage:[UIImage imageNamed:@"doneButtonHighlight"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  30. [dismissButton setTitleTextAttributes:@{UITextAttributeTextShadowColor : [UIColor whiteColor], UITextAttributeTextColor : [UIColor blackColor]} forState:UIControlStateNormal];
  31. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  32. self.navigationItem.rightBarButtonItem = dismissButton;
  33. }
  34. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  35. {
  36. NSURL *requestURL = request.URL;
  37. if (![requestURL.scheme isEqualToString:@""])
  38. return ![[UIApplication sharedApplication] openURL:requestURL];
  39. else
  40. return YES;
  41. }
  42. - (void)webViewDidFinishLoad:(UIWebView *)webView
  43. {
  44. webView.alpha = 0.;
  45. CGFloat alpha = 1.;
  46. void (^animationBlock)() = ^() {
  47. webView.alpha = alpha;
  48. };
  49. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  50. webView.hidden = NO;
  51. };
  52. [UIView animateWithDuration:1. animations:animationBlock completion:completionBlock];
  53. }
  54. - (void)dismiss
  55. {
  56. [self dismissModalViewControllerAnimated:YES];
  57. }
  58. @end