-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to set only height as downsampling size. (#11)
* Use swift-docc-plugin v1.3.0 * Update README * Create DownSamplingSize to allow either width or heght as size defining parameter. * Update downsampling code to follow the parameter change. * Delete unused init * Update Example * Update Example * Refactor
- Loading branch information
Showing
14 changed files
with
367 additions
and
82 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
.swiftpm/xcode/xcshareddata/xcschemes/AsyncDownSamplingImage.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1540" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES" | ||
buildArchitectures = "Automatic"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "AsyncDownSamplingImage" | ||
BuildableName = "AsyncDownSamplingImage" | ||
BlueprintName = "AsyncDownSamplingImage" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "AsyncDownSamplingImageTests" | ||
BuildableName = "AsyncDownSamplingImageTests" | ||
BlueprintName = "AsyncDownSamplingImageTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</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"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "AsyncDownSamplingImage" | ||
BuildableName = "AsyncDownSamplingImage" | ||
BlueprintName = "AsyncDownSamplingImage" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// DownSamplingVStackView.swift | ||
// Example | ||
// | ||
// Created by Fumiya Tanaka on 2024/07/06. | ||
// | ||
|
||
import SwiftUI | ||
import AsyncDownSamplingImage | ||
|
||
struct DownSamplingVStackView: View { | ||
|
||
@State private var url = Util.VStack.url | ||
@State private var height: Double = 240 | ||
|
||
var body: some View { | ||
VStack { | ||
Text("AsyncDownSamplingImage") | ||
ScrollView { | ||
LazyVStack() { | ||
ForEach(0..<1000, id: \.self) { _ in | ||
AsyncDownSamplingImage( | ||
url: url, | ||
downsampleSize: .height( | ||
Util.VStack.bufferedImageHeight | ||
) | ||
) { image in | ||
image.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(height: height) | ||
} onFail: { error in | ||
Text("Error: \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview { | ||
DownSamplingVStackView() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// StandardView+VStack.swift | ||
// Example | ||
// | ||
// Created by Fumiya Tanaka on 2024/07/06. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct StandardView_VStack: View { | ||
|
||
@State private var url = Util.VStack.url | ||
@State private var height: Double = 240 | ||
|
||
var body: some View { | ||
VStack { | ||
Text("Default AsyncImage") | ||
ScrollView { | ||
LazyVStack() { | ||
ForEach(0..<1000, id: \.self) { _ in | ||
AsyncImage(url: url) { phase in | ||
switch phase { | ||
case .empty: | ||
ProgressView().progressViewStyle(.circular) | ||
case .failure(let error): | ||
Text("Error: \(error.localizedDescription)") | ||
case .success(let image): | ||
image.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(height: height) | ||
@unknown default: | ||
fatalError() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview { | ||
StandardView_VStack() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Util.swift | ||
// Example | ||
// | ||
// Created by Fumiya Tanaka on 2024/07/06. | ||
// | ||
|
||
import Foundation | ||
|
||
enum Util { | ||
enum Grid { | ||
static let url = URL(string: "https://picsum.photos/1000/1000") | ||
static let bufferedImageSize = CGSize(width: 160, height: 160) | ||
} | ||
enum VStack { | ||
static let url = URL(string: "https://picsum.photos/800/600") | ||
static let bufferedImageHeight = 320.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.