-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite the library using Swift concurrency (#30)
* Rewrite using Swift concurrency. * Update workflows * Run swift-format * Fix Xcode version in workflows * Update sample code * Update README * Run swift-format * Update README * Better approach for visionOS compatibility * Run swift-format * Update documentation * Add SwiftPackageIndex manifest * Replace PlatformImage with CGImage
- Loading branch information
1 parent
87a1980
commit 7aff8d1
Showing
56 changed files
with
1,063 additions
and
1,502 deletions.
There are no files selected for viewing
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,4 @@ | ||
version: 1 | ||
builder: | ||
configs: | ||
- documentation_targets: [NetworkImage] |
Large diffs are not rendered by default.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
Demo/NetworkImageDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
var body: some View { | ||
NavigationView { | ||
List { | ||
NavigationLink { | ||
ImagesView() | ||
.navigationTitle("Displaying Images") | ||
.inlineNavigationBarTitleDisplayMode() | ||
} label: { | ||
Label("Displaying Images", systemImage: "photo") | ||
} | ||
NavigationLink { | ||
StyledImagesView() | ||
.navigationTitle("Styling Images") | ||
.inlineNavigationBarTitleDisplayMode() | ||
} label: { | ||
Label("Styling Images", systemImage: "photo.artframe") | ||
} | ||
NavigationLink { | ||
PlaceholdersView() | ||
.navigationTitle("Placeholders and fallbacks") | ||
.inlineNavigationBarTitleDisplayMode() | ||
} label: { | ||
Label("Placeholders and fallbacks", systemImage: "square.dashed") | ||
} | ||
NavigationLink { | ||
RandomImageView() | ||
.navigationTitle("Random Image") | ||
.inlineNavigationBarTitleDisplayMode() | ||
} label: { | ||
Label("Random Image", systemImage: "questionmark.square") | ||
} | ||
NavigationLink { | ||
ImageListView() | ||
.navigationTitle("Image List") | ||
.inlineNavigationBarTitleDisplayMode() | ||
} label: { | ||
Label("Image List", systemImage: "scroll") | ||
} | ||
} | ||
.navigationTitle("NetworkImage") | ||
} | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
import NetworkImage | ||
import SwiftUI | ||
|
||
struct ImageListView: View { | ||
private struct Item: Identifiable { | ||
let id = UUID() | ||
let imageURL = URL.randomImageURL(size: .init(width: 400, height: 300)) | ||
} | ||
|
||
private let items = Array(repeating: (), count: 100).map(Item.init) | ||
|
||
var body: some View { | ||
ScrollView { | ||
LazyVStack { | ||
ForEach(self.items) { item in | ||
NetworkImage(url: item.imageURL, transaction: .init(animation: .default)) { image in | ||
image.resizable().scaledToFill() | ||
} | ||
.aspectRatio(1.333, contentMode: .fill) | ||
.clipShape(RoundedRectangle(cornerRadius: 4)) | ||
.overlay { | ||
RoundedRectangle(cornerRadius: 4) | ||
// This crashes in Xcode 15 beta 8 when running on visionOS simulator | ||
// .strokeBorder(Color.primary.opacity(0.25), lineWidth: 0.5) | ||
.strokeBorder(style: .init(lineWidth: 0.5)) | ||
.foregroundColor(Color.primary.opacity(0.25)) | ||
|
||
} | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
} | ||
|
||
struct ImageListView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ImageListView() | ||
} | ||
} |
17 changes: 7 additions & 10 deletions
17
Demo/Shared/SimpleExampleView.swift → Demo/Shared/ImagesView.swift
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 |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import NetworkImage | ||
import SwiftUI | ||
|
||
struct SimpleExampleView: View { | ||
private var content: some View { | ||
VStack { | ||
struct ImagesView: View { | ||
var body: some View { | ||
Form { | ||
NetworkImage(url: URL(string: "https://picsum.photos/id/1025/300/200")) | ||
.frame(width: 200, height: 200) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
NetworkImage(url: URL(string: "https://picsum.photos/id/237/300/200")) | ||
.frame(width: 200, height: 200) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
} | ||
.navigationTitle("Displaying Network Images") | ||
} | ||
} | ||
|
||
var body: some View { | ||
#if os(iOS) | ||
content.navigationBarTitleDisplayMode(.inline) | ||
#else | ||
content | ||
#endif | ||
struct ImagesView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ImagesView() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Demo/Shared/InlineNavigationBarTitleDisplayModeModifier.swift
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,17 @@ | ||
import SwiftUI | ||
|
||
extension View { | ||
func inlineNavigationBarTitleDisplayMode() -> some View { | ||
self.modifier(InlineNavigationBarTitleDisplayModeModifier()) | ||
} | ||
} | ||
|
||
struct InlineNavigationBarTitleDisplayModeModifier: ViewModifier { | ||
func body(content: Content) -> some View { | ||
#if os(iOS) || os(watchOS) | ||
content.navigationBarTitleDisplayMode(.inline) | ||
#else | ||
content | ||
#endif | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.