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

Unified Diff: ios/chrome/share_extension/share_view_controller.mm

Issue 2593563002: Tweak the share screen animation (Closed)
Patch Set: Fix direction Created 4 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/share_extension/share_view_controller.mm
diff --git a/ios/chrome/share_extension/share_view_controller.mm b/ios/chrome/share_extension/share_view_controller.mm
index cfd96dd90ff60adbffcf114b6b902b6e09a8191b..8ea9e871b2560d788e77bc23c826b08596f3b913 100644
--- a/ios/chrome/share_extension/share_view_controller.mm
+++ b/ios/chrome/share_extension/share_view_controller.mm
@@ -59,9 +59,6 @@ const CGFloat kMediumAlpha = 0.5;
// Loads all the shared elements from the extension context and update the UI.
- (void)loadElementsFromContext;
-// Performs a fade in animation for the whole widget.
-- (void)fadeIn;
-
// Sets constaints to the widget so that margin are at least
// kShareExtensionMargin points and widget width is closest up to
// kShareExtensionMaxWidth points.
@@ -75,6 +72,8 @@ const CGFloat kMediumAlpha = 0.5;
@synthesize shareView = _shareView;
@synthesize itemType = _itemType;
+#pragma mark - UIViewController
+
- (void)viewDidLoad {
[super viewDidLoad];
@@ -94,9 +93,13 @@ const CGFloat kMediumAlpha = 0.5;
[self constrainWidgetWidth];
- // Center the widget in the screen.
+ // Position the widget below the screen. It will be slided up with an
+ // animation.
_centerYConstraint = [[shareView centerYAnchor]
constraintEqualToAnchor:[self.view centerYAnchor]];
+ [_centerYConstraint setConstant:(self.view.frame.size.height +
+ self.shareView.frame.size.height) /
+ 2];
[_centerYConstraint setActive:YES];
[[[shareView centerXAnchor] constraintEqualToAnchor:[self.view centerXAnchor]]
setActive:YES];
@@ -105,9 +108,23 @@ const CGFloat kMediumAlpha = 0.5;
[self.shareView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self loadElementsFromContext];
- [self fadeIn];
}
+- (void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+
+ // Center the widget.
+ [_centerYConstraint setConstant:0];
+ [self.maskView setAlpha:0];
+ [UIView animateWithDuration:kAnimationDuration
+ animations:^{
+ [self.maskView setAlpha:1];
Olivier 2016/12/20 16:31:44 Is this needed? Will this not also fade in ?
gambard 2016/12/20 16:33:49 The dark background view will fade in and the exte
+ [self.view layoutIfNeeded];
+ }];
+}
+
+#pragma mark - Private methods
+
- (void)constrainWidgetWidth {
// Setting the constraints.
NSDictionary* views = @{ @"share" : self.shareView };
@@ -140,17 +157,6 @@ const CGFloat kMediumAlpha = 0.5;
forAxis:UILayoutConstraintAxisHorizontal];
}
-- (void)fadeIn {
- // Fade in animation.
- [self.maskView setAlpha:0];
- [self.shareView setAlpha:0];
- [UIView animateWithDuration:kAnimationDuration
- animations:^{
- [self.maskView setAlpha:kMediumAlpha];
- [self.shareView setAlpha:1];
- }];
-}
-
- (void)loadElementsFromContext {
NSString* typeURL = static_cast<NSString*>(kUTTypeURL);
for (NSExtensionItem* item in self.extensionContext.inputItems) {
@@ -195,10 +201,13 @@ const CGFloat kMediumAlpha = 0.5;
}
- (void)dismissAndReturnItem:(NSExtensionItem*)item {
- // Set the Y center constraints so the whole extension slides up out of the
+ // Set the Y center constraints so the whole extension slides out of the
// screen. Constant is relative to the center of the screen.
- [_centerYConstraint setConstant:-(self.view.frame.size.height +
- self.shareView.frame.size.height) /
+ // The direction (up or down) is relative to the output (cancel or submit).
+ NSInteger direction = item ? -1 : 1;
+ [_centerYConstraint setConstant:direction *
+ (self.view.frame.size.height +
+ self.shareView.frame.size.height) /
2];
[UIView animateWithDuration:kAnimationDuration
animations:^{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698