Commit b1309cfb authored by gambard's avatar gambard Committed by Commit bot

Tweak the share screen animation

Change the share view animation from fade in/slide up to slide up/slide down.

BUG=672773

Review-Url: https://codereview.chromium.org/2593563002
Cr-Commit-Position: refs/heads/master@{#439826}
parent 29cd6645
......@@ -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];
[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,9 +201,12 @@ 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 +
// 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment