1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support."
9 #import "remoting/ios/ui/pin_entry_view_controller.h"
11 #import "remoting/ios/utility.h"
13 @implementation PinEntryViewController
15 @synthesize delegate = _delegate;
16 @synthesize shouldPrompt = _shouldPrompt;
17 @synthesize pairingSupported = _pairingSupported;
19 // Override UIViewController
20 - (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil {
21 // NibName is the * part of your *.xib file
23 if ([Utility isPad]) {
24 self = [super initWithNibName:@"pin_entry_view_controller_ipad" bundle:nil];
27 [super initWithNibName:@"pin_entry_view_controller_iphone" bundle:nil];
30 // Custom initialization
35 // Override UIViewController
36 // Controls are not created immediately, properties must be set before the form
38 - (void)viewWillAppear:(BOOL)animated {
39 _host.text = _hostName;
41 [_switchAskAgain setOn:!_shouldPrompt];
43 // TODO (aboone) The switch is being hidden in all cases, this functionality
44 // is not scheduled for QA yet.
45 // if (!_pairingSupported) {
46 _switchAskAgain.hidden = YES;
47 _shouldSavePin.hidden = YES;
48 _switchAskAgain.enabled = NO;
50 [_hostPin becomeFirstResponder];
53 // @protocol UITextFieldDelegate, called when the 'enter' key is pressed
54 - (BOOL)textFieldShouldReturn:(UITextField*)textField {
55 [textField resignFirstResponder];
56 if (textField == _hostPin)
57 [self buttonConnectClicked:self];
61 - (IBAction)buttonCancelClicked:(id)sender {
62 [_delegate cancelledConnectToHostWithPin:self];
65 - (IBAction)buttonConnectClicked:(id)sender {
66 [_delegate connectToHostWithPin:self
68 shouldPrompt:!_switchAskAgain.isOn];