[AltWidget] Supports refreshing apps directly from home screen

This commit is contained in:
Riley Testut
2023-08-18 19:24:31 -05:00
committed by Magesh K
parent 693969dc28
commit 641c716d57
5 changed files with 90 additions and 3 deletions

View File

@@ -24,4 +24,33 @@ extension View
background(backgroundView)
}
}
@ViewBuilder
func invalidatableContentIfAvailable() -> some View
{
if #available(iOSApplicationExtension 17, *)
{
self.invalidatableContent()
}
else
{
self
}
}
@ViewBuilder
func activatesRefreshAllAppsIntent() -> some View
{
if #available(iOSApplicationExtension 17, *)
{
Button(intent: RefreshAllAppsWidgetIntent()) {
self
}
.buttonStyle(.plain)
}
else
{
self
}
}
}

View File

@@ -80,9 +80,11 @@ struct WidgetView : View
.opacity(0.8)
.fixedSize(horizontal: true, vertical: false)
.offset(x: 5)
.invalidatableContentIfAvailable()
}
}
.fixedSize(horizontal: false, vertical: true)
.activatesRefreshAllAppsIntent()
}
.padding()
}