| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/ios/app/host_view_controller.h" | 9 #import "remoting/ios/app/host_view_controller.h" |
| 10 | 10 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 _client.keyboardInterpreter->HandleDeleteEvent(0); | 186 _client.keyboardInterpreter->HandleDeleteEvent(0); |
| 187 } | 187 } |
| 188 | 188 |
| 189 #pragma mark - Private | 189 #pragma mark - Private |
| 190 | 190 |
| 191 - (void)didTap:(id)sender { | 191 - (void)didTap:(id)sender { |
| 192 // TODO(nicholss): The FAB is being used to launch an alert window with | 192 // TODO(nicholss): The FAB is being used to launch an alert window with |
| 193 // more options. This is not ideal but it gets us an easy way to make a | 193 // more options. This is not ideal but it gets us an easy way to make a |
| 194 // modal window option selector. Replace this with a real menu later. | 194 // modal window option selector. Replace this with a real menu later. |
| 195 | 195 |
| 196 UIAlertController* alert = | 196 UIAlertController* alert = [UIAlertController |
| 197 [UIAlertController alertControllerWithTitle:@"Remote Settings" | 197 alertControllerWithTitle:@"Remote Settings" |
| 198 message:nil | 198 message:nil |
| 199 preferredStyle:UIAlertControllerStyleAlert]; | 199 preferredStyle:UIAlertControllerStyleActionSheet]; |
| 200 | 200 |
| 201 if ([self isKeyboardActive]) { | 201 if ([self isKeyboardActive]) { |
| 202 void (^hideKeyboardHandler)(UIAlertAction*) = ^(UIAlertAction*) { | 202 void (^hideKeyboardHandler)(UIAlertAction*) = ^(UIAlertAction*) { |
| 203 NSLog(@"Will hide keyboard."); | |
| 204 [self hideKeyboard]; | 203 [self hideKeyboard]; |
| 205 }; | 204 }; |
| 206 [alert addAction:[UIAlertAction actionWithTitle:@"Hide Keyboard" | 205 [alert addAction:[UIAlertAction actionWithTitle:@"Hide Keyboard" |
| 207 style:UIAlertActionStyleDefault | 206 style:UIAlertActionStyleDefault |
| 208 handler:hideKeyboardHandler]]; | 207 handler:hideKeyboardHandler]]; |
| 209 } else { | 208 } else { |
| 210 void (^showKeyboardHandler)(UIAlertAction*) = ^(UIAlertAction*) { | 209 void (^showKeyboardHandler)(UIAlertAction*) = ^(UIAlertAction*) { |
| 211 NSLog(@"Will show keyboard."); | |
| 212 [self showKeyboard]; | 210 [self showKeyboard]; |
| 213 }; | 211 }; |
| 214 [alert addAction:[UIAlertAction actionWithTitle:@"Show Keyboard" | 212 [alert addAction:[UIAlertAction actionWithTitle:@"Show Keyboard" |
| 215 style:UIAlertActionStyleDefault | 213 style:UIAlertActionStyleDefault |
| 216 handler:showKeyboardHandler]]; | 214 handler:showKeyboardHandler]]; |
| 217 } | 215 } |
| 218 void (^disconnectHandler)(UIAlertAction*) = ^(UIAlertAction*) { | 216 void (^disconnectHandler)(UIAlertAction*) = ^(UIAlertAction*) { |
| 219 [_client disconnectFromHost]; | 217 [_client disconnectFromHost]; |
| 220 [self dismissViewControllerAnimated:YES completion:nil]; | 218 [self dismissViewControllerAnimated:YES completion:nil]; |
| 221 }; | 219 }; |
| 222 [alert addAction:[UIAlertAction actionWithTitle:@"Disconnect" | 220 [alert addAction:[UIAlertAction actionWithTitle:@"Disconnect" |
| 223 style:UIAlertActionStyleCancel | 221 style:UIAlertActionStyleDefault |
| 224 handler:disconnectHandler]]; | 222 handler:disconnectHandler]]; |
| 225 | 223 |
| 224 void (^cancelHandler)(UIAlertAction*) = ^(UIAlertAction*) { |
| 225 [alert dismissViewControllerAnimated:YES completion:nil]; |
| 226 }; |
| 227 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" |
| 228 style:UIAlertActionStyleCancel |
| 229 handler:cancelHandler]]; |
| 230 |
| 231 alert.popoverPresentationController.sourceView = self.view; |
| 232 // Target the alert menu at the top middle of the FAB. |
| 233 alert.popoverPresentationController.sourceRect = CGRectMake( |
| 234 _floatingButton.center.x, _floatingButton.frame.origin.y, 1.0, 1.0); |
| 235 |
| 236 alert.popoverPresentationController.permittedArrowDirections = |
| 237 UIPopoverArrowDirectionDown; |
| 226 [self presentViewController:alert animated:YES completion:nil]; | 238 [self presentViewController:alert animated:YES completion:nil]; |
| 227 } | 239 } |
| 228 | 240 |
| 229 @end | 241 @end |
| OLD | NEW |