Skip to content

Commit

Permalink
Fix iOS demo app failing and style on iOS 13
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Mattiello <[email protected]>
  • Loading branch information
JoeMatt committed Oct 29, 2019
1 parent 4da4f6e commit 89cc4a2
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 72 deletions.
7 changes: 6 additions & 1 deletion Examples/AppStoreCardExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ class AppStoreViewController2: ExampleBaseViewController {
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent neque est, hendrerit vitae nibh ultrices, accumsan elementum ante. Phasellus fringilla sapien non lorem consectetur, in ullamcorper tortor condimentum. Nulla tincidunt iaculis maximus. Sed ut urna urna. Nulla at sem vel neque scelerisque imperdiet. Donec ornare luctus dapibus. Donec aliquet ante augue, at pellentesque ipsum mollis eget. Cras vulputate mauris ac eleifend sollicitudin. Vivamus ut posuere odio. Suspendisse vulputate sem vel felis vehicula iaculis. Fusce sagittis, eros quis consequat tincidunt, arcu nunc ornare nulla, non egestas dolor ex at ipsum. Cras et massa sit amet quam imperdiet viverra. Mauris vitae finibus nibh, ac vulputate sapien.
"""

contentCard.backgroundColor = .white
if #available(iOS 13.0, *) {
contentCard.backgroundColor = .systemBackground
} else {
contentCard.backgroundColor = .white
}

contentCard.clipsToBounds = true

contentCard.addSubview(contentView)
Expand Down
6 changes: 5 additions & 1 deletion Examples/ExampleBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class ExampleBaseViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap)))

dismissButton.setTitle("Back", for: .normal)
Expand Down
28 changes: 15 additions & 13 deletions Examples/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class MainViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
if #available(iOS 13.0, *) {
view.backgroundColor = UIColor.systemBackground
} else {
view.backgroundColor = .white
}

view.addSubview(collectionView)

Expand All @@ -27,6 +31,13 @@ class MainViewController: UIViewController {
let viewSource = ClosureViewSource { (label: UILabel, data: SourceData, index) in
label.text = "\(index + 1). \(data.1)"
label.textAlignment = .center
if #available(iOS 13.0, *) {
label.textColor = .label
label.backgroundColor = .systemBackground
} else {
label.textColor = .darkText
label.backgroundColor = .white
}
label.layer.borderColor = UIColor.gray.cgColor
label.layer.borderWidth = 0.5
label.layer.cornerRadius = 8
Expand All @@ -51,22 +62,13 @@ class MainViewController: UIViewController {
imageView.contentMode = .scaleAspectFit

let imageProvider = SimpleViewProvider(views: [imageView], sizeStrategy: (.fill, .fit))

let legacyButton = UIButton(type: .system)
legacyButton.setTitle("Legacy Examples", for: .normal)
legacyButton.addTarget(self, action: #selector(showLegacy), for: .touchUpInside)
let legacyExamplesProvider = SimpleViewProvider(views: [legacyButton], sizeStrategy: (.fill, .fit))


collectionView.provider = ComposedProvider(
layout: FlowLayout(lineSpacing: 10).inset(by: UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)),
sections: [imageProvider, examplesProvider, legacyExamplesProvider]
sections: [imageProvider, examplesProvider]
)
}

@objc func showLegacy() {
hero.replaceViewController(with: viewController(forStoryboardName: "Main"))
}


override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
collectionView.frame = view.bounds
Expand Down
16 changes: 10 additions & 6 deletions Examples/MatchExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MatchExampleViewController1: ExampleBaseViewController {
class MatchExampleViewController2: ExampleBaseViewController {
let redView = UIView()
let blackView = UIView()
let whiteView = UIView()
let backgroundView = UIView()

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -65,19 +65,23 @@ class MatchExampleViewController2: ExampleBaseViewController {
blackView.cornerRadius = 8
view.addSubview(blackView)

whiteView.backgroundColor = .white
whiteView.cornerRadius = 8
if #available(iOS 13.0, *) {
backgroundView.backgroundColor = .systemBackground
} else {
backgroundView.backgroundColor = .white
}
backgroundView.cornerRadius = 8
// .useGlobalCoordinateSpace modifier is needed here otherwise it will be covered by redView during transition.
// see http://lkzhao.com/2018/03/02/hero-useglobalcoordinatespace-explained.html for detail
whiteView.hero.modifiers = [.translate(y: 500), .useGlobalCoordinateSpace]
view.addSubview(whiteView)
backgroundView.hero.modifiers = [.translate(y: 500), .useGlobalCoordinateSpace]
view.addSubview(backgroundView)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
redView.frame = view.bounds
blackView.frame.size = CGSize(width: 250, height: 60)
blackView.center = CGPoint(x: view.bounds.midX, y: 130)
whiteView.frame = CGRect(x: (view.bounds.width - 250) / 2, y: 180, width: 250, height: view.bounds.height - 320)
backgroundView.frame = CGRect(x: (view.bounds.width - 250) / 2, y: 180, width: 250, height: view.bounds.height - 320)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-1024.png",
"scale" : "1x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

16 changes: 8 additions & 8 deletions Examples/Resources/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="ahU-2K-RQA"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
45 changes: 43 additions & 2 deletions Hero.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
A32D2D131E501C4F008D35FF /* HeroModifier+HeroStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = A32D2D121E501C4F008D35FF /* HeroModifier+HeroStringConvertible.swift */; };
A32D2D141E501C4F008D35FF /* HeroModifier+HeroStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = A32D2D121E501C4F008D35FF /* HeroModifier+HeroStringConvertible.swift */; };
A33E60A51DE761C90065CBD8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A33E60A41DE761C90065CBD8 /* AppDelegate.swift */; };
A33E60AA1DE761C90065CBD8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A33E60A81DE761C90065CBD8 /* Main.storyboard */; };
A33E60AC1DE761C90065CBD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A33E60AB1DE761C90065CBD8 /* Assets.xcassets */; };
A33E60AF1DE761C90065CBD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A33E60AD1DE761C90065CBD8 /* LaunchScreen.storyboard */; };
A33E60BD1DE7621C0065CBD8 /* UIKit+HeroExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = A33E60B61DE7621C0065CBD8 /* UIKit+HeroExamples.swift */; };
Expand Down Expand Up @@ -128,8 +127,13 @@
B1D816EC1EF5A720007B9776 /* HeroTransition+Animate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D816EA1EF5A720007B9776 /* HeroTransition+Animate.swift */; };
B1D834041F02E7C0009E1E36 /* ConditionalPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D834031F02E7C0009E1E36 /* ConditionalPreprocessor.swift */; };
B1D834051F02E7C0009E1E36 /* ConditionalPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D834031F02E7C0009E1E36 /* ConditionalPreprocessor.swift */; };
DBA05BB41A704A4A17967918 /* Pods_HeroTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841FFA357ACB279D3F74CDEE /* Pods_HeroTests.framework */; };
F482F0BE235D7808002E97ED /* UIColor+HexString.swift in Sources */ = {isa = PBXBuildFile; fileRef = F482F0BD235D7808002E97ED /* UIColor+HexString.swift */; };
F482F0BF235D7808002E97ED /* UIColor+HexString.swift in Sources */ = {isa = PBXBuildFile; fileRef = F482F0BD235D7808002E97ED /* UIColor+HexString.swift */; };
F482F0C0235D7A3A002E97ED /* ImageGalleryCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3499D9E1DF2024E0049B541 /* ImageGalleryCollectionViewController.swift */; };
F482F0C1235D7A51002E97ED /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A304BF831DF2717900A03345 /* ImageViewController.swift */; };
F482F0C2235D7A5B002E97ED /* ImageCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = A304BF891DF647FC00A03345 /* ImageCells.swift */; };
F482F0C3235D7A65002E97ED /* ImageLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = A313499A1E1E2AED00EB5139 /* ImageLibrary.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -181,6 +185,8 @@
4D307DF320E3C6DC00DD9F65 /* HeroModifier+Advanced.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HeroModifier+Advanced.swift"; sourceTree = "<group>"; };
5C69728F2002CDBD001A5051 /* HeroCompatible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeroCompatible.swift; sourceTree = "<group>"; };
5CD4F09A588E81DA75C2BE38 /* Pods-HeroExamples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HeroExamples.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HeroExamples/Pods-HeroExamples.debug.xcconfig"; sourceTree = "<group>"; };
5CEC69C9A9A60129002FD931 /* Pods-HeroTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HeroTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-HeroTests/Pods-HeroTests.release.xcconfig"; sourceTree = "<group>"; };
841FFA357ACB279D3F74CDEE /* Pods_HeroTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HeroTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
86C87C73D89E75C8443B5071 /* Pods-HeroTvOSExamples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HeroTvOSExamples.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HeroTvOSExamples/Pods-HeroTvOSExamples.debug.xcconfig"; sourceTree = "<group>"; };
A304BF831DF2717900A03345 /* ImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
A304BF891DF647FC00A03345 /* ImageCells.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCells.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -278,8 +284,10 @@
B1D816EA1EF5A720007B9776 /* HeroTransition+Animate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HeroTransition+Animate.swift"; sourceTree = "<group>"; };
B1D834031F02E7C0009E1E36 /* ConditionalPreprocessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConditionalPreprocessor.swift; sourceTree = "<group>"; };
C377744CBFF1E24426E80F55 /* Pods-HeroExamples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HeroExamples.release.xcconfig"; path = "Pods/Target Support Files/Pods-HeroExamples/Pods-HeroExamples.release.xcconfig"; sourceTree = "<group>"; };
C51A6465EC2CB38D82F28B93 /* Pods-HeroTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HeroTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HeroTests/Pods-HeroTests.debug.xcconfig"; sourceTree = "<group>"; };
EEE340F89FF0A49DD23A5A6E /* Pods_HeroExamples.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HeroExamples.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F482F0BD235D7808002E97ED /* UIColor+HexString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+HexString.swift"; sourceTree = "<group>"; };
F482F0C5235D7C4C002E97ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
FD2306FDA4E15ADA91EFED44 /* Pods_HeroTvOSExamples.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HeroTvOSExamples.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -320,6 +328,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DBA05BB41A704A4A17967918 /* Pods_HeroTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -331,6 +340,7 @@
children = (
EEE340F89FF0A49DD23A5A6E /* Pods_HeroExamples.framework */,
FD2306FDA4E15ADA91EFED44 /* Pods_HeroTvOSExamples.framework */,
841FFA357ACB279D3F74CDEE /* Pods_HeroTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -406,6 +416,8 @@
C377744CBFF1E24426E80F55 /* Pods-HeroExamples.release.xcconfig */,
86C87C73D89E75C8443B5071 /* Pods-HeroTvOSExamples.debug.xcconfig */,
A41D45F75C2C4244CC105281 /* Pods-HeroTvOSExamples.release.xcconfig */,
C51A6465EC2CB38D82F28B93 /* Pods-HeroTests.debug.xcconfig */,
5CEC69C9A9A60129002FD931 /* Pods-HeroTests.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
Expand Down Expand Up @@ -739,6 +751,7 @@
isa = PBXNativeTarget;
buildConfigurationList = AF1E1B581E66822C00ECE039 /* Build configuration list for PBXNativeTarget "HeroTests" */;
buildPhases = (
3673D17D1C42FCAD03311A99 /* [CP] Check Pods Manifest.lock */,
AF1E1B4D1E66822C00ECE039 /* Sources */,
AF1E1B4E1E66822C00ECE039 /* Frameworks */,
AF1E1B4F1E66822C00ECE039 /* Resources */,
Expand Down Expand Up @@ -850,7 +863,6 @@
files = (
A33E60AF1DE761C90065CBD8 /* LaunchScreen.storyboard in Resources */,
A33E60AC1DE761C90065CBD8 /* Assets.xcassets in Resources */,
A33E60AA1DE761C90065CBD8 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -882,6 +894,28 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HeroExamples/Pods-HeroExamples-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3673D17D1C42FCAD03311A99 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-HeroTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
89DC76B30A0BF7FD724C24D3 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -993,9 +1027,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F482F0C0235D7A3A002E97ED /* ImageGalleryCollectionViewController.swift in Sources */,
A32D2CFC1E4A80DC008D35FF /* UIKit+HeroExamples.swift in Sources */,
2D1F7FE71E49DD90004D944B /* TVImageGalleryViewController.swift in Sources */,
F482F0BF235D7808002E97ED /* UIColor+HexString.swift in Sources */,
F482F0C1235D7A51002E97ED /* ImageViewController.swift in Sources */,
F482F0C3235D7A65002E97ED /* ImageLibrary.swift in Sources */,
F482F0C2235D7A5B002E97ED /* ImageCells.swift in Sources */,
2D1F7FE51E49DD90004D944B /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1112,6 +1150,7 @@
isa = PBXVariantGroup;
children = (
A33E60A91DE761C90065CBD8 /* Base */,
F482F0C5235D7C4C002E97ED /* en */,
);
name = Main.storyboard;
path = .;
Expand Down Expand Up @@ -1419,6 +1458,7 @@
};
AF1E1B591E66822C00ECE039 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C51A6465EC2CB38D82F28B93 /* Pods-HeroTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 4VSEW78TKT;
Expand All @@ -1434,6 +1474,7 @@
};
AF1E1B5A1E66822C00ECE039 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5CEC69C9A9A60129002FD931 /* Pods-HeroTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 4VSEW78TKT;
Expand Down
Loading

0 comments on commit 89cc4a2

Please sign in to comment.