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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.mm
diff --git a/ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.mm b/ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..aebf2324767a796e938035ec158166df90e6be3d
--- /dev/null
+++ b/ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.mm
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/ui/ntp/recent_tabs/views/disclosure_view.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+
+// Animation duration for rotating the disclosure icon.
+const NSTimeInterval kDisclosureIconRotateDuration = 0.25;
+
+// Angles of the closure icon.
+// The rotation animation privileges rotating using the smallest angle. Setting
+// |kCollapsedIconAngle| to a value slightly less then 0 forces the animation to
+// always happen in the same half-plane.
+const CGFloat kCollapsedIconAngle = -0.00001;
+const CGFloat kExpandedIconAngle = M_PI;
+
+} // anonymous namespace
+
+@implementation DisclosureView
+
+- (instancetype)init {
+ UIImage* arrowImage = [[UIImage imageNamed:@"ntp_opentabs_recent_arrow"]
+ imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+ self = [super initWithImage:arrowImage];
+ return self;
+}
+
+- (void)setTransformWhenCollapsed:(BOOL)collapsed animated:(BOOL)animated {
+ CGFloat angle = collapsed ? kCollapsedIconAngle : kExpandedIconAngle;
+ if (animated) {
+ [UIView animateWithDuration:kDisclosureIconRotateDuration
+ animations:^{
+ self.transform = CGAffineTransformRotate(
+ CGAffineTransformIdentity, angle);
+ }];
+ } else {
+ self.transform = CGAffineTransformRotate(CGAffineTransformIdentity, angle);
+ }
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698