OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/browser/ui/elements/selector_coordinator.h" | 5 #import "ios/chrome/browser/ui/elements/selector_coordinator.h" |
6 | 6 |
7 #import "base/mac/objc_property_releaser.h" | |
8 #import "ios/chrome/browser/ui/elements/selector_picker_view_controller.h" | 7 #import "ios/chrome/browser/ui/elements/selector_picker_view_controller.h" |
9 #import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.
h" | 8 #import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.
h" |
10 #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" | 9 #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" |
11 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
12 @interface SelectorCoordinator ()<SelectorViewControllerDelegate, | 15 @interface SelectorCoordinator ()<SelectorViewControllerDelegate, |
13 UIViewControllerTransitioningDelegate> { | 16 UIViewControllerTransitioningDelegate> { |
14 base::mac::ObjCPropertyReleaser _propertyReleaser_SelectorCoordinator; | |
15 __unsafe_unretained id<SelectorCoordinatorDelegate> _delegate; | 17 __unsafe_unretained id<SelectorCoordinatorDelegate> _delegate; |
16 } | 18 } |
17 | 19 |
18 // Redeclaration of infoBarPickerController as readwrite. | 20 // Redeclaration of infoBarPickerController as readwrite. |
19 @property(nonatomic, nullable, retain) | 21 @property(nonatomic, nullable, strong) |
20 SelectorPickerViewController* selectorPickerViewController; | 22 SelectorPickerViewController* selectorPickerViewController; |
21 | 23 |
22 @end | 24 @end |
23 | 25 |
24 @implementation SelectorCoordinator | 26 @implementation SelectorCoordinator |
25 | 27 |
26 @synthesize options = _options; | 28 @synthesize options = _options; |
27 @synthesize defaultOption = _defaultOption; | 29 @synthesize defaultOption = _defaultOption; |
28 @synthesize delegate = _delegate; | 30 @synthesize delegate = _delegate; |
29 @synthesize selectorPickerViewController = _selectorPickerViewController; | 31 @synthesize selectorPickerViewController = _selectorPickerViewController; |
30 | 32 |
31 - (nullable instancetype)initWithBaseViewController: | |
32 (nullable UIViewController*)viewController { | |
33 self = [super initWithBaseViewController:viewController]; | |
34 if (self) { | |
35 _propertyReleaser_SelectorCoordinator.Init(self, | |
36 [SelectorCoordinator class]); | |
37 } | |
38 return self; | |
39 } | |
40 | |
41 - (void)start { | 33 - (void)start { |
42 self.selectorPickerViewController = [[[SelectorPickerViewController alloc] | 34 self.selectorPickerViewController = |
43 initWithOptions:self.options | 35 [[SelectorPickerViewController alloc] initWithOptions:self.options |
44 default:self.defaultOption] autorelease]; | 36 default:self.defaultOption]; |
45 self.selectorPickerViewController.delegate = self; | 37 self.selectorPickerViewController.delegate = self; |
46 | 38 |
47 self.selectorPickerViewController.modalTransitionStyle = | 39 self.selectorPickerViewController.modalTransitionStyle = |
48 UIModalTransitionStyleCoverVertical; | 40 UIModalTransitionStyleCoverVertical; |
49 self.selectorPickerViewController.modalPresentationStyle = | 41 self.selectorPickerViewController.modalPresentationStyle = |
50 UIModalPresentationCustom; | 42 UIModalPresentationCustom; |
51 self.selectorPickerViewController.transitioningDelegate = self; | 43 self.selectorPickerViewController.transitioningDelegate = self; |
52 | 44 |
53 [self.baseViewController | 45 [self.baseViewController |
54 presentViewController:self.selectorPickerViewController | 46 presentViewController:self.selectorPickerViewController |
(...skipping 13 matching lines...) Expand all Loading... |
68 [self.delegate selectorCoordinator:self didCompleteWithSelection:option]; | 60 [self.delegate selectorCoordinator:self didCompleteWithSelection:option]; |
69 [self stop]; | 61 [self stop]; |
70 } | 62 } |
71 | 63 |
72 #pragma mark UIViewControllerTransitioningDelegate | 64 #pragma mark UIViewControllerTransitioningDelegate |
73 | 65 |
74 - (UIPresentationController*) | 66 - (UIPresentationController*) |
75 presentationControllerForPresentedViewController:(UIViewController*)presented | 67 presentationControllerForPresentedViewController:(UIViewController*)presented |
76 presentingViewController:(UIViewController*)presenting | 68 presentingViewController:(UIViewController*)presenting |
77 sourceViewController:(UIViewController*)source { | 69 sourceViewController:(UIViewController*)source { |
78 return [[[SelectorPickerPresentationController alloc] | 70 return [[SelectorPickerPresentationController alloc] |
79 initWithPresentedViewController:self.selectorPickerViewController | 71 initWithPresentedViewController:self.selectorPickerViewController |
80 presentingViewController:self.baseViewController] autorelease]; | 72 presentingViewController:self.baseViewController]; |
81 } | 73 } |
82 | 74 |
83 @end | 75 @end |
OLD | NEW |