| 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" | 7 #include "base/mac/objc_release_properties.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" | 9 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" |
| 10 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" | 10 #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" | 11 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 const CGFloat kCloseButtonSize = 40; | 14 const CGFloat kCloseButtonSize = 40; |
| 15 const CGFloat kCloseButtonMargin = 10; | 15 const CGFloat kCloseButtonMargin = 10; |
| 16 const CGFloat kMinWidth = kCloseButtonSize + kCloseButtonMargin * 2; | 16 const CGFloat kMinWidth = kCloseButtonSize + kCloseButtonMargin * 2; |
| 17 const CGFloat kMinHeight = kMinWidth; | 17 const CGFloat kMinHeight = kMinWidth; |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 @interface ReaderModeView ()<MDCActivityIndicatorDelegate> { | 20 @interface ReaderModeView ()<MDCActivityIndicatorDelegate> { |
| 21 std::unique_ptr<dom_distiller::DistillerViewer> _viewer; | 21 std::unique_ptr<dom_distiller::DistillerViewer> _viewer; |
| 22 base::mac::ObjCPropertyReleaser _propertyReleaser_ReaderModeView; | |
| 23 } | 22 } |
| 24 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; | 23 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; |
| 25 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; | 24 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; |
| 26 @property(nonatomic, retain) UIButton* closeButton; | 25 @property(nonatomic, retain) UIButton* closeButton; |
| 27 | 26 |
| 28 @end | 27 @end |
| 29 | 28 |
| 30 @implementation ReaderModeView | 29 @implementation ReaderModeView |
| 31 @synthesize activityIndicator = _activityIndicator; | 30 @synthesize activityIndicator = _activityIndicator; |
| 32 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; | 31 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; |
| 33 @synthesize closeButton = _closeButton; | 32 @synthesize closeButton = _closeButton; |
| 34 @synthesize delegate = _delegate; | 33 @synthesize delegate = _delegate; |
| 35 | 34 |
| 36 - (instancetype)initWithFrame:(CGRect)frame | 35 - (instancetype)initWithFrame:(CGRect)frame |
| 37 delegate:(id<ReaderModeViewDelegate>)delegate { | 36 delegate:(id<ReaderModeViewDelegate>)delegate { |
| 38 self = [super initWithFrame:frame]; | 37 self = [super initWithFrame:frame]; |
| 39 if (self) { | 38 if (self) { |
| 40 _propertyReleaser_ReaderModeView.Init(self, [ReaderModeView class]); | |
| 41 _delegate = delegate; | 39 _delegate = delegate; |
| 42 | 40 |
| 43 self.backgroundColor = [UIColor whiteColor]; | 41 self.backgroundColor = [UIColor whiteColor]; |
| 44 | 42 |
| 45 self.autoresizingMask = | 43 self.autoresizingMask = |
| 46 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 44 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 47 | 45 |
| 48 _closeButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; | 46 _closeButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; |
| 49 [_closeButton addTarget:self | 47 [_closeButton addTarget:self |
| 50 action:@selector(close) | 48 action:@selector(close) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 - (instancetype)initWithFrame:(CGRect)frame { | 71 - (instancetype)initWithFrame:(CGRect)frame { |
| 74 NOTREACHED(); | 72 NOTREACHED(); |
| 75 return nil; | 73 return nil; |
| 76 } | 74 } |
| 77 | 75 |
| 78 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 76 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 79 NOTREACHED(); | 77 NOTREACHED(); |
| 80 return nil; | 78 return nil; |
| 81 } | 79 } |
| 82 | 80 |
| 81 - (void)dealloc { |
| 82 base::mac::ReleaseProperties(self); |
| 83 [super dealloc]; |
| 84 } |
| 85 |
| 83 - (void)start { | 86 - (void)start { |
| 84 [self.activityIndicator startAnimating]; | 87 [self.activityIndicator startAnimating]; |
| 85 } | 88 } |
| 86 | 89 |
| 87 - (void)stopWaitingWithCompletion:(ProceduralBlock)completion { | 90 - (void)stopWaitingWithCompletion:(ProceduralBlock)completion { |
| 88 if (self.activityIndicator.isAnimating) { | 91 if (self.activityIndicator.isAnimating) { |
| 89 self.animateOutCompletionBlock = completion; | 92 self.animateOutCompletionBlock = completion; |
| 90 [self.activityIndicator stopAnimating]; | 93 [self.activityIndicator stopAnimating]; |
| 91 } else if (completion) { | 94 } else if (completion) { |
| 92 completion(); | 95 completion(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 - (void)activityIndicatorAnimationDidFinish: | 131 - (void)activityIndicatorAnimationDidFinish: |
| 129 (MDCActivityIndicator*)activityIndicator { | 132 (MDCActivityIndicator*)activityIndicator { |
| 130 [self.activityIndicator removeFromSuperview]; | 133 [self.activityIndicator removeFromSuperview]; |
| 131 self.activityIndicator = nil; | 134 self.activityIndicator = nil; |
| 132 if (self.animateOutCompletionBlock) | 135 if (self.animateOutCompletionBlock) |
| 133 self.animateOutCompletionBlock(); | 136 self.animateOutCompletionBlock(); |
| 134 self.animateOutCompletionBlock = nil; | 137 self.animateOutCompletionBlock = nil; |
| 135 } | 138 } |
| 136 | 139 |
| 137 @end | 140 @end |
| OLD | NEW |