mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltWidget] Adds “icon” style lock screen widget
This commit is contained in:
committed by
Joseph Mattello
parent
d7d0a83550
commit
699eda5d1b
@@ -189,9 +189,9 @@ struct HomeScreenWidget: Widget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LockScreenWidget: Widget
|
struct TextLockScreenWidget: Widget
|
||||||
{
|
{
|
||||||
private let kind: String = "LockAppDetail"
|
private let kind: String = "TextLockAppDetail"
|
||||||
|
|
||||||
public var body: some WidgetConfiguration {
|
public var body: some WidgetConfiguration {
|
||||||
if #available(iOSApplicationExtension 16, *)
|
if #available(iOSApplicationExtension 16, *)
|
||||||
@@ -199,10 +199,10 @@ struct LockScreenWidget: Widget
|
|||||||
return IntentConfiguration(kind: kind,
|
return IntentConfiguration(kind: kind,
|
||||||
intent: ViewAppIntent.self,
|
intent: ViewAppIntent.self,
|
||||||
provider: Provider()) { (entry) in
|
provider: Provider()) { (entry) in
|
||||||
ComplicationView(entry: entry)
|
ComplicationView(entry: entry, style: .text)
|
||||||
}
|
}
|
||||||
.supportedFamilies([.accessoryCircular])
|
.supportedFamilies([.accessoryCircular])
|
||||||
.configurationDisplayName("AltWidget")
|
.configurationDisplayName("AltWidget (Text)")
|
||||||
.description("View remaining days until SideStore expires.")
|
.description("View remaining days until SideStore expires.")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -212,11 +212,58 @@ struct LockScreenWidget: Widget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct IconLockScreenWidget: Widget
|
||||||
|
{
|
||||||
|
private let kind: String = "IconLockAppDetail"
|
||||||
|
|
||||||
|
public var body: some WidgetConfiguration {
|
||||||
|
if #available(iOSApplicationExtension 16, *)
|
||||||
|
{
|
||||||
|
return IntentConfiguration(kind: kind,
|
||||||
|
intent: ViewAppIntent.self,
|
||||||
|
provider: Provider()) { (entry) in
|
||||||
|
ComplicationView(entry: entry, style: .icon)
|
||||||
|
}
|
||||||
|
.supportedFamilies([.accessoryCircular])
|
||||||
|
.configurationDisplayName("AltWidget (Icon)")
|
||||||
|
.description("View remaining days until SideStore expires.")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return EmptyWidgetConfiguration()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//struct LockScreenWidget: Widget
|
||||||
|
//{
|
||||||
|
// private let kind: String = "LockAppDetail"
|
||||||
|
//
|
||||||
|
// public var body: some WidgetConfiguration {
|
||||||
|
// if #available(iOSApplicationExtension 16, *)
|
||||||
|
// {
|
||||||
|
// return IntentConfiguration(kind: kind,
|
||||||
|
// intent: ViewAppIntent.self,
|
||||||
|
// provider: Provider()) { (entry) in
|
||||||
|
// ComplicationView(entry: entry, style: .icon)
|
||||||
|
// }
|
||||||
|
// .supportedFamilies([.accessoryCircular])
|
||||||
|
// .configurationDisplayName("AltWidget")
|
||||||
|
// .description("View remaining days until SideStore expires.")
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return EmptyWidgetConfiguration()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct AltWidgets: WidgetBundle
|
struct AltWidgets: WidgetBundle
|
||||||
{
|
{
|
||||||
var body: some Widget {
|
var body: some Widget {
|
||||||
HomeScreenWidget()
|
HomeScreenWidget()
|
||||||
LockScreenWidget()
|
IconLockScreenWidget()
|
||||||
|
TextLockScreenWidget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
AltWidget/Assets.xcassets/SmallIcon.imageset/Contents.json
vendored
Normal file
16
AltWidget/Assets.xcassets/SmallIcon.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "altminicon.pdf",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"preserves-vector-representation" : true,
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
AltWidget/Assets.xcassets/SmallIcon.imageset/altminicon.pdf
vendored
Normal file
BIN
AltWidget/Assets.xcassets/SmallIcon.imageset/altminicon.pdf
vendored
Normal file
Binary file not shown.
@@ -9,10 +9,21 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
|
|
||||||
|
@available(iOS 16, *)
|
||||||
|
extension ComplicationView
|
||||||
|
{
|
||||||
|
enum Style
|
||||||
|
{
|
||||||
|
case text
|
||||||
|
case icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@available(iOS 16, *)
|
@available(iOS 16, *)
|
||||||
struct ComplicationView: View
|
struct ComplicationView: View
|
||||||
{
|
{
|
||||||
let entry: AppEntry
|
let entry: AppEntry
|
||||||
|
let style: Style
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let refreshedDate = self.entry.app?.refreshedDate ?? .now
|
let refreshedDate = self.entry.app?.refreshedDate ?? .now
|
||||||
@@ -31,16 +42,42 @@ struct ComplicationView: View
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VStack(spacing: -1) {
|
switch self.style
|
||||||
let fontSize = daysRemaining > 99 ? 18.0 : 20.0
|
{
|
||||||
Text("\(daysRemaining)")
|
case .text:
|
||||||
.font(.system(size: fontSize, weight: .bold, design: .rounded))
|
VStack(spacing: -1) {
|
||||||
|
let fontSize = daysRemaining > 99 ? 18.0 : 20.0
|
||||||
|
Text("\(daysRemaining)")
|
||||||
|
.font(.system(size: fontSize, weight: .bold, design: .rounded))
|
||||||
|
|
||||||
|
Text(daysRemaining == 1 ? "DAY" : "DAYS")
|
||||||
|
.font(.caption)
|
||||||
|
}
|
||||||
|
.fixedSize()
|
||||||
|
.offset(y: -1)
|
||||||
|
|
||||||
Text(daysRemaining == 1 ? "DAY" : "DAYS")
|
case .icon:
|
||||||
.font(.caption)
|
ZStack {
|
||||||
|
// Destination
|
||||||
|
Image("SmallIcon")
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(1.0, contentMode: .fill)
|
||||||
|
.scaleEffect(x: 0.8, y: 0.8)
|
||||||
|
|
||||||
|
// Source
|
||||||
|
(
|
||||||
|
daysRemaining > 7 ?
|
||||||
|
Text("7+")
|
||||||
|
.font(.system(size: 18, weight: .bold, design: .rounded))
|
||||||
|
.kerning(-2) :
|
||||||
|
|
||||||
|
Text("\(daysRemaining)")
|
||||||
|
.font(.system(size: 20, weight: .bold, design: .rounded))
|
||||||
|
)
|
||||||
|
.foregroundColor(Color.black)
|
||||||
|
.blendMode(.destinationOut) // Clip text out of image.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.fixedSize()
|
|
||||||
.offset(y: -1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.gaugeStyle(.accessoryCircularCapacity)
|
.gaugeStyle(.accessoryCircularCapacity)
|
||||||
@@ -74,14 +111,23 @@ struct ComplicationView_Previews: PreviewProvider {
|
|||||||
icon: UIImage(named: "AltStore"))
|
icon: UIImage(named: "AltStore"))
|
||||||
|
|
||||||
return Group {
|
return Group {
|
||||||
ComplicationView(entry: AppEntry(date: Date(), app: weekAltstore))
|
ComplicationView(entry: AppEntry(date: Date(), app: weekAltstore), style: .icon)
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
|
|
||||||
ComplicationView(entry: AppEntry(date: expiredDate, app: weekAltstore))
|
ComplicationView(entry: AppEntry(date: expiredDate, app: weekAltstore), style: .icon)
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
|
|
||||||
ComplicationView(entry: AppEntry(date: longRefreshedDate, app: yearAltstore))
|
ComplicationView(entry: AppEntry(date: longRefreshedDate, app: yearAltstore), style: .icon)
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
|
|
||||||
|
ComplicationView(entry: AppEntry(date: Date(), app: weekAltstore), style: .text)
|
||||||
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
|
|
||||||
|
ComplicationView(entry: AppEntry(date: expiredDate, app: weekAltstore), style: .text)
|
||||||
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
|
|
||||||
|
ComplicationView(entry: AppEntry(date: longRefreshedDate, app: yearAltstore), style: .text)
|
||||||
|
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user