| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bookmarks/bookmark_home_waiting_view.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_waiting_view.h" |
| 6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" | |
| 8 #include "base/mac/scoped_nsobject.h" | |
| 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 7 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.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/chrome/browser/ui/rtl_geometry.h" | 9 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" | 10 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
| 13 | 11 |
| 14 @interface BookmarkHomeWaitingView ()<MDCActivityIndicatorDelegate> { | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHomeWaitingView; | 13 #error "This file requires ARC support." |
| 16 } | 14 #endif |
| 15 |
| 16 @interface BookmarkHomeWaitingView ()<MDCActivityIndicatorDelegate> |
| 17 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; | 17 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; |
| 18 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; | 18 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; |
| 19 @end | 19 @end |
| 20 | 20 |
| 21 @implementation BookmarkHomeWaitingView | 21 @implementation BookmarkHomeWaitingView |
| 22 | 22 |
| 23 @synthesize activityIndicator = _activityIndicator; | 23 @synthesize activityIndicator = _activityIndicator; |
| 24 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; | 24 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; |
| 25 | 25 |
| 26 - (instancetype)initWithFrame:(CGRect)frame { | 26 - (instancetype)initWithFrame:(CGRect)frame { |
| 27 self = [super initWithFrame:frame]; | 27 self = [super initWithFrame:frame]; |
| 28 if (self) { | 28 if (self) { |
| 29 _propertyReleaser_BookmarkHomeWaitingView.Init( | |
| 30 self, [BookmarkHomeWaitingView class]); | |
| 31 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); | 29 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); |
| 32 self.autoresizingMask = | 30 self.autoresizingMask = |
| 33 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 31 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 34 } | 32 } |
| 35 return self; | 33 return self; |
| 36 } | 34 } |
| 37 | 35 |
| 38 - (void)startWaiting { | 36 - (void)startWaiting { |
| 39 dispatch_time_t delayForIndicatorAppearance = | 37 dispatch_time_t delayForIndicatorAppearance = |
| 40 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)); | 38 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)); |
| 41 dispatch_after(delayForIndicatorAppearance, dispatch_get_main_queue(), ^{ | 39 dispatch_after(delayForIndicatorAppearance, dispatch_get_main_queue(), ^{ |
| 42 base::scoped_nsobject<MDCActivityIndicator> activityIndicator( | 40 MDCActivityIndicator* activityIndicator = |
| 43 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]); | 41 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]; |
| 44 self.activityIndicator = activityIndicator; | 42 self.activityIndicator = activityIndicator; |
| 45 self.activityIndicator.delegate = self; | 43 self.activityIndicator.delegate = self; |
| 46 self.activityIndicator.autoresizingMask = | 44 self.activityIndicator.autoresizingMask = |
| 47 UIViewAutoresizingFlexibleLeadingMargin() | | 45 UIViewAutoresizingFlexibleLeadingMargin() | |
| 48 UIViewAutoresizingFlexibleTopMargin | | 46 UIViewAutoresizingFlexibleTopMargin | |
| 49 UIViewAutoresizingFlexibleTrailingMargin() | | 47 UIViewAutoresizingFlexibleTrailingMargin() | |
| 50 UIViewAutoresizingFlexibleBottomMargin; | 48 UIViewAutoresizingFlexibleBottomMargin; |
| 51 self.activityIndicator.center = CGPointMake( | 49 self.activityIndicator.center = CGPointMake( |
| 52 CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) / 2); | 50 CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) / 2); |
| 53 self.activityIndicator.cycleColors = ActivityIndicatorBrandedCycleColors(); | 51 self.activityIndicator.cycleColors = ActivityIndicatorBrandedCycleColors(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 - (void)activityIndicatorAnimationDidFinish: | 68 - (void)activityIndicatorAnimationDidFinish: |
| 71 (MDCActivityIndicator*)activityIndicator { | 69 (MDCActivityIndicator*)activityIndicator { |
| 72 [self.activityIndicator removeFromSuperview]; | 70 [self.activityIndicator removeFromSuperview]; |
| 73 self.activityIndicator = nil; | 71 self.activityIndicator = nil; |
| 74 if (self.animateOutCompletionBlock) | 72 if (self.animateOutCompletionBlock) |
| 75 self.animateOutCompletionBlock(); | 73 self.animateOutCompletionBlock(); |
| 76 self.animateOutCompletionBlock = nil; | 74 self.animateOutCompletionBlock = nil; |
| 77 } | 75 } |
| 78 | 76 |
| 79 @end | 77 @end |
| OLD | NEW |