From 83a265f34aa3dc23d193834c8237f27c78db5a86 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Wed, 18 Nov 2020 08:27:32 -0500 Subject: [PATCH] Switch to URLImage for better macOS support --- MobileFort/Common/PostView.swift | 23 ++---- MobileFort/MobileFort (iOS)/Info.plist | 82 +++++++++++++------ .../MobileFort.xcodeproj/project.pbxproj | 32 ++++---- .../xcshareddata/swiftpm/Package.resolved | 18 ++-- 4 files changed, 88 insertions(+), 67 deletions(-) diff --git a/MobileFort/Common/PostView.swift b/MobileFort/Common/PostView.swift index 776d6f8..35c7ab0 100644 --- a/MobileFort/Common/PostView.swift +++ b/MobileFort/Common/PostView.swift @@ -1,5 +1,5 @@ import SwiftUI -import RemoteImage +import URLImage extension String { func encodeUrl() -> String? { @@ -13,15 +13,11 @@ struct PostView: View { var body: some View { VStack { HStack { - RemoteImage(type: .url(URL(string: post.post.avatarUrl.encodeUrl()!)!), errorView: { error in - Text(error.localizedDescription) - }, imageView: { image in + URLImage(url: URL(string: post.post.avatarUrl.encodeUrl()!)!) { image in image - .resizable() - .aspectRatio(contentMode: .fit) - }, loadingView: { - Text("Loading...") - }).frame(width: 50.0, height: 50.0).padding(.leading) + .resizable() + .aspectRatio(contentMode: .fit) + }.frame(width: 50.0, height: 50.0).padding(.leading) VStack(alignment: .leading) { if post.post.isReblogged() { @@ -40,15 +36,10 @@ struct PostView: View { ForEach(post.post.media) { media in if !media.url.isEmpty { VStack { - RemoteImage(type: .url(URL(string: media.url.encodeUrl()!)!), errorView: { error in - Text(error.localizedDescription) - }, imageView: { image in + URLImage(url: URL(string: media.url.encodeUrl()!)!) { image in image - .resizable() .aspectRatio(contentMode: .fit) - }, loadingView: { - Text("Loading...") - }) + } } } } diff --git a/MobileFort/MobileFort (iOS)/Info.plist b/MobileFort/MobileFort (iOS)/Info.plist index cfbbdb7..b5d4937 100644 --- a/MobileFort/MobileFort (iOS)/Info.plist +++ b/MobileFort/MobileFort (iOS)/Info.plist @@ -1,30 +1,60 @@ - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSMainStoryboardFile - Main - NSPrincipalClass - NSApplication - + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + diff --git a/MobileFort/MobileFort.xcodeproj/project.pbxproj b/MobileFort/MobileFort.xcodeproj/project.pbxproj index c708876..bdda41b 100644 --- a/MobileFort/MobileFort.xcodeproj/project.pbxproj +++ b/MobileFort/MobileFort.xcodeproj/project.pbxproj @@ -20,12 +20,12 @@ 03B2BA7025654F0500483FE3 /* Common.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03427F6C248887D200A0073D /* Common.swift */; }; 03B2BA7125654F0500483FE3 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BCD7422488947200DA1F27 /* ProfileView.swift */; }; 03B2BA7225654F0500483FE3 /* PostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BCD7442488948200DA1F27 /* PostView.swift */; }; - 03B2BA7925654F4E00483FE3 /* RemoteImage in Frameworks */ = {isa = PBXBuildFile; productRef = 03B2BA7825654F4E00483FE3 /* RemoteImage */; }; 03B2BA85256550FA00483FE3 /* AttributedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03B2BA84256550FA00483FE3 /* AttributedText.swift */; }; 03B2BA9F2565555500483FE3 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03B2BA9E2565555500483FE3 /* MainView.swift */; }; + 03B2BAA4256556C800483FE3 /* URLImage in Frameworks */ = {isa = PBXBuildFile; productRef = 03B2BAA3256556C800483FE3 /* URLImage */; }; + 03B2BAA8256556D100483FE3 /* URLImage in Frameworks */ = {isa = PBXBuildFile; productRef = 03B2BAA7256556D100483FE3 /* URLImage */; }; 03BCD7432488947200DA1F27 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BCD7422488947200DA1F27 /* ProfileView.swift */; }; 03BCD7452488948200DA1F27 /* PostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BCD7442488948200DA1F27 /* PostView.swift */; }; - 03BCD7482488985A00DA1F27 /* RemoteImage in Frameworks */ = {isa = PBXBuildFile; productRef = 03BCD7472488985A00DA1F27 /* RemoteImage */; }; 03BCD74A2489322500DA1F27 /* AttributedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BCD7492489322500DA1F27 /* AttributedText.swift */; }; 03BCD74D2489365600DA1F27 /* WebView in Frameworks */ = {isa = PBXBuildFile; productRef = 03BCD74C2489365600DA1F27 /* WebView */; }; /* End PBXBuildFile section */ @@ -59,7 +59,7 @@ buildActionMask = 2147483647; files = ( 03BCD74D2489365600DA1F27 /* WebView in Frameworks */, - 03BCD7482488985A00DA1F27 /* RemoteImage in Frameworks */, + 03B2BAA8256556D100483FE3 /* URLImage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -67,7 +67,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 03B2BA7925654F4E00483FE3 /* RemoteImage in Frameworks */, + 03B2BAA4256556C800483FE3 /* URLImage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -165,8 +165,8 @@ ); name = "MobileFort (iOS)"; packageProductDependencies = ( - 03BCD7472488985A00DA1F27 /* RemoteImage */, 03BCD74C2489365600DA1F27 /* WebView */, + 03B2BAA7256556D100483FE3 /* URLImage */, ); productName = MobileFort; productReference = 03427F552488856C00A0073D /* MobileFort (iOS).app */; @@ -186,7 +186,7 @@ ); name = "MobileFort (macOS)"; packageProductDependencies = ( - 03B2BA7825654F4E00483FE3 /* RemoteImage */, + 03B2BAA3256556C800483FE3 /* URLImage */, ); productName = MobileFort; productReference = 03B2BA5925654E9700483FE3 /* MobileFort (macOS).app */; @@ -219,8 +219,8 @@ ); mainGroup = 03427F4C2488856C00A0073D; packageReferences = ( - 03BCD7462488985A00DA1F27 /* XCRemoteSwiftPackageReference "RemoteImage" */, 03BCD74B2489365600DA1F27 /* XCRemoteSwiftPackageReference "SwiftUI-WebView" */, + 03B2BAA2256556C800483FE3 /* XCRemoteSwiftPackageReference "url-image" */, ); productRefGroup = 03427F562488856C00A0073D /* Products */; projectDirPath = ""; @@ -551,12 +551,12 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 03BCD7462488985A00DA1F27 /* XCRemoteSwiftPackageReference "RemoteImage" */ = { + 03B2BAA2256556C800483FE3 /* XCRemoteSwiftPackageReference "url-image" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/crelies/RemoteImage"; + repositoryURL = "https://github.com/dmytro-anokhin/url-image"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 3.0.0; + minimumVersion = 2.1.9; }; }; 03BCD74B2489365600DA1F27 /* XCRemoteSwiftPackageReference "SwiftUI-WebView" */ = { @@ -570,15 +570,15 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 03B2BA7825654F4E00483FE3 /* RemoteImage */ = { + 03B2BAA3256556C800483FE3 /* URLImage */ = { isa = XCSwiftPackageProductDependency; - package = 03BCD7462488985A00DA1F27 /* XCRemoteSwiftPackageReference "RemoteImage" */; - productName = RemoteImage; + package = 03B2BAA2256556C800483FE3 /* XCRemoteSwiftPackageReference "url-image" */; + productName = URLImage; }; - 03BCD7472488985A00DA1F27 /* RemoteImage */ = { + 03B2BAA7256556D100483FE3 /* URLImage */ = { isa = XCSwiftPackageProductDependency; - package = 03BCD7462488985A00DA1F27 /* XCRemoteSwiftPackageReference "RemoteImage" */; - productName = RemoteImage; + package = 03B2BAA2256556C800483FE3 /* XCRemoteSwiftPackageReference "url-image" */; + productName = URLImage; }; 03BCD74C2489365600DA1F27 /* WebView */ = { isa = XCSwiftPackageProductDependency; diff --git a/MobileFort/MobileFort.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/MobileFort/MobileFort.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5a28100..3d35253 100644 --- a/MobileFort/MobileFort.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/MobileFort/MobileFort.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,15 +1,6 @@ { "object": { "pins": [ - { - "package": "RemoteImage", - "repositoryURL": "https://github.com/crelies/RemoteImage", - "state": { - "branch": null, - "revision": "0a774642c744d653601d76b625c2cf290e363e52", - "version": "3.0.0" - } - }, { "package": "WebView", "repositoryURL": "https://github.com/kylehickinson/SwiftUI-WebView", @@ -18,6 +9,15 @@ "revision": "ec4352095428a06423868b3b2a92fdaa3c6281f7", "version": "0.2.0" } + }, + { + "package": "URLImage", + "repositoryURL": "https://github.com/dmytro-anokhin/url-image", + "state": { + "branch": null, + "revision": "cedfdb207dcba2aec1229f3e2053bb93460a4244", + "version": "2.1.9" + } } ] },