diff --git a/Examples/MainViewController.swift b/Examples/MainViewController.swift index f29efab6..d673c853 100644 --- a/Examples/MainViewController.swift +++ b/Examples/MainViewController.swift @@ -24,6 +24,7 @@ class MainViewController: UIViewController { let dataSource = ArrayDataSource(data: [ (BuiltInTransitionExampleViewController1.self, "Built In Animations"), (MatchExampleViewController1.self, "Match Animation"), + (SwiftUIMatchExampleViewController.self, "Match SwiftUI"), (MatchInCollectionExampleViewController1.self, "Match Cell in Collection"), (AppStoreViewController1.self, "App Store Transition"), ]) @@ -54,6 +55,7 @@ class MainViewController: UIViewController { layout: FlowLayout(lineSpacing: 10)) { (context) in let vc = context.data.0.init() + vc.modalPresentationStyle = .fullScreen self.present(vc, animated: true, completion: nil) } // TODO: Migrate the example to CollectionKit 2.2.0 diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Contents.json new file mode 100644 index 00000000..ad93011e --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash0_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Unsplash0_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Unsplash0_cell.png new file mode 100644 index 00000000..94bfe540 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash0_cell.imageset/Unsplash0_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Contents.json new file mode 100644 index 00000000..b897c82a --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash10_cell.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Unsplash10_cell.jpg b/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Unsplash10_cell.jpg new file mode 100644 index 00000000..4f86a73a Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash10_cell.imageset/Unsplash10_cell.jpg differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Contents.json new file mode 100644 index 00000000..7291d39f --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash1_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Unsplash1_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Unsplash1_cell.png new file mode 100644 index 00000000..f09b2f49 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash1_cell.imageset/Unsplash1_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Contents.json new file mode 100644 index 00000000..039092ab --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash2_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Unsplash2_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Unsplash2_cell.png new file mode 100644 index 00000000..b0f02b6c Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash2_cell.imageset/Unsplash2_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Contents.json new file mode 100644 index 00000000..51b9d95c --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash3_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Unsplash3_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Unsplash3_cell.png new file mode 100644 index 00000000..37c18170 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash3_cell.imageset/Unsplash3_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Contents.json new file mode 100644 index 00000000..bd560dd3 --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash4_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Unsplash4_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Unsplash4_cell.png new file mode 100644 index 00000000..e53c9797 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash4_cell.imageset/Unsplash4_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Contents.json new file mode 100644 index 00000000..48e5c54a --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash5_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Unsplash5_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Unsplash5_cell.png new file mode 100644 index 00000000..78b819ad Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash5_cell.imageset/Unsplash5_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Contents.json new file mode 100644 index 00000000..2dffb000 --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash6_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Unsplash6_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Unsplash6_cell.png new file mode 100644 index 00000000..de0fc276 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash6_cell.imageset/Unsplash6_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Contents.json new file mode 100644 index 00000000..1464e06d --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash7_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Unsplash7_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Unsplash7_cell.png new file mode 100644 index 00000000..b851d853 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash7_cell.imageset/Unsplash7_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Contents.json new file mode 100644 index 00000000..a53c6904 --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash8_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Unsplash8_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Unsplash8_cell.png new file mode 100644 index 00000000..874d24a6 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash8_cell.imageset/Unsplash8_cell.png differ diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Contents.json b/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Contents.json new file mode 100644 index 00000000..cfc910f6 --- /dev/null +++ b/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Unsplash9_cell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Unsplash9_cell.png b/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Unsplash9_cell.png new file mode 100644 index 00000000..3c3cffd5 Binary files /dev/null and b/Examples/Resources/Assets.xcassets/Foods/Unsplash9_cell.imageset/Unsplash9_cell.png differ diff --git a/Examples/SwiftUIMatchExample.swift b/Examples/SwiftUIMatchExample.swift new file mode 100644 index 00000000..26ab0ead --- /dev/null +++ b/Examples/SwiftUIMatchExample.swift @@ -0,0 +1,87 @@ +import UIKit +import SwiftUI + +class SwiftUIMatchExampleViewController: UIHostingController { + + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(rootView: ImagesTableView()) + + rootView.onTapRow = { image in + + let destinationViewController = UIHostingController(rootView: ImageViewWrapper(name: image.name, heroID: image.name) + .onTapGesture { [weak self] in + self?.presentedViewController?.dismiss(animated: true, completion: nil) + }) + + destinationViewController.isHeroEnabled = true + + self.present(destinationViewController, animated: true, completion: nil) + } + } + + @objc required dynamic init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +struct ImageInfo: Identifiable { + + let id: Int + let name: String +} + +struct ImagesTableView: View { + + var onTapRow: ((ImageInfo)->())? + + @State var images = (0...9).map{ ImageInfo(id: $0, name: "Unsplash\($0)") } + + var body: some View { + List(images) { image in + + HStack { + ImageViewWrapper(name: "\(image.name)_cell", heroID: image.name) + Spacer() + Text("Image number \(image.id)").padding() + }.onTapGesture { + self.onTapRow?(image) + } + } + } +} + +#if DEBUG +#endif + +struct ImageViewWrapper: View, UIViewRepresentable { + + let name: String + let heroID: String? + + func makeUIView(context: UIViewRepresentableContext) -> UIImageView { + UIImageView(frame: .zero) + } + + func updateUIView(_ uiView: UIImageView, context: UIViewRepresentableContext) { + uiView.image = UIImage(named: name) + uiView.hero.id = heroID + } +} + +//MARK: - Previews + +#if DEBUG + +struct ImagesTableView_Previews: PreviewProvider { + static var previews: some View { + ImagesTableView(onTapRow: nil) + } +} + +struct ImageViewWrapper_Previews: PreviewProvider { + static var previews: some View { + ImageViewWrapper(name: "Unsplash0", heroID: nil) + } +} + +#endif diff --git a/Hero.xcodeproj/project.pbxproj b/Hero.xcodeproj/project.pbxproj index b113df49..9586539a 100644 --- a/Hero.xcodeproj/project.pbxproj +++ b/Hero.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ 4D307DF520E3C6DC00DD9F65 /* HeroModifier+Advanced.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D307DF320E3C6DC00DD9F65 /* HeroModifier+Advanced.swift */; }; 5C5442AA2004092500E1E326 /* HeroCompatible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C69728F2002CDBD001A5051 /* HeroCompatible.swift */; }; 5C6972902002CDBD001A5051 /* HeroCompatible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C69728F2002CDBD001A5051 /* HeroCompatible.swift */; }; + 62EFDDAC236F4FC200F3E85E /* SwiftUIMatchExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EFDDAB236F4FC200F3E85E /* SwiftUIMatchExample.swift */; }; 83043017B73BC66DBB920D5C /* Pods_HeroExamples.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEE340F89FF0A49DD23A5A6E /* Pods_HeroExamples.framework */; }; A306D3B61E1C7A2E00B6C23A /* Hero.h in Headers */ = {isa = PBXBuildFile; fileRef = A306D3B41E1C7A2E00B6C23A /* Hero.h */; settings = {ATTRIBUTES = (Public, ); }; }; A306D3B91E1C7A2E00B6C23A /* Hero.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A306D3B21E1C7A2E00B6C23A /* Hero.framework */; }; @@ -186,6 +187,7 @@ 5C69728F2002CDBD001A5051 /* HeroCompatible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeroCompatible.swift; sourceTree = ""; }; 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 = ""; }; 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 = ""; }; + 62EFDDAB236F4FC200F3E85E /* SwiftUIMatchExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIMatchExample.swift; sourceTree = ""; }; 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 = ""; }; A304BF831DF2717900A03345 /* ImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = ""; }; @@ -565,6 +567,7 @@ A3D060C120833B4E00E48927 /* ExampleBaseViewController.swift */, A3D060BF20833B0700E48927 /* BuiltInTransitionExample.swift */, A3D060C320833D0400E48927 /* MatchExample.swift */, + 62EFDDAB236F4FC200F3E85E /* SwiftUIMatchExample.swift */, A3D060C5208348CB00E48927 /* MatchInCollectionExample.swift */, A3D060C720834FF100E48927 /* AppStoreCardExample.swift */, A33E60C21DE76CEF0065CBD8 /* Resources */, @@ -1098,6 +1101,7 @@ files = ( F482F0BE235D7808002E97ED /* UIColor+HexString.swift in Sources */, A33E60BD1DE7621C0065CBD8 /* UIKit+HeroExamples.swift in Sources */, + 62EFDDAC236F4FC200F3E85E /* SwiftUIMatchExample.swift in Sources */, A3D060C820834FF100E48927 /* AppStoreCardExample.swift in Sources */, A3D060C420833D0400E48927 /* MatchExample.swift in Sources */, A3D060C020833B0800E48927 /* BuiltInTransitionExample.swift in Sources */, @@ -1437,7 +1441,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = 683UGRW72Z; INFOPLIST_FILE = "$(SRCROOT)/Examples/Resources/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.HeroExamples; @@ -1454,7 +1458,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = 683UGRW72Z; INFOPLIST_FILE = "$(SRCROOT)/Examples/Resources/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.HeroExamples;