gif previews + handle apple wallpapers
This commit is contained in:
1 parent
4d6b093ffd
commit
ad280b1a6b
4 files changed
+82
-21
No files matched your search
@@ -10,6 +10,7 @@
|
|||||||
6F09B7BB2DEB873F00CDE89C /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 6F09B7BA2DEB873F00CDE89C /* ZIPFoundation */; };
|
6F09B7BB2DEB873F00CDE89C /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 6F09B7BA2DEB873F00CDE89C /* ZIPFoundation */; };
|
||||||
6F09BA332E00808300CDE89C /* Dynamic in Frameworks */ = {isa = PBXBuildFile; productRef = 6F09BA322E00808300CDE89C /* Dynamic */; };
|
6F09BA332E00808300CDE89C /* Dynamic in Frameworks */ = {isa = PBXBuildFile; productRef = 6F09BA322E00808300CDE89C /* Dynamic */; };
|
||||||
6FB105552E26D3EC00185A5C /* CachedAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 6FB105542E26D3EC00185A5C /* CachedAsyncImage */; };
|
6FB105552E26D3EC00185A5C /* CachedAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 6FB105542E26D3EC00185A5C /* CachedAsyncImage */; };
|
||||||
|
6FB105602E26DD0A00185A5C /* Giffy in Frameworks */ = {isa = PBXBuildFile; productRef = 6FB1055F2E26DD0A00185A5C /* Giffy */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
files = (
|
files = (
|
||||||
6FB105552E26D3EC00185A5C /* CachedAsyncImage in Frameworks */,
|
6FB105552E26D3EC00185A5C /* CachedAsyncImage in Frameworks */,
|
||||||
6F09BA332E00808300CDE89C /* Dynamic in Frameworks */,
|
6F09BA332E00808300CDE89C /* Dynamic in Frameworks */,
|
||||||
|
6FB105602E26DD0A00185A5C /* Giffy in Frameworks */,
|
||||||
6F09B7BB2DEB873F00CDE89C /* ZIPFoundation in Frameworks */,
|
6F09B7BB2DEB873F00CDE89C /* ZIPFoundation in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -80,6 +82,7 @@
|
|||||||
6F09B7BA2DEB873F00CDE89C /* ZIPFoundation */,
|
6F09B7BA2DEB873F00CDE89C /* ZIPFoundation */,
|
||||||
6F09BA322E00808300CDE89C /* Dynamic */,
|
6F09BA322E00808300CDE89C /* Dynamic */,
|
||||||
6FB105542E26D3EC00185A5C /* CachedAsyncImage */,
|
6FB105542E26D3EC00185A5C /* CachedAsyncImage */,
|
||||||
|
6FB1055F2E26DD0A00185A5C /* Giffy */,
|
||||||
);
|
);
|
||||||
productName = "Pocket Poster";
|
productName = "Pocket Poster";
|
||||||
productReference = 6F09B79D2DEB694B00CDE89C /* Pocket Poster.app */;
|
productReference = 6F09B79D2DEB694B00CDE89C /* Pocket Poster.app */;
|
||||||
@@ -113,6 +116,7 @@
|
|||||||
6F09B7B92DEB873F00CDE89C /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
|
6F09B7B92DEB873F00CDE89C /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
|
||||||
6F09BA312E00808300CDE89C /* XCRemoteSwiftPackageReference "Dynamic" */,
|
6F09BA312E00808300CDE89C /* XCRemoteSwiftPackageReference "Dynamic" */,
|
||||||
6FB105532E26D3EC00185A5C /* XCRemoteSwiftPackageReference "swiftui-cached-async-image" */,
|
6FB105532E26D3EC00185A5C /* XCRemoteSwiftPackageReference "swiftui-cached-async-image" */,
|
||||||
|
6FB1055E2E26DD0A00185A5C /* XCRemoteSwiftPackageReference "Giffy" */,
|
||||||
);
|
);
|
||||||
preferredProjectObjectVersion = 77;
|
preferredProjectObjectVersion = 77;
|
||||||
productRefGroup = 6F09B79E2DEB694B00CDE89C /* Products */;
|
productRefGroup = 6F09B79E2DEB694B00CDE89C /* Products */;
|
||||||
@@ -378,6 +382,14 @@
|
|||||||
minimumVersion = 2.1.1;
|
minimumVersion = 2.1.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
6FB1055E2E26DD0A00185A5C /* XCRemoteSwiftPackageReference "Giffy" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/tfmart/Giffy.git";
|
||||||
|
requirement = {
|
||||||
|
branch = main;
|
||||||
|
kind = branch;
|
||||||
|
};
|
||||||
|
};
|
||||||
/* End XCRemoteSwiftPackageReference section */
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
/* Begin XCSwiftPackageProductDependency section */
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
@@ -396,6 +408,11 @@
|
|||||||
package = 6FB105532E26D3EC00185A5C /* XCRemoteSwiftPackageReference "swiftui-cached-async-image" */;
|
package = 6FB105532E26D3EC00185A5C /* XCRemoteSwiftPackageReference "swiftui-cached-async-image" */;
|
||||||
productName = CachedAsyncImage;
|
productName = CachedAsyncImage;
|
||||||
};
|
};
|
||||||
|
6FB1055F2E26DD0A00185A5C /* Giffy */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = 6FB1055E2E26DD0A00185A5C /* XCRemoteSwiftPackageReference "Giffy" */;
|
||||||
|
productName = Giffy;
|
||||||
|
};
|
||||||
/* End XCSwiftPackageProductDependency section */
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = 6F09B7952DEB694B00CDE89C /* Project object */;
|
rootObject = 6F09B7952DEB694B00CDE89C /* Project object */;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "73a600cf677d3bb2b929c60349923a2a4e20e6a9ef10509bf043d2ad2229ca95",
|
"originHash" : "9d3a39dff9bda7be6921bb553210388e3a68059324656c0ace5f2eb2378819b1",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "dynamic",
|
"identity" : "dynamic",
|
||||||
@@ -10,6 +10,24 @@
|
|||||||
"version" : "1.2.0"
|
"version" : "1.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "flanimatedimage",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/Flipboard/FLAnimatedImage.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "d4f07b6f164d53c1212c3e54d6460738b1981e9f",
|
||||||
|
"version" : "1.0.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "giffy",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/tfmart/Giffy.git",
|
||||||
|
"state" : {
|
||||||
|
"branch" : "main",
|
||||||
|
"revision" : "595bd0a0bc292d32da4b26b8bca4347235ab2556"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swiftui-cached-async-image",
|
"identity" : "swiftui-cached-async-image",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
class DownloadableWallpaper: Identifiable, Codable {
|
class DownloadableWallpaper: Identifiable, Codable {
|
||||||
var name: String
|
var name: String
|
||||||
var description: String
|
var description: String?
|
||||||
var url: String
|
var url: String
|
||||||
var preview: String
|
var preview: String
|
||||||
var authors: String
|
var authors: String?
|
||||||
var type: WallpaperType?
|
var type: WallpaperType?
|
||||||
|
|
||||||
init(name: String, description: String, authors: String, preview: String, url: String, version: String) {
|
init(name: String, description: String?, authors: String?, preview: String, url: String, version: String) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.authors = authors
|
self.authors = authors
|
||||||
@@ -24,4 +24,8 @@ class DownloadableWallpaper: Identifiable, Codable {
|
|||||||
enum WallpaperType: String, Codable {
|
enum WallpaperType: String, Codable {
|
||||||
case custom, apple, template
|
case custom, apple, template
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func previewIsGif() -> Bool {
|
||||||
|
return preview.hasSuffix(".gif")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import CachedAsyncImage
|
import CachedAsyncImage
|
||||||
|
import Giffy
|
||||||
|
|
||||||
let MIN_SIZE: CGFloat = 165
|
let MIN_SIZE: CGFloat = 165
|
||||||
|
|
||||||
@@ -50,21 +51,40 @@ struct ExploreView: View {
|
|||||||
} else {
|
} else {
|
||||||
LazyVGrid(columns: gridItemLayout) {
|
LazyVGrid(columns: gridItemLayout) {
|
||||||
ForEach(wallpapers) { wallpaper in
|
ForEach(wallpapers) { wallpaper in
|
||||||
if searchTerm == "" || wallpaper.name.lowercased().contains(searchTerm.lowercased()) || wallpaper.authors.lowercased().contains(searchTerm.lowercased()) {
|
if searchTerm == "" || wallpaper.name.lowercased().contains(searchTerm.lowercased()) || (wallpaper.authors ?? "").lowercased().contains(searchTerm.lowercased()) {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
DownloadManager.shared.startTendiesDownload(for: cowabungaAPI.getDownloadURLForWallpaper(wallpaper: wallpaper))
|
DownloadManager.shared.startTendiesDownload(for: cowabungaAPI.getDownloadURLForWallpaper(wallpaper: wallpaper))
|
||||||
}) {
|
}) {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
CachedAsyncImage(url: cowabungaAPI.getPreviewURLForWallpaper(wallpaper: wallpaper), urlCache: .imageCache) { image in
|
if wallpaper.previewIsGif() {
|
||||||
image
|
AsyncGiffy(url: cowabungaAPI.getPreviewURLForWallpaper(wallpaper: wallpaper)) { phase in
|
||||||
.resizable()
|
switch phase {
|
||||||
.aspectRatio(contentMode: .fill)
|
case .loading:
|
||||||
.frame(maxWidth: .infinity)
|
Color.gray
|
||||||
.cornerRadius(10, corners: .topLeft)
|
.frame(height: MIN_SIZE)
|
||||||
.cornerRadius(10, corners: .topRight)
|
case .error:
|
||||||
} placeholder: {
|
Color.red
|
||||||
Color.gray
|
.frame(height: MIN_SIZE)
|
||||||
.frame(height: MIN_SIZE)
|
case .success(let giffy):
|
||||||
|
giffy
|
||||||
|
.aspectRatio(contentMode: .fill)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.cornerRadius(10, corners: .topLeft)
|
||||||
|
.cornerRadius(10, corners: .topRight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CachedAsyncImage(url: cowabungaAPI.getPreviewURLForWallpaper(wallpaper: wallpaper), urlCache: .imageCache) { image in
|
||||||
|
image
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fill)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.cornerRadius(10, corners: .topLeft)
|
||||||
|
.cornerRadius(10, corners: .topRight)
|
||||||
|
} placeholder: {
|
||||||
|
Color.gray
|
||||||
|
.frame(height: MIN_SIZE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
VStack(spacing: 4) {
|
VStack(spacing: 4) {
|
||||||
@@ -74,12 +94,14 @@ struct ExploreView: View {
|
|||||||
.minimumScaleFactor(0.5)
|
.minimumScaleFactor(0.5)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
if let authors = wallpaper.authors {
|
||||||
Text(wallpaper.authors)
|
HStack {
|
||||||
.foregroundColor(.secondary)
|
Text(authors)
|
||||||
.font(.caption)
|
.foregroundColor(.secondary)
|
||||||
.minimumScaleFactor(0.5)
|
.font(.caption)
|
||||||
Spacer()
|
.minimumScaleFactor(0.5)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
|||||||
Reference in new issue
Block a user