From 2842c8f669883487531c96b2d5fc43ad7c0ffa84 Mon Sep 17 00:00:00 2001 From: Magesh K <47920326+mahee96@users.noreply.github.com> Date: Tue, 12 Nov 2024 01:16:33 +0530 Subject: [PATCH] Widgets-Fix: Ported Widget compatibility for ios 18+ from altstore (#746) --- AltStore.xcodeproj/project.pbxproj | 14 ++++++++++++ AltWidget/ComplicationView.swift | 1 + AltWidget/Extensions/View+AltWidget.swift | 27 +++++++++++++++++++++++ AltWidget/WidgetView.swift | 3 ++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 AltWidget/Extensions/View+AltWidget.swift diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index fe52cefb..e37e6b11 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ 99F87D0529D8B4E200B40039 /* minimuxer-helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9961EC2D29BE9F2E00AF2C6F /* minimuxer-helpers.swift */; }; 99F87D1829D8E4C900B40039 /* SwiftBridgeCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99F87D1629D8E4C900B40039 /* SwiftBridgeCore.swift */; }; 99F87D1929D8E4C900B40039 /* minimuxer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99F87D1729D8E4C900B40039 /* minimuxer.swift */; }; + A800F7042CE28E3800208744 /* View+AltWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = A800F7032CE28E2F00208744 /* View+AltWidget.swift */; }; B3146ED2284F581E00BBC3FD /* Roxas.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3146ECD284F580500BBC3FD /* Roxas.framework */; }; B33FFBA8295F8E98002259E6 /* libfragmentzip.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B343F894295F7F9B002B1159 /* libfragmentzip.a */; }; B33FFBAA295F8F78002259E6 /* preboard.c in Sources */ = {isa = PBXBuildFile; fileRef = B33FFBA9295F8F78002259E6 /* preboard.c */; }; @@ -559,6 +560,7 @@ 9961EC2D29BE9F2E00AF2C6F /* minimuxer-helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "minimuxer-helpers.swift"; path = "Dependencies/minimuxer/minimuxer-helpers.swift"; sourceTree = SOURCE_ROOT; }; 99F87D1629D8E4C900B40039 /* SwiftBridgeCore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftBridgeCore.swift; path = Dependencies/minimuxer/SwiftBridgeCore.swift; sourceTree = SOURCE_ROOT; }; 99F87D1729D8E4C900B40039 /* minimuxer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = minimuxer.swift; path = Dependencies/minimuxer/minimuxer.swift; sourceTree = SOURCE_ROOT; }; + A800F7032CE28E2F00208744 /* View+AltWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+AltWidget.swift"; sourceTree = ""; }; B3146EC6284F580500BBC3FD /* Roxas.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Roxas.xcodeproj; path = Dependencies/Roxas/Roxas.xcodeproj; sourceTree = ""; }; B33FFBA9295F8F78002259E6 /* preboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = preboard.c; path = src/preboard.c; sourceTree = ""; }; B33FFBAB295F8F98002259E6 /* companion_proxy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = companion_proxy.c; path = src/companion_proxy.c; sourceTree = ""; }; @@ -1008,6 +1010,14 @@ name = Generated; sourceTree = ""; }; + A800F6FE2CE28DE300208744 /* Extensions */ = { + isa = PBXGroup; + children = ( + A800F7032CE28E2F00208744 /* View+AltWidget.swift */, + ); + path = Extensions; + sourceTree = ""; + }; B3146EC7284F580500BBC3FD /* Products */ = { isa = PBXGroup; children = ( @@ -1465,6 +1475,7 @@ BF98916C250AABF3002ACF50 /* AltWidget */ = { isa = PBXGroup; children = ( + A800F6FE2CE28DE300208744 /* Extensions */, BF8B17F0250AC62400F8157F /* AltWidgetExtension.entitlements */, BF98917D250AAC4F002ACF50 /* AltWidget.swift */, BF42345825101C1D006D1EB2 /* WidgetView.swift */, @@ -2489,6 +2500,7 @@ BF42345A25101C35006D1EB2 /* WidgetView.swift in Sources */, D55E163728776CB700A627A1 /* ComplicationView.swift in Sources */, BF98917F250AAC4F002ACF50 /* AltWidget.swift in Sources */, + A800F7042CE28E3800208744 /* View+AltWidget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3073,6 +3085,7 @@ CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; + ENABLE_DEBUG_DYLIB = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = AltWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -3103,6 +3116,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; + ENABLE_DEBUG_DYLIB = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = AltWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; diff --git a/AltWidget/ComplicationView.swift b/AltWidget/ComplicationView.swift index 98142c41..6ad6aba2 100644 --- a/AltWidget/ComplicationView.swift +++ b/AltWidget/ComplicationView.swift @@ -82,6 +82,7 @@ struct ComplicationView: View } .gaugeStyle(.accessoryCircularCapacity) .unredacted() + .widgetBackground(Color.clear) } } diff --git a/AltWidget/Extensions/View+AltWidget.swift b/AltWidget/Extensions/View+AltWidget.swift new file mode 100644 index 00000000..ed212ef0 --- /dev/null +++ b/AltWidget/Extensions/View+AltWidget.swift @@ -0,0 +1,27 @@ +// +// View+AltWidget.swift +// AltStore +// +// Created by Riley Testut on 8/18/23. +// Copyright © 2023 Riley Testut. All rights reserved. +// + +import SwiftUI + +extension View +{ + @ViewBuilder + func widgetBackground(_ backgroundView: some View) -> some View + { + if #available(iOSApplicationExtension 17, *) + { + containerBackground(for: .widget) { + backgroundView + } + } + else + { + background(backgroundView) + } + } +} diff --git a/AltWidget/WidgetView.swift b/AltWidget/WidgetView.swift index 6dcfadec..4483e737 100644 --- a/AltWidget/WidgetView.swift +++ b/AltWidget/WidgetView.swift @@ -104,7 +104,8 @@ struct WidgetView : View .frame(maxWidth: .infinity, maxHeight: .infinity) } } - .background(backgroundView(icon: entry.app?.icon, tintColor: entry.app?.tintColor)) + .widgetBackground(backgroundView(icon: entry.app?.icon, tintColor: entry.app?.tintColor)) + } }