diff --git a/.kokoro b/.kokoro index 8d0dff6..d820c6d 100755 --- a/.kokoro +++ b/.kokoro @@ -1,4 +1,18 @@ #!/bin/bash +# +# Copyright 2017-present The Material Motion Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Fail on any error. set -e @@ -6,30 +20,36 @@ set -e # Display commands to stderr. set -x +KOKORO_RUNNER_VERSION="v3.*" + +fix_bazel_imports() { + if [ -z "$KOKORO_BUILD_NUMBER" ]; then + repo_prefix="" + else + repo_prefix="github/repo/" + fi + + # Fixes a bug in bazel where objc_library targets have a _ prefix. + find "${repo_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "s/import Motion(.+)/import _Motion\1/" {} + || true + stashed_dir=$(pwd) + reset_imports() { + # Undoes our source changes from above. + find "${stashed_dir}/${tests_dir_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "s/import _Motion(.+)/import Motion\1/" {} + || true + } + trap reset_imports EXIT +} + if [ ! -d .kokoro-ios-runner ]; then git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner fi pushd .kokoro-ios-runner git fetch > /dev/null -TAG=$(git tag -l "v3*" | sort | tail -n1) -git checkout $TAG > /dev/null +TAG=$(git tag --sort=v:refname -l "$KOKORO_RUNNER_VERSION" | tail -n1) +git checkout "$TAG" > /dev/null popd -if [ -z "$KOKORO_BUILD_NUMBER" ]; then - tests_dir_prefix="" -else - tests_dir_prefix="github/repo/" -fi - -# Fixes a bug in bazel where objc_library targets have a _ prefix. -find ${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import Motion(.+)/import _Motion\1/" {} + || true -stashed_dir=$(pwd) -reset_imports() { - # Undoes our source changes from above. - find ${stashed_dir}/${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import _Motion(.+)/import Motion\1/" {} + || true -} -trap reset_imports EXIT +fix_bazel_imports ./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0 diff --git a/BUILD b/BUILD index 4ade595..c77a8fc 100644 --- a/BUILD +++ b/BUILD @@ -1,3 +1,17 @@ +# Copyright 2017-present The Material Motion Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # Description: # Light-weight API for building UIViewController transitions. diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e5aaf1..406f7fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# 4.0.2 + +This patch release fixes a bug where the frames of custom presented views would be incorrectly set +to the view controller's frame. + +## Source changes + +* [Add support for transitions with custom presented views. (#55)](https://github.com/material-motion/motion-transitioning-objc/commit/2564bfdf42a2ba7c550656b95bc7dc98019468bb) (featherless) + +## Non-source changes + +* [Standardize the kokoro and bazel files. (#51)](https://github.com/material-motion/motion-transitioning-objc/commit/588b63dfae7471f3377041caa08496ef1fa74ced) (featherless) + # 4.0.1 This patch release resolves a build warning and migrates the project's continuous integration to diff --git a/MotionTransitioning.podspec b/MotionTransitioning.podspec index cde300b..17bda58 100644 --- a/MotionTransitioning.podspec +++ b/MotionTransitioning.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MotionTransitioning" s.summary = "Light-weight API for building UIViewController transitions." - s.version = "4.0.1" + s.version = "4.0.2" s.authors = "The Material Motion Authors" s.license = "Apache 2.0" s.homepage = "https://github.com/material-motion/transitioning-objc" diff --git a/Podfile.lock b/Podfile.lock index 28cf967..c4f0389 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,6 +1,6 @@ PODS: - CatalogByConvention (2.1.1) - - MotionTransitioning (4.0.1) + - MotionTransitioning (4.0.2) DEPENDENCIES: - CatalogByConvention @@ -12,7 +12,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CatalogByConvention: c3a5319de04250a7cd4649127fcfca5fe3322a43 - MotionTransitioning: 277501a1a1e6121c0ab523e6a3e00d64659c3367 + MotionTransitioning: 9885e68bd1501f1f8244b2e40081acd8cf3ac461 PODFILE CHECKSUM: 25d5942fb7698339a03667bb46c3fbb77529b92d diff --git a/WORKSPACE b/WORKSPACE index c01a93d..722a7a4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,3 +1,17 @@ +# Copyright 2017-present The Material Motion Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + git_repository( name = "build_bazel_rules_apple", remote = "https://github.com/bazelbuild/rules_apple.git", @@ -7,5 +21,5 @@ git_repository( git_repository( name = "bazel_ios_warnings", remote = "https://github.com/material-foundation/bazel_ios_warnings.git", - commit = "3e61cb5b60f52c8b9c77b5d62364d8b4d25e528f", + tag = "v1.0.1", ) diff --git a/src/private/MDMViewControllerTransitionCoordinator.m b/src/private/MDMViewControllerTransitionCoordinator.m index 9dd1e8f..4da369e 100644 --- a/src/private/MDMViewControllerTransitionCoordinator.m +++ b/src/private/MDMViewControllerTransitionCoordinator.m @@ -313,35 +313,43 @@ - (void)initiateTransition { _root.transitionContext = _transitionContext; UIViewController *from = [_transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; - if (from) { + UIView *fromView = [_transitionContext viewForKey:UITransitionContextFromViewKey]; + if (fromView == nil) { + fromView = from.view; + } + if (fromView != nil && fromView == from.view) { CGRect finalFrame = [_transitionContext finalFrameForViewController:from]; if (!CGRectIsEmpty(finalFrame)) { - from.view.frame = finalFrame; + fromView.frame = finalFrame; } } UIViewController *to = [_transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; - if (to) { + UIView *toView = [_transitionContext viewForKey:UITransitionContextToViewKey]; + if (toView == nil) { + toView = to.view; + } + if (toView != nil && toView == to.view) { CGRect finalFrame = [_transitionContext finalFrameForViewController:to]; if (!CGRectIsEmpty(finalFrame)) { - to.view.frame = finalFrame; + toView.frame = finalFrame; } - switch (_direction) { - case MDMTransitionDirectionForward: - [_transitionContext.containerView addSubview:to.view]; - break; + if (toView.superview == nil) { + switch (_direction) { + case MDMTransitionDirectionForward: + [_transitionContext.containerView addSubview:toView]; + break; - case MDMTransitionDirectionBackward: - if (!to.view.superview) { - [_transitionContext.containerView insertSubview:to.view atIndex:0]; - } - break; + case MDMTransitionDirectionBackward: + [_transitionContext.containerView insertSubview:toView atIndex:0]; + break; + } } - - [to.view layoutIfNeeded]; } + [toView layoutIfNeeded]; + [_root attemptFallback]; [self anticipateOnlyExplicitAnimations];