OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/reader_mode/reader_mode_view.h" | 5 #import "ios/chrome/browser/ui/reader_mode/reader_mode_view.h" |
6 | 6 |
7 #include "base/mac/objc_property_releaser.h" | |
8 #include "base/mac/scoped_nsobject.h" | |
9 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" | 7 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" |
10 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" | 8 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" |
11 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" | 9 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
12 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
13 namespace { | 15 namespace { |
14 const CGFloat kCloseButtonSize = 40; | 16 const CGFloat kCloseButtonSize = 40; |
15 const CGFloat kCloseButtonMargin = 10; | 17 const CGFloat kCloseButtonMargin = 10; |
16 const CGFloat kMinWidth = kCloseButtonSize + kCloseButtonMargin * 2; | 18 const CGFloat kMinWidth = kCloseButtonSize + kCloseButtonMargin * 2; |
17 const CGFloat kMinHeight = kMinWidth; | 19 const CGFloat kMinHeight = kMinWidth; |
18 } // namespace | 20 } // namespace |
19 | 21 |
20 @interface ReaderModeView ()<MDCActivityIndicatorDelegate> { | 22 @interface ReaderModeView ()<MDCActivityIndicatorDelegate> { |
21 std::unique_ptr<dom_distiller::DistillerViewer> _viewer; | 23 std::unique_ptr<dom_distiller::DistillerViewer> _viewer; |
22 base::mac::ObjCPropertyReleaser _propertyReleaser_ReaderModeView; | |
23 } | 24 } |
24 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; | 25 @property(nonatomic, strong) MDCActivityIndicator* activityIndicator; |
25 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; | 26 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; |
26 @property(nonatomic, retain) UIButton* closeButton; | 27 @property(nonatomic, strong) UIButton* closeButton; |
27 | 28 |
28 @end | 29 @end |
29 | 30 |
30 @implementation ReaderModeView | 31 @implementation ReaderModeView |
31 @synthesize activityIndicator = _activityIndicator; | 32 @synthesize activityIndicator = _activityIndicator; |
32 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; | 33 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; |
33 @synthesize closeButton = _closeButton; | 34 @synthesize closeButton = _closeButton; |
34 @synthesize delegate = _delegate; | 35 @synthesize delegate = _delegate; |
35 | 36 |
36 - (instancetype)initWithFrame:(CGRect)frame | 37 - (instancetype)initWithFrame:(CGRect)frame |
37 delegate:(id<ReaderModeViewDelegate>)delegate { | 38 delegate:(id<ReaderModeViewDelegate>)delegate { |
38 self = [super initWithFrame:frame]; | 39 self = [super initWithFrame:frame]; |
39 if (self) { | 40 if (self) { |
40 _propertyReleaser_ReaderModeView.Init(self, [ReaderModeView class]); | |
41 _delegate = delegate; | 41 _delegate = delegate; |
42 | 42 |
43 self.backgroundColor = [UIColor whiteColor]; | 43 self.backgroundColor = [UIColor whiteColor]; |
44 | 44 |
45 self.autoresizingMask = | 45 self.autoresizingMask = |
46 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 46 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
47 | 47 |
48 _closeButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; | 48 _closeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; |
49 [_closeButton addTarget:self | 49 [_closeButton addTarget:self |
50 action:@selector(close) | 50 action:@selector(close) |
51 forControlEvents:UIControlEventTouchUpInside]; | 51 forControlEvents:UIControlEventTouchUpInside]; |
52 [_closeButton setTitle:@"X" forState:UIControlStateNormal]; | 52 [_closeButton setTitle:@"X" forState:UIControlStateNormal]; |
53 _closeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | | 53 _closeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | |
54 UIViewAutoresizingFlexibleTopMargin; | 54 UIViewAutoresizingFlexibleTopMargin; |
55 | 55 |
56 _activityIndicator = | 56 _activityIndicator = |
57 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]; | 57 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]; |
58 _activityIndicator.delegate = self; | 58 _activityIndicator.delegate = self; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 - (void)activityIndicatorAnimationDidFinish: | 128 - (void)activityIndicatorAnimationDidFinish: |
129 (MDCActivityIndicator*)activityIndicator { | 129 (MDCActivityIndicator*)activityIndicator { |
130 [self.activityIndicator removeFromSuperview]; | 130 [self.activityIndicator removeFromSuperview]; |
131 self.activityIndicator = nil; | 131 self.activityIndicator = nil; |
132 if (self.animateOutCompletionBlock) | 132 if (self.animateOutCompletionBlock) |
133 self.animateOutCompletionBlock(); | 133 self.animateOutCompletionBlock(); |
134 self.animateOutCompletionBlock = nil; | 134 self.animateOutCompletionBlock = nil; |
135 } | 135 } |
136 | 136 |
137 @end | 137 @end |
OLD | NEW |