Skip to content

Commit

Permalink
Merge pull request #83 from jrsaruo/release/0.1.0
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
jrsaruo authored Dec 1, 2023
2 parents 82446ae + d934fbe commit 86282da
Show file tree
Hide file tree
Showing 21 changed files with 1,295 additions and 200 deletions.
2 changes: 2 additions & 0 deletions Demo/MediaViewerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
5A13B05F2AF61D530095729F /* CameraLikeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraLikeViewController.swift; sourceTree = "<group>"; };
5A13B0612AF62BFA0095729F /* PHImageFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHImageFetcher.swift; sourceTree = "<group>"; };
5A13B0652AF660710095729F /* CameraLikeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraLikeView.swift; sourceTree = "<group>"; };
5A13EC8B2AFD554C0007E405 /* MediaViewerDemo.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaViewerDemo.xctestplan; sourceTree = "<group>"; };
5A54612629A2594700F16456 /* MediaViewerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MediaViewerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
5A54612929A2594700F16456 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
5A54612B29A2594700F16456 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -114,6 +115,7 @@
5A54613229A2594800F16456 /* Assets.xcassets */,
5A54613429A2594800F16456 /* LaunchScreen.storyboard */,
5A54613729A2594800F16456 /* Info.plist */,
5A13EC8B2AFD554C0007E405 /* MediaViewerDemo.xctestplan */,
);
path = MediaViewerDemo;
sourceTree = "<group>";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5A54612529A2594700F16456"
BuildableName = "MediaViewerDemo.app"
BlueprintName = "MediaViewerDemo"
ReferencedContainer = "container:MediaViewerDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:MediaViewerDemo/MediaViewerDemo.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5A54612529A2594700F16456"
BuildableName = "MediaViewerDemo.app"
BlueprintName = "MediaViewerDemo"
ReferencedContainer = "container:MediaViewerDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5A54612529A2594700F16456"
BuildableName = "MediaViewerDemo.app"
BlueprintName = "MediaViewerDemo"
ReferencedContainer = "container:MediaViewerDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
37 changes: 37 additions & 0 deletions Demo/MediaViewerDemo/MediaViewerDemo.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"configurations" : [
{
"id" : "AB7B7AB7-CBF9-4FE7-BCC6-08C2C775A839",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"codeCoverage" : {
"targets" : [
{
"containerPath" : "container:..",
"identifier" : "MediaViewer",
"name" : "MediaViewer"
}
]
},
"targetForVariableExpansion" : {
"containerPath" : "container:MediaViewerDemo.xcodeproj",
"identifier" : "5A54612529A2594700F16456",
"name" : "MediaViewerDemo"
}
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:..",
"identifier" : "MediaViewerTests",
"name" : "MediaViewerTests"
}
}
],
"version" : 1
}
26 changes: 14 additions & 12 deletions Demo/MediaViewerDemo/Samples/Camera/CameraLikeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ final class CameraLikeViewController: UIViewController {
// MARK: - Methods

private func showLibrary() {
guard !assets.isEmpty else { return }
let mediaViewer = MediaViewerViewController(page: assets.count - 1, dataSource: self)
guard let lastAsset = assets.last else { return }
let mediaViewer = MediaViewerViewController(
opening: lastAsset,
dataSource: self
)
navigationController?.delegate = mediaViewer
navigationController?.pushViewController(mediaViewer, animated: true)
}
Expand Down Expand Up @@ -115,30 +118,29 @@ final class CameraLikeViewController: UIViewController {

extension CameraLikeViewController: MediaViewerDataSource {

func numberOfMedia(in mediaViewer: MediaViewerViewController) -> Int {
assets.count
func mediaIdentifiers(for mediaViewer: MediaViewerViewController) -> [PHAsset] {
assets
}

func mediaViewer(
_ mediaViewer: MediaViewerViewController,
mediaOnPage page: Int
mediaWith mediaIdentifier: PHAsset
) -> Media {
let asset = assets[page]
return .async { await PHImageFetcher.image(for: asset) }
.async { await PHImageFetcher.image(for: mediaIdentifier) }
}

func mediaViewer(
_ mediaViewer: MediaViewerViewController,
mediaWidthToHeightOnPage page: Int
widthToHeightOfMediaWith mediaIdentifier: PHAsset
) -> CGFloat? {
let asset = assets[page]
let size = PHImageFetcher.imageSize(of: asset)
let size = PHImageFetcher.imageSize(of: mediaIdentifier)
guard let size, size.height > 0 else { return nil }
return size.width / size.height
}

func transitionSourceView(
forCurrentPageOf mediaViewer: MediaViewerViewController
func mediaViewer(
_ mediaViewer: MediaViewerViewController,
transitionSourceViewForMediaWith mediaIdentifier: PHAsset
) -> UIView? {
cameraLikeView.showLibraryButton
}
Expand Down
Loading

0 comments on commit 86282da

Please sign in to comment.