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

Side by Side Diff: ios/chrome/widget_extension/widget_view.mm

Issue 2809173002: Add support in widget to open search modes + copied link in app. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/widget_extension/widget_view.h" 5 #import "ios/chrome/widget_extension/widget_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if !defined(__has_feature) || !__has_feature(objc_arc) 9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support." 10 #error "This file requires ARC support."
11 #endif 11 #endif
12 12
13 namespace { 13 namespace {
14 14
15 const CGFloat kCursorHeight = 40; 15 const CGFloat kCursorHeight = 40;
16 const CGFloat kCursorWidth = 2; 16 const CGFloat kCursorWidth = 2;
17 const CGFloat kCursorHorizontalPadding = 10; 17 const CGFloat kCursorHorizontalPadding = 10;
18 const CGFloat kCursorVerticalPadding = 10; 18 const CGFloat kCursorVerticalPadding = 10;
19 const CGFloat kFakeboxHorizontalPadding = 40; 19 const CGFloat kFakeboxHorizontalPadding = 40;
20 const CGFloat kFakeboxVerticalPadding = 40; 20 const CGFloat kFakeboxVerticalPadding = 40;
21 21
22 } // namespace 22 } // namespace
23 23
24 @interface WidgetView () { 24 @interface WidgetView () {
25 __weak id<WidgetViewActionTarget> _target; 25 __weak id<WidgetViewActionTarget> _target;
26 } 26 }
27 27
28 @property(nonatomic) NSString* copiedLink;
lpromero 2017/04/11 13:24:03 NSString (as NSArray, NSDictionary, etc.) has a mu
lody 2017/04/11 14:38:18 Done.
29 @property(nonatomic) UILabel* copiedLinkURLLabel;
lpromero 2017/04/11 13:24:03 Add "strong" to be explicit.
lody 2017/04/11 14:38:18 Done.
28 @property(nonatomic, weak) UIView* cursor; 30 @property(nonatomic, weak) UIView* cursor;
29 31
30 // Creates and adds a fake omnibox with blinking cursor to the view and sets the 32 // Creates and adds a fake omnibox with blinking cursor to the view and sets the
31 // class cursor property. 33 // class cursor property.
32 - (void)addFakebox; 34 - (void)addFakebox;
33 35
34 @end 36 @end
35 37
36 @implementation WidgetView 38 @implementation WidgetView
37 39
40 @synthesize copiedLink = _copiedLink;
41 @synthesize copiedLinkURLLabel = _copiedLinkURLLabel;
42
38 @synthesize cursor = _cursor; 43 @synthesize cursor = _cursor;
39 44
40 - (instancetype)initWithActionTarget:(id<WidgetViewActionTarget>)target { 45 - (instancetype)initWithActionTarget:(id<WidgetViewActionTarget>)target {
41 self = [super initWithFrame:CGRectZero]; 46 self = [super initWithFrame:CGRectZero];
42 if (self) { 47 if (self) {
43 DCHECK(target); 48 DCHECK(target);
44 _target = target; 49 _target = target;
45 [self addFakebox]; 50 [self addFakebox];
46 } 51 }
47 return self; 52 return self;
48 } 53 }
49 54
50 - (void)addFakebox { 55 - (void)addFakebox {
51 UIView* fakebox = [[UIView alloc] initWithFrame:CGRectZero]; 56 UIView* fakebox = [[UIView alloc] initWithFrame:CGRectZero];
52 57
53 UIGestureRecognizer* tapRecognizer = 58 UIGestureRecognizer* tapRecognizer =
54 [[UITapGestureRecognizer alloc] initWithTarget:_target 59 [[UITapGestureRecognizer alloc] initWithTarget:_target
55 action:@selector(openApp:)]; 60 action:@selector(openSearch:)];
56 61
57 [fakebox addGestureRecognizer:tapRecognizer]; 62 [fakebox addGestureRecognizer:tapRecognizer];
58 [self addSubview:fakebox]; 63 [self addSubview:fakebox];
59 64
60 UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero]; 65 UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero];
61 self.cursor = cursor; 66 self.cursor = cursor;
62 self.cursor.backgroundColor = [UIColor blueColor]; 67 self.cursor.backgroundColor = [UIColor blueColor];
63 [fakebox addSubview:self.cursor]; 68 [fakebox addSubview:self.cursor];
64 69
65 [fakebox setTranslatesAutoresizingMaskIntoConstraints:NO]; 70 [fakebox setTranslatesAutoresizingMaskIntoConstraints:NO];
(...skipping 20 matching lines...) Expand all
86 [UIView animateWithDuration:0.3 91 [UIView animateWithDuration:0.3
87 delay:0.0 92 delay:0.0
88 options:UIViewAnimationOptionRepeat | 93 options:UIViewAnimationOptionRepeat |
89 UIViewAnimationOptionAutoreverse 94 UIViewAnimationOptionAutoreverse
90 animations:^{ 95 animations:^{
91 self.cursor.alpha = 0.0f; 96 self.cursor.alpha = 0.0f;
92 } 97 }
93 completion:nil]; 98 completion:nil];
94 } 99 }
95 100
101 - (void)updateCopiedURL:(NSString*)copiedURL {
102 self.copiedLink = copiedURL;
103 self.copiedLinkURLLabel.text = copiedURL;
104 }
105
96 @end 106 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698