From 588b63dfae7471f3377041caa08496ef1fa74ced Mon Sep 17 00:00:00 2001 From: featherless Date: Thu, 26 Oct 2017 14:41:17 -0400 Subject: [PATCH 1/5] Standardize the kokoro and bazel files. (#51) * Standardize the kokoro and bazel files. Changes modeled after the latest changes made in https://github.com/material-motion/motion-animator-objc/tree/2ac68fb1ac4cdf61ba6fc7563a59417d39938074 * Revert the build_bazel_rules_apple version change. --- .kokoro | 52 ++++++++++++++++++++++++++++++++++++---------------- BUILD | 14 ++++++++++++++ WORKSPACE | 16 +++++++++++++++- 3 files changed, 65 insertions(+), 17 deletions(-) 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/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", ) From 2564bfdf42a2ba7c550656b95bc7dc98019468bb Mon Sep 17 00:00:00 2001 From: featherless Date: Mon, 13 Nov 2017 16:39:00 -0500 Subject: [PATCH 2/5] Add support for transitions with custom presented views. (#55) If the transition's presentation controller implements -presentedView, it's possible that viewForKey: will not return the view of either of the fore/back view controllers. This type of behavior is often implemented if the presented view controller's view is being embedded inside of another view. In order to support this behavior, we must use the viewForKey: API to fetch the desired view. If that view matches the view controller's view, then we can set the view's frame to the view controller's destination frame as we had been doing before. Otherwise, we make no modifications to the view's frame. --- .../MDMViewControllerTransitionCoordinator.m | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) 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]; From 45ecd163c07726b0c3fb1e0c332ec8f5bb504ba8 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Tue, 14 Nov 2017 11:47:06 -0500 Subject: [PATCH 3/5] Automatic changelog preparation for release. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e5aaf1..694daea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# #develop# + + TODO: Enumerate changes. + + # 4.0.1 This patch release resolves a build warning and migrates the project's continuous integration to From 0a01070900f36fde80bff46f029364c7c299d2ec Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Tue, 14 Nov 2017 11:50:53 -0500 Subject: [PATCH 4/5] Update changelog. --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 694daea..406f7fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ -# #develop# +# 4.0.2 - TODO: Enumerate changes. +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 From 1fffbaed35e99d8e6483fcce60d02adb3fcec334 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Tue, 14 Nov 2017 11:51:03 -0500 Subject: [PATCH 5/5] Bump the release. --- MotionTransitioning.podspec | 2 +- Podfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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