VLCNetworkLoginViewController.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }
  28. - (IBAction)dismissWithAnimation:(id)sender
  29. {
  30. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  31. [self.navigationController popViewControllerAnimated:YES];
  32. else
  33. [self dismissViewControllerAnimated:YES completion:nil];
  34. }
  35. - (IBAction)dismiss:(id)sender
  36. {
  37. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  38. [self.navigationController popViewControllerAnimated:NO];
  39. else
  40. [self dismissViewControllerAnimated:NO completion:nil];
  41. }
  42. - (IBAction)connectToServer:(id)sender
  43. {
  44. [self dismiss:nil];
  45. if (self.delegate) {
  46. if ([self.delegate respondsToSelector:@selector(loginToURL:confirmedWithUsername:andPassword:)]) {
  47. NSString *string = self.serverAddressField.text;
  48. if (![string hasPrefix:@"ftp://"])
  49. string = [NSString stringWithFormat:@"ftp://%@", string];
  50. [self.delegate loginToURL:[NSURL URLWithString:string] confirmedWithUsername:self.usernameField.text andPassword:self.passwordField.text];
  51. }
  52. }
  53. }
  54. @end