VLCNetworkLoginViewController.m 1.8 KB

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