From ff3fb6427732011f99db74ba5fcf740bfa55fb45 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Fri, 18 Aug 2023 19:00:57 -0500 Subject: [PATCH] [AltWidget] Adopts containerBackground(for:) on iOS 17 --- AltStore.xcodeproj/project.pbxproj | 12 ++++++++++ AltWidget/Extensions/View+AltWidget.swift | 27 +++++++++++++++++++++++ AltWidget/WidgetView.swift | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 AltWidget/Extensions/View+AltWidget.swift diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index e51d88b0..bc8b5616 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -346,6 +346,7 @@ BFF7C9342578492100E55F36 /* ALTAnisetteData.m in Sources */ = {isa = PBXBuildFile; fileRef = BFB49AA823834CF900D542D9 /* ALTAnisetteData.m */; }; D513F6162A12CE4E0061EAA1 /* SourceError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D571ADCD2A02FA7400B24B63 /* SourceError.swift */; }; D5151BD92A8FF64300C96F28 /* RefreshAllAppsIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5151BD82A8FF64300C96F28 /* RefreshAllAppsIntent.swift */; }; + D5151BE72A90395400C96F28 /* View+AltWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5151BE52A90391900C96F28 /* View+AltWidget.swift */; }; D5177B0D2A26944600270065 /* AltStore12ToAltStore13.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = D5177B0C2A26944600270065 /* AltStore12ToAltStore13.xcmappingmodel */; }; D5189C012A01BC6800F44625 /* UserInfoValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5189C002A01BC6800F44625 /* UserInfoValue.swift */; }; D5189C022A01BC6800F44625 /* UserInfoValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5189C002A01BC6800F44625 /* UserInfoValue.swift */; }; @@ -877,6 +878,7 @@ BFFCFA45248835530077BFCE /* AltDaemon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AltDaemon.entitlements; sourceTree = ""; }; C9EEAA842DA87A88A870053B /* Pods_AltStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AltStore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D5151BD82A8FF64300C96F28 /* RefreshAllAppsIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshAllAppsIntent.swift; sourceTree = ""; }; + D5151BE52A90391900C96F28 /* View+AltWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+AltWidget.swift"; sourceTree = ""; }; D5177B0C2A26944600270065 /* AltStore12ToAltStore13.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = AltStore12ToAltStore13.xcmappingmodel; sourceTree = ""; }; D5189C002A01BC6800F44625 /* UserInfoValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfoValue.swift; sourceTree = ""; }; D51AD27C29356B7B00967AAA /* ALTWrappedError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALTWrappedError.h; sourceTree = ""; }; @@ -1536,6 +1538,7 @@ BF42345825101C1D006D1EB2 /* WidgetView.swift */, BF98917C250AAC4F002ACF50 /* Countdown.swift */, D55E163528776CB000A627A1 /* ComplicationView.swift */, + D5151BE42A9038FA00C96F28 /* Extensions */, BF989170250AABF4002ACF50 /* Assets.xcassets */, BF989172250AABF4002ACF50 /* Info.plist */, ); @@ -1943,6 +1946,14 @@ path = Errors; sourceTree = ""; }; + D5151BE42A9038FA00C96F28 /* Extensions */ = { + isa = PBXGroup; + children = ( + D5151BE52A90391900C96F28 /* View+AltWidget.swift */, + ); + path = Extensions; + sourceTree = ""; + }; D54058B72A1D6251008CCC58 /* Previews */ = { isa = PBXGroup; children = ( @@ -2805,6 +2816,7 @@ BF98917E250AAC4F002ACF50 /* Countdown.swift in Sources */, BF42345A25101C35006D1EB2 /* WidgetView.swift in Sources */, D55E163728776CB700A627A1 /* ComplicationView.swift in Sources */, + D5151BE72A90395400C96F28 /* View+AltWidget.swift in Sources */, BF98917F250AAC4F002ACF50 /* AltWidget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; 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 55fcc679..164a8367 100644 --- a/AltWidget/WidgetView.swift +++ b/AltWidget/WidgetView.swift @@ -104,7 +104,7 @@ 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)) } }