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 alert.popoverPresentationController.sourceRect = | |
233 CGRectMake(self.view.bounds.size.width - kFabInset - | |
Yuwei
2017/05/16 20:49:10
It could be easier to understand if you just do:
nicholss
2017/05/16 21:00:43
One better:
alert.popoverPresentationController
Yuwei
2017/05/16 21:18:54
Yep. That's much better :)
| |
234 _floatingButton.frame.size.width / 2.f, | |
235 self.view.bounds.size.height - kFabInset - | |
236 _floatingButton.frame.size.width, | |
237 1.0, 1.0); | |
238 | |
239 alert.popoverPresentationController.permittedArrowDirections = | |
240 UIPopoverArrowDirectionDown; | |
226 [self presentViewController:alert animated:YES completion:nil]; | 241 [self presentViewController:alert animated:YES completion:nil]; |
227 } | 242 } |
228 | 243 |
229 @end | 244 @end |
OLD | NEW |