VLCNetworkLoginViewController.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // VLCNetworkLoginViewController.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 11.08.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 "VLCNetworkLoginViewController.h"
  11. #import "UIBarButtonItem+Theme.h"
  12. @interface VLCNetworkLoginViewController ()
  13. @end
  14. @implementation VLCNetworkLoginViewController
  15. - (void)viewDidLoad
  16. {
  17. [super viewDidLoad];
  18. self.modalPresentationStyle = UIModalPresentationFormSheet;
  19. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  20. UIBarButtonItem *dismissButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(dismissWithAnimation:)];
  21. self.navigationItem.leftBarButtonItem = dismissButton;
  22. }
  23. self.title = NSLocalizedString(@"CONNECT_TO_SERVER", nil);
  24. [self.connectButton setTitle:NSLocalizedString(@"BUTTON_CONNECT",@"") forState:UIControlStateNormal];
  25. self.serverAddressHelpLabel.text = NSLocalizedString(@"ENTER_SERVER_ADDRESS_HELP",@"");
  26. self.loginHelpLabel.text = NSLocalizedString(@"ENTER_SERVER_CREDS_HELP",@"");
  27. self.usernameLabel.text = NSLocalizedString(@"USER_LABEL", @"");
  28. self.passwordLabel.text = NSLocalizedString(@"PASSWORD_LABEL", @"");
  29. }
  30. - (IBAction)dismissWithAnimation:(id)sender
  31. {
  32. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  33. [self.navigationController popViewControllerAnimated:YES];
  34. else
  35. [self dismissViewControllerAnimated:YES completion:nil];
  36. }
  37. - (IBAction)dismiss:(id)sender
  38. {
  39. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  40. [self.navigationController popViewControllerAnimated:NO];
  41. else
  42. [self dismissViewControllerAnimated:NO completion:nil];
  43. }
  44. - (IBAction)connectToServer:(id)sender
  45. {
  46. [self dismiss:nil];
  47. if (self.delegate) {
  48. if ([self.delegate respondsToSelector:@selector(loginToURL:confirmedWithUsername:andPassword:)]) {
  49. NSString *string = self.serverAddressField.text;
  50. if (![string hasPrefix:@"ftp://"])
  51. string = [NSString stringWithFormat:@"ftp://%@", string];
  52. [self.delegate loginToURL:[NSURL URLWithString:string] confirmedWithUsername:self.usernameField.text andPassword:self.passwordField.text];
  53. }
  54. }
  55. }
  56. @end