Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1221)

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_home_waiting_view.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_waiting_view.h"
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"
10 #import "ios/chrome/browser/ui/material_components/activity_indicator.h"
11 #import "ios/chrome/browser/ui/rtl_geometry.h"
12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato r/src/MaterialActivityIndicator.h"
13
14 @interface BookmarkHomeWaitingView ()<MDCActivityIndicatorDelegate> {
15 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHomeWaitingView;
16 }
17 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator;
18 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock;
19 @end
20
21 @implementation BookmarkHomeWaitingView
22
23 @synthesize activityIndicator = _activityIndicator;
24 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock;
25
26 - (instancetype)initWithFrame:(CGRect)frame {
27 self = [super initWithFrame:frame];
28 if (self) {
29 _propertyReleaser_BookmarkHomeWaitingView.Init(
30 self, [BookmarkHomeWaitingView class]);
31 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor();
32 self.autoresizingMask =
33 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
34 }
35 return self;
36 }
37
38 - (void)startWaiting {
39 dispatch_time_t delayForIndicatorAppearance =
40 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC));
41 dispatch_after(delayForIndicatorAppearance, dispatch_get_main_queue(), ^{
42 base::scoped_nsobject<MDCActivityIndicator> activityIndicator(
43 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]);
44 self.activityIndicator = activityIndicator;
45 self.activityIndicator.delegate = self;
46 self.activityIndicator.autoresizingMask =
47 UIViewAutoresizingFlexibleLeadingMargin() |
48 UIViewAutoresizingFlexibleTopMargin |
49 UIViewAutoresizingFlexibleTrailingMargin() |
50 UIViewAutoresizingFlexibleBottomMargin;
51 self.activityIndicator.center = CGPointMake(
52 CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) / 2);
53 self.activityIndicator.cycleColors = ActivityIndicatorBrandedCycleColors();
54 [self addSubview:self.activityIndicator];
55 [self.activityIndicator startAnimating];
56 });
57 }
58
59 - (void)stopWaitingWithCompletion:(ProceduralBlock)completion {
60 if (self.activityIndicator) {
61 self.animateOutCompletionBlock = completion;
62 [self.activityIndicator stopAnimating];
63 } else if (completion) {
64 completion();
65 }
66 }
67
68 #pragma mark - MDCActivityIndicatorDelegate
69
70 - (void)activityIndicatorAnimationDidFinish:
71 (MDCActivityIndicator*)activityIndicator {
72 [self.activityIndicator removeFromSuperview];
73 self.activityIndicator = nil;
74 if (self.animateOutCompletionBlock)
75 self.animateOutCompletionBlock();
76 self.animateOutCompletionBlock = nil;
77 }
78
79 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698