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

Side by Side Diff: ios/chrome/share_extension/share_view_controller.mm

Issue 2617993002: Animate IOS Share extension button. (Closed)
Patch Set: feedback 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <MobileCoreServices/MobileCoreServices.h> 5 #import <MobileCoreServices/MobileCoreServices.h>
6 6
7 #import "ios/chrome/share_extension/share_view_controller.h" 7 #import "ios/chrome/share_extension/share_view_controller.h"
8 8
9 #import "base/ios/block_types.h" 9 #import "base/ios/block_types.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 10 matching lines...) Expand all
21 using ItemBlock = void (^)(id idResponse, NSError* error); 21 using ItemBlock = void (^)(id idResponse, NSError* error);
22 22
23 namespace { 23 namespace {
24 24
25 // Minimum size around the widget 25 // Minimum size around the widget
26 const CGFloat kShareExtensionMargin = 15; 26 const CGFloat kShareExtensionMargin = 15;
27 const CGFloat kShareExtensionMaxWidth = 390; 27 const CGFloat kShareExtensionMaxWidth = 390;
28 // Clip the last separator out of the table view. 28 // Clip the last separator out of the table view.
29 const CGFloat kScreenShotWidth = 100; 29 const CGFloat kScreenShotWidth = 100;
30 const CGFloat kScreenShotHeight = 100; 30 const CGFloat kScreenShotHeight = 100;
31 const CGFloat kAnimationDuration = 0.3;
32 const CGFloat kMediumAlpha = 0.5; 31 const CGFloat kMediumAlpha = 0.5;
33 32
34 } // namespace 33 } // namespace
35 34
36 @interface ShareViewController ()<ShareExtensionViewActionTarget> { 35 @interface ShareViewController ()<ShareExtensionViewActionTarget> {
37 // This constrains the center of the widget to be vertically in the center 36 // This constrains the center of the widget to be vertically in the center
38 // of the the screen. It has to be modified for the appearance and dismissal 37 // of the the screen. It has to be modified for the appearance and dismissal
39 // animation. 38 // animation.
40 NSLayoutConstraint* _widgetVerticalPlacementConstraint; 39 NSLayoutConstraint* _widgetVerticalPlacementConstraint;
41 40
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (_image) { 122 if (_image) {
124 [self.shareView setScreenshot:_image]; 123 [self.shareView setScreenshot:_image];
125 } 124 }
126 dispatch_async(dispatch_get_main_queue(), ^{ 125 dispatch_async(dispatch_get_main_queue(), ^{
127 // Center the widget. 126 // Center the widget.
128 [_widgetVerticalPlacementConstraint setActive:NO]; 127 [_widgetVerticalPlacementConstraint setActive:NO];
129 _widgetVerticalPlacementConstraint = [_shareView.centerYAnchor 128 _widgetVerticalPlacementConstraint = [_shareView.centerYAnchor
130 constraintEqualToAnchor:self.view.centerYAnchor]; 129 constraintEqualToAnchor:self.view.centerYAnchor];
131 [_widgetVerticalPlacementConstraint setActive:YES]; 130 [_widgetVerticalPlacementConstraint setActive:YES];
132 [self.maskView setAlpha:0]; 131 [self.maskView setAlpha:0];
133 [UIView animateWithDuration:kAnimationDuration 132 [UIView animateWithDuration:ui_util::kAnimationDuration
134 animations:^{ 133 animations:^{
135 [self.maskView setAlpha:1]; 134 [self.maskView setAlpha:1];
136 [self.view layoutIfNeeded]; 135 [self.view layoutIfNeeded];
137 }]; 136 }];
138 }); 137 });
139 } 138 }
140 139
141 - (void)displayErrorView { 140 - (void)displayErrorView {
142 NSString* errorMessage = 141 NSString* errorMessage =
143 NSLocalizedString(@"IDS_IOS_ERROR_MESSAGE_SHARE_EXTENSION", 142 NSLocalizedString(@"IDS_IOS_ERROR_MESSAGE_SHARE_EXTENSION",
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // The direction (up or down) is relative to the output (cancel or submit). 246 // The direction (up or down) is relative to the output (cancel or submit).
248 [_widgetVerticalPlacementConstraint setActive:NO]; 247 [_widgetVerticalPlacementConstraint setActive:NO];
249 if (item) { 248 if (item) {
250 _widgetVerticalPlacementConstraint = 249 _widgetVerticalPlacementConstraint =
251 [_shareView.bottomAnchor constraintEqualToAnchor:self.view.topAnchor]; 250 [_shareView.bottomAnchor constraintEqualToAnchor:self.view.topAnchor];
252 } else { 251 } else {
253 _widgetVerticalPlacementConstraint = 252 _widgetVerticalPlacementConstraint =
254 [_shareView.topAnchor constraintEqualToAnchor:self.view.bottomAnchor]; 253 [_shareView.topAnchor constraintEqualToAnchor:self.view.bottomAnchor];
255 } 254 }
256 [_widgetVerticalPlacementConstraint setActive:YES]; 255 [_widgetVerticalPlacementConstraint setActive:YES];
257 [UIView animateWithDuration:kAnimationDuration 256 [UIView animateWithDuration:ui_util::kAnimationDuration
258 animations:^{ 257 animations:^{
259 [self.maskView setAlpha:0]; 258 [self.maskView setAlpha:0];
260 [self.view layoutIfNeeded]; 259 [self.view layoutIfNeeded];
261 } 260 }
262 completion:^(BOOL finished) { 261 completion:^(BOOL finished) {
263 NSArray* returnItem = item ? @[ item ] : @[]; 262 NSArray* returnItem = item ? @[ item ] : @[];
264 [self.extensionContext completeRequestReturningItems:returnItem 263 [self.extensionContext completeRequestReturningItems:returnItem
265 completionHandler:nil]; 264 completionHandler:nil];
266 }]; 265 }];
267 } 266 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 [self dismissAndReturnItem:_shareItem]; 342 [self dismissAndReturnItem:_shareItem];
344 }]; 343 }];
345 } 344 }
346 345
347 - (void)shareExtensionView:(id)sender 346 - (void)shareExtensionView:(id)sender
348 typeChanged:(app_group::ShareExtensionItemType)type { 347 typeChanged:(app_group::ShareExtensionItemType)type {
349 [self setItemType:type]; 348 [self setItemType:type];
350 } 349 }
351 350
352 @end 351 @end
OLDNEW
« no previous file with comments | « ios/chrome/share_extension/share_extension_view.mm ('k') | ios/chrome/share_extension/strings/ios_share_extension_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698