From d6d60e60a92632fba0f348a3039dad9e7de085cc Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 21 Dec 2024 13:21:44 +0800 Subject: [PATCH] :bug: Fix ios widget image --- ios/Podfile | 5 + ios/Podfile.lock | 6 +- ios/Runner.xcodeproj/project.pbxproj | 36 +++++++ ios/SolarWidget/CheckInWidget.swift | 2 +- ios/SolarWidget/RandomPostWidget.swift | 131 ++++++++++++------------- 5 files changed, 110 insertions(+), 70 deletions(-) diff --git a/ios/Podfile b/ios/Podfile index f922a47..7af792c 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -36,6 +36,11 @@ target 'Runner' do inherit! :search_paths end + target 'SolarWidgetExtension' do + inherit! :search_paths + pod 'Kingfisher', '~> 8.0' + end + target 'SolarShare' do inherit! :search_paths end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 273048c..918fec9 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -167,6 +167,7 @@ PODS: - Flutter - image_picker_ios (0.0.1): - Flutter + - Kingfisher (8.1.3) - livekit_client (2.3.2): - Flutter - flutter_webrtc @@ -235,6 +236,7 @@ DEPENDENCIES: - gal (from `.symlinks/plugins/gal/darwin`) - home_widget (from `.symlinks/plugins/home_widget/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) + - Kingfisher (~> 8.0) - livekit_client (from `.symlinks/plugins/livekit_client/ios`) - media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`) - media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`) @@ -266,6 +268,7 @@ SPEC REPOS: - GoogleAppMeasurement - GoogleDataTransport - GoogleUtilities + - Kingfisher - nanopb - PromisesObjC - SAMKeychain @@ -366,6 +369,7 @@ SPEC CHECKSUMS: GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57 image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 + Kingfisher: f2af9028b16baf9dc6c07c570072bc41cbf009ef livekit_client: 6108dad8b77db3142bafd4c630f471d0a54335cd media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1 media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a @@ -390,6 +394,6 @@ SPEC CHECKSUMS: WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6 -PODFILE CHECKSUM: 23d35ad686cacf9103d1e85035ee4f3e9750630d +PODFILE CHECKSUM: f36978bb00ec01cd27f69faaf9a821024de98fcc COCOAPODS: 1.16.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a5694dc..2ba3a46 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 0B21A2B78F1AE403D3BE143E /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26CC8DE2338798EAB472B62D /* Pods_RunnerTests.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 2630F2992106E991467A6FC4 /* Pods_SolarWidgetExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F357CFDA89A0D9E5692846D4 /* Pods_SolarWidgetExtension.framework */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 738C1EAC2D0D76A400A215F3 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 731B7B6B2D0D6CE000CEB9B7 /* WidgetKit.framework */; }; @@ -86,6 +87,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 16F41E029731EA30268EDE2A /* Pods_SolarShare.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SolarShare.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2134F3903A0E8EB8CC2670BE /* Pods-SolarWidgetExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarWidgetExtension.debug.xcconfig"; path = "Target Support Files/Pods-SolarWidgetExtension/Pods-SolarWidgetExtension.debug.xcconfig"; sourceTree = ""; }; 26CC8DE2338798EAB472B62D /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2DA1B873D39B9FD33298BBCE /* Pods-SolarShare.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarShare.profile.xcconfig"; path = "Target Support Files/Pods-SolarShare/Pods-SolarShare.profile.xcconfig"; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; @@ -96,6 +98,7 @@ 4A2F84B6033057E3BD2C7CB8 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 5922A50B1231B06B92E31F20 /* Pods-SolarShare.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarShare.debug.xcconfig"; path = "Target Support Files/Pods-SolarShare/Pods-SolarShare.debug.xcconfig"; sourceTree = ""; }; 64FBE78F9C282712818D6D95 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 6618E2E3015264643175B43D /* Pods-SolarWidgetExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarWidgetExtension.release.xcconfig"; path = "Target Support Files/Pods-SolarWidgetExtension/Pods-SolarWidgetExtension.release.xcconfig"; sourceTree = ""; }; 72E9279EFA6DAC00BBAC493C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 73111C212CEE3D5E004CF4B3 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 731B7B6B2D0D6CE000CEB9B7 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; @@ -117,7 +120,9 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A2C24C5238FAC44EA2CCF738 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; B1763F1D7318A2745CA7EDFE /* Pods-SolarShare.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarShare.release.xcconfig"; path = "Target Support Files/Pods-SolarShare/Pods-SolarShare.release.xcconfig"; sourceTree = ""; }; + BCE0C4086B776A27B202B373 /* Pods-SolarWidgetExtension.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SolarWidgetExtension.profile.xcconfig"; path = "Target Support Files/Pods-SolarWidgetExtension/Pods-SolarWidgetExtension.profile.xcconfig"; sourceTree = ""; }; EDF483E994343CDFBF9BA347 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F357CFDA89A0D9E5692846D4 /* Pods_SolarWidgetExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SolarWidgetExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ @@ -217,6 +222,7 @@ files = ( 738C1EAD2D0D76A400A215F3 /* SwiftUI.framework in Frameworks */, 738C1EAC2D0D76A400A215F3 /* WidgetKit.framework in Frameworks */, + 2630F2992106E991467A6FC4 /* Pods_SolarWidgetExtension.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -262,6 +268,7 @@ 731B7B6B2D0D6CE000CEB9B7 /* WidgetKit.framework */, 731B7B6D2D0D6CE000CEB9B7 /* SwiftUI.framework */, 16F41E029731EA30268EDE2A /* Pods_SolarShare.framework */, + F357CFDA89A0D9E5692846D4 /* Pods_SolarWidgetExtension.framework */, ); name = Frameworks; sourceTree = ""; @@ -344,6 +351,9 @@ 5922A50B1231B06B92E31F20 /* Pods-SolarShare.debug.xcconfig */, B1763F1D7318A2745CA7EDFE /* Pods-SolarShare.release.xcconfig */, 2DA1B873D39B9FD33298BBCE /* Pods-SolarShare.profile.xcconfig */, + 2134F3903A0E8EB8CC2670BE /* Pods-SolarWidgetExtension.debug.xcconfig */, + 6618E2E3015264643175B43D /* Pods-SolarWidgetExtension.release.xcconfig */, + BCE0C4086B776A27B202B373 /* Pods-SolarWidgetExtension.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -374,6 +384,7 @@ isa = PBXNativeTarget; buildConfigurationList = 738C1EBA2D0D76A500A215F3 /* Build configuration list for PBXNativeTarget "SolarWidgetExtension" */; buildPhases = ( + F2FCDA0E1BD434BF4883AFFD /* [CP] Check Pods Manifest.lock */, 738C1EA72D0D76A400A215F3 /* Sources */, 738C1EA82D0D76A400A215F3 /* Frameworks */, 738C1EA92D0D76A400A215F3 /* Resources */, @@ -710,6 +721,28 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + F2FCDA0E1BD434BF4883AFFD /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SolarWidgetExtension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; FC4815D44D909666EB1FA614 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -947,6 +980,7 @@ }; 738C1EBB2D0D76A500A215F3 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2134F3903A0E8EB8CC2670BE /* Pods-SolarWidgetExtension.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -990,6 +1024,7 @@ }; 738C1EBC2D0D76A500A215F3 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 6618E2E3015264643175B43D /* Pods-SolarWidgetExtension.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -1030,6 +1065,7 @@ }; 738C1EBD2D0D76A500A215F3 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = BCE0C4086B776A27B202B373 /* Pods-SolarWidgetExtension.profile.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; diff --git a/ios/SolarWidget/CheckInWidget.swift b/ios/SolarWidget/CheckInWidget.swift index 1f283c6..18a6ca9 100644 --- a/ios/SolarWidget/CheckInWidget.swift +++ b/ios/SolarWidget/CheckInWidget.swift @@ -108,7 +108,7 @@ struct CheckInWidgetEntryView : View { Button("Check In", systemImage: "checkmark", action: checkIn).labelStyle(.iconOnly).buttonBorderShape(.circle).frame(maxWidth: .infinity, alignment: .trailing) } } - }.padding(8) + }.padding(8).widgetURL(URL(string: "https://sn.solsynth.dev")) } } diff --git a/ios/SolarWidget/RandomPostWidget.swift b/ios/SolarWidget/RandomPostWidget.swift index 81990c8..ce85cfa 100644 --- a/ios/SolarWidget/RandomPostWidget.swift +++ b/ios/SolarWidget/RandomPostWidget.swift @@ -7,6 +7,7 @@ import SwiftUI import WidgetKit +import Kingfisher struct RandomPostProvider: TimelineProvider { func placeholder(in context: Context) -> RandomPostEntry { @@ -67,82 +68,76 @@ struct RandomPostWidgetEntryView : View { var body: some View { VStack(alignment: .leading, spacing: 0) { if let randomPost = entry.randomPost { - HStack(alignment: .center) { - if let avatar = randomPost.publisher.avatar { - let avatarUrl = getAttachmentUrl(for: avatar) - let size: CGFloat = 24 - - AsyncImage(url: URL(string: avatarUrl)) { image in - image.resizable() + VStack(alignment: .leading, spacing: 0) { + HStack(alignment: .center) { + if let avatar = randomPost.publisher.avatar { + let avatarUrl = getAttachmentUrl(for: avatar) + let size: CGFloat = 28 + + KFImage.url(URL(string: avatarUrl)) + .resizable() + .setProcessor(ResizingImageProcessor(referenceSize: CGSize(width: size, height: size), mode: .aspectFit)) .aspectRatio(contentMode: .fit) .frame(width: size, height: size) .cornerRadius(size / 2) - .overlay( - Circle() - .stroke(Color.white, lineWidth: 4) - .frame(width: size, height: size) - ) - .shadow(radius: 10) - .frame(width: 24, height: 24, alignment: .center) - } placeholder: { - ProgressView().frame(width: 24, height: 24, alignment: .center) + .frame(width: size, height: size, alignment: .center) + } + + Text("@\(randomPost.publisher.name)") + .font(.system(size: 13, design: .monospaced)) + .opacity(0.9) + + Spacer() + }.frame(maxWidth: .infinity).padding(.bottom, 12) + + if randomPost.body.title != nil || randomPost.body.description != nil { + VStack(alignment: .leading) { + if let title = randomPost.body.title { + Text(title) + .font(.system(size: 17)) + } + if let description = randomPost.body.description { + Text(description) + .font(.system(size: 15)) + } + }.padding(.bottom, 8) + } + + if let content = randomPost.body.content { + if (randomPost.body.title == nil && randomPost.body.description == nil) || entry.family == .systemLarge || entry.family == .systemExtraLarge { + Text( + (entry.family == .systemLarge || entry.family == .systemExtraLarge) ? content : content.replacingOccurrences(of: "\n", with: " ") + ) + .font(.system(size: 15)) + } else { + Text("\(Image(systemName: "plus")) total \(content.count) characters") + .font(.system(size: 11, design: .monospaced)) + .opacity(0.75) + .padding(.top, 1) } } - Text("@\(randomPost.publisher.name)") - .font(.system(size: 13, design: .monospaced)) - .opacity(0.9) + if let attachment = randomPost.body.attachments { + if attachment.count == 1 { + Text("\(Image(systemName: "document.fill")) \(attachment.count) attachment") + .font(.system(size: 11, design: .monospaced)) + .opacity(0.75) + .padding(.top, 2) + } else if attachment.count > 1 { + Text("\(Image(systemName: "document.fill")) \(attachment.count) attachments") + .font(.system(size: 11, design: .monospaced)) + .opacity(0.75) + .padding(.top, 2) + } + } Spacer() - }.frame(maxWidth: .infinity).padding(.bottom, 12) - - if randomPost.body.title != nil || randomPost.body.description != nil { - VStack(alignment: .leading) { - if let title = randomPost.body.title { - Text(title) - .font(.system(size: 17)) - } - if let description = randomPost.body.description { - Text(description) - .font(.system(size: 15)) - } - }.padding(.bottom, 8) - } - - if let content = randomPost.body.content { - if (randomPost.body.title == nil && randomPost.body.description == nil) || entry.family == .systemLarge || entry.family == .systemExtraLarge { - Text( - (entry.family == .systemLarge || entry.family == .systemExtraLarge) ? content : content.replacingOccurrences(of: "\n", with: " ") - ) - .font(.system(size: 15)) - } else { - Text("\(Image(systemName: "plus")) total \(content.count) characters") - .font(.system(size: 11, design: .monospaced)) - .opacity(0.75) - .padding(.top, 1) - } - } - - if let attachment = randomPost.body.attachments { - if attachment.count == 1 { - Text("\(Image(systemName: "document.fill")) \(attachment.count) attachment") - .font(.system(size: 11, design: .monospaced)) - .opacity(0.75) - .padding(.top, 1) - } else if attachment.count > 1 { - Text("\(Image(systemName: "document.fill")) \(attachment.count) attachments") - .font(.system(size: 11, design: .monospaced)) - .opacity(0.75) - .padding(.top, 1) - } - } - - Spacer() - - Text(randomPost.publishedAt!, format: .dateTime) - .font(.system(size: 11)) - Text("#\(randomPost.id)") - .font(.system(size: 9)) + + Text(randomPost.publishedAt!, format: .dateTime) + .font(.system(size: 11)) + Text("#\(randomPost.id)") + .font(.system(size: 9)) + }.widgetURL(URL(string: "https://sn.solsynth.dev/posts/\(randomPost.id)")) } else { VStack(alignment: .center) { Text("No Recommendations").font(.system(size: 19, weight: .bold))