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

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

Issue 2643723006: Add a fake cursor (blinking UIView) to the widget extension. (Closed)
Patch Set: nit 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
« no previous file with comments | « no previous file | ios/chrome/widget_extension/widget_view_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d2c5a77ea27efe1d1bc675171590c3c510784604 100644
--- a/ios/chrome/widget_extension/widget_view.mm
+++ b/ios/chrome/widget_extension/widget_view.mm
@@ -8,13 +8,59 @@
#error "This file requires ARC support."
#endif
+namespace {
+
+const CGFloat kCursorHeight = 40;
+const CGFloat kCursorWidth = 2;
+const CGFloat kCursorHorizontalPadding = 40;
+
+} // namespace
+
+@interface WidgetView ()
+
+@property(nonatomic, weak) UIView* cursor;
+
+// Creates a cursor, adds it to the view and sets the class cursor property.
+- (void)addCursor;
+
+@end
+
@implementation WidgetView
-#pragma mark - Lifecycle
+@synthesize cursor = _cursor;
- (instancetype)init {
self = [super initWithFrame:CGRectZero];
+ if (self) {
+ [self addCursor];
+ }
return self;
}
+- (void)addCursor {
+ UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero];
+ self.cursor = cursor;
+ self.cursor.backgroundColor = [UIColor blueColor];
+ [self addSubview:self.cursor];
+
+ [self.cursor setTranslatesAutoresizingMaskIntoConstraints:NO];
+ [NSLayoutConstraint activateConstraints:@[
+ [[self.cursor widthAnchor] constraintEqualToConstant:kCursorWidth],
+ [[self.cursor leadingAnchor]
+ constraintEqualToAnchor:self.leadingAnchor
+ constant:kCursorHorizontalPadding],
+ [[self.cursor heightAnchor] constraintEqualToConstant:kCursorHeight],
+ [[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
« no previous file with comments | « no previous file | ios/chrome/widget_extension/widget_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698