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

Unified Diff: ios/chrome/widget_extension/widget_view.mm

Issue 2643723006: Add a fake cursor (blinking UIView) to the widget extension. (Closed)
Patch Set: Created 3 years, 11 months 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/widget_extension/widget_view.mm
diff --git a/ios/chrome/widget_extension/widget_view.mm b/ios/chrome/widget_extension/widget_view.mm
index 843adccd36fe5b34934dab71aa87cc878f48b023..bbe3b861da4f3b7d8cf06bcbb0e1047cf7d5eb28 100644
--- a/ios/chrome/widget_extension/widget_view.mm
+++ b/ios/chrome/widget_extension/widget_view.mm
@@ -8,13 +8,47 @@
#error "This file requires ARC support."
#endif
+@interface WidgetView ()
+
+@property(nonatomic, weak) UIView* cursor;
+
+@end
+
@implementation WidgetView
-#pragma mark - Lifecycle
+@synthesize cursor = _cursor;
- (instancetype)init {
self = [super initWithFrame:CGRectZero];
+ if (self) {
+ [self addCursor];
+ }
return self;
}
+- (void)addCursor {
Olivier 2017/01/19 10:33:07 declare method and add comment. Document that it s
lody 2017/01/19 13:17:55 Done.
+ UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero];
Olivier 2017/01/19 10:33:07 Is the cursor added directly in the widget view? S
lody 2017/01/19 13:17:55 Some of the current mocks say yes, some say no. I
+ self.cursor = cursor;
+ self.cursor.backgroundColor = [UIColor blueColor];
+ [self addSubview:_cursor];
Olivier 2017/01/19 10:33:07 cursor or self.cursor
lody 2017/01/19 13:17:55 Done.
+
+ [self.cursor setTranslatesAutoresizingMaskIntoConstraints:NO];
+ [NSLayoutConstraint activateConstraints:@[
+ [[self.cursor widthAnchor] constraintEqualToConstant:2],
+ [[self.cursor leadingAnchor] constraintEqualToAnchor:self.leadingAnchor
+ constant:40],
+ [[self.cursor heightAnchor] constraintEqualToConstant:40],
+ [[self.cursor centerYAnchor] constraintEqualToAnchor:self.centerYAnchor]
+ ]];
+
+ [UIView animateWithDuration:0.3
+ delay:0.0
+ options:UIViewAnimationOptionRepeat |
+ UIViewAnimationOptionAutoreverse
+ animations:^{
+ self.cursor.alpha = 0.0f;
+ }
+ completion:nil];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698