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

Side by Side Diff: ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.mm

Issue 2589803002: Upstream Chrome on iOS source code [6/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 #include "ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.h"
6
7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support."
9 #endif
10
11 namespace {
12
13 // Animation duration for rotating the disclosure icon.
14 const NSTimeInterval kDisclosureIconRotateDuration = 0.25;
15
16 // Angles of the closure icon.
17 // The rotation animation privileges rotating using the smallest angle. Setting
18 // |kCollapsedIconAngle| to a value slightly less then 0 forces the animation to
19 // always happen in the same half-plane.
20 const CGFloat kCollapsedIconAngle = -0.00001;
21 const CGFloat kExpandedIconAngle = M_PI;
22
23 } // anonymous namespace
24
25 @implementation DisclosureView
26
27 - (instancetype)init {
28 UIImage* arrowImage = [[UIImage imageNamed:@"ntp_opentabs_recent_arrow"]
29 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
30 self = [super initWithImage:arrowImage];
31 return self;
32 }
33
34 - (void)setTransformWhenCollapsed:(BOOL)collapsed animated:(BOOL)animated {
35 CGFloat angle = collapsed ? kCollapsedIconAngle : kExpandedIconAngle;
36 if (animated) {
37 [UIView animateWithDuration:kDisclosureIconRotateDuration
38 animations:^{
39 self.transform = CGAffineTransformRotate(
40 CGAffineTransformIdentity, angle);
41 }];
42 } else {
43 self.transform = CGAffineTransformRotate(CGAffineTransformIdentity, angle);
44 }
45 }
46
47 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698