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

Unified Diff: ios/chrome/search_widget_extension/search_widget_view_controller.mm

Issue 2858253002: Adding search widget UI and functionality. (Closed)
Patch Set: Created 3 years, 7 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/search_widget_extension/search_widget_view_controller.mm
diff --git a/ios/chrome/search_widget_extension/search_widget_view_controller.mm b/ios/chrome/search_widget_extension/search_widget_view_controller.mm
index 12e8838f2b407684113cc719268d4cf0b1bb57e2..5600af8875e645079d4d45914fe6c4f64b9d386a 100644
--- a/ios/chrome/search_widget_extension/search_widget_view_controller.mm
+++ b/ios/chrome/search_widget_extension/search_widget_view_controller.mm
@@ -68,10 +68,22 @@ NSString* const kXCallbackURLHost = @"x-callback-url";
- (void)viewDidLoad {
[super viewDidLoad];
+ UIVibrancyEffect* primary;
+ UIVibrancyEffect* secondary;
+ if (base::ios::IsRunningOnIOS10OrLater()) {
+ primary = [UIVibrancyEffect widgetPrimaryVibrancyEffect];
+ secondary = [UIVibrancyEffect widgetSecondaryVibrancyEffect];
+ } else {
+ primary = [UIVibrancyEffect notificationCenterVibrancyEffect];
+ secondary = [UIVibrancyEffect notificationCenterVibrancyEffect];
+ }
+
// A local variable is necessary here as the property is declared weak and the
// object would be deallocated before being retained by the addSubview call.
SearchWidgetView* widgetView =
- [[SearchWidgetView alloc] initWithActionTarget:self];
+ [[SearchWidgetView alloc] initWithActionTarget:self
+ primaryVibrancyEffect:primary
+ secondaryVibrancyEffect:secondary];
self.widgetView = widgetView;
[self.view addSubview:self.widgetView];
@@ -82,17 +94,13 @@ NSString* const kXCallbackURLHost = @"x-callback-url";
self.widgetView.translatesAutoresizingMaskIntoConstraints = NO;
- NSLayoutConstraint* heightAnchor = [self.widgetView.heightAnchor
- constraintEqualToAnchor:self.view.heightAnchor];
- heightAnchor.priority = 900;
-
[NSLayoutConstraint activateConstraints:@[
stkhapugin 2017/05/04 13:12:09 I think you can replace this code with a helper th
lody 2017/05/05 17:05:44 Done.
[self.widgetView.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
- [self.widgetView.widthAnchor constraintEqualToAnchor:self.view.widthAnchor],
[self.widgetView.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
- heightAnchor,
+ [self.widgetView.bottomAnchor
+ constraintEqualToAnchor:self.view.bottomAnchor],
[self.widgetView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
]];
}
@@ -123,6 +131,10 @@ NSString* const kXCallbackURLHost = @"x-callback-url";
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode
withMaximumSize:(CGSize)maxSize {
+ // Set the copied URL section here so that the fitting size is correctly
+ // calculated.
+ [self.widgetView
+ setCopiedURLVisible:(activeDisplayMode == NCWidgetDisplayModeExpanded)];
CGSize fittingSize = [self.widgetView
stkhapugin 2017/05/04 13:12:09 Please add a newline and a comment for line 138 an
lody 2017/05/05 17:05:44 Done.
systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
if (fittingSize.height > maxSize.height) {

Powered by Google App Engine
This is Rietveld 408576698