mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 08:13:26 +01:00
[AltWidget] Replaces ProgressRing with SwiftUI.Gauge
This commit is contained in:
@@ -348,7 +348,6 @@
|
||||
BFF7C90F257844C900E55F36 /* AltXPC.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = BFF7C904257844C900E55F36 /* AltXPC.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
BFF7C920257844FA00E55F36 /* ALTPluginService.m in Sources */ = {isa = PBXBuildFile; fileRef = BF5C5FCE237DF69100EDD0C6 /* ALTPluginService.m */; };
|
||||
BFF7C9342578492100E55F36 /* ALTAnisetteData.m in Sources */ = {isa = PBXBuildFile; fileRef = BFB49AA823834CF900D542D9 /* ALTAnisetteData.m */; };
|
||||
D504F42628AD72C50014BB5D /* ProgressRing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D504F42528AD72C50014BB5D /* ProgressRing.swift */; };
|
||||
D52C08EE28AEC37A006C4AE5 /* AppVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = D52C08ED28AEC37A006C4AE5 /* AppVersion.swift */; };
|
||||
D533E8B72727841800A9B5DD /* libAppleArchive.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D533E8B62727841800A9B5DD /* libAppleArchive.tbd */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
D533E8BC2727BBEE00A9B5DD /* libfragmentzip.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D533E8BB2727BBEE00A9B5DD /* libfragmentzip.a */; };
|
||||
@@ -819,7 +818,6 @@
|
||||
BFF7EC4C25081E9300BDE521 /* AltStore 8.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AltStore 8.xcdatamodel"; sourceTree = "<group>"; };
|
||||
BFFCFA45248835530077BFCE /* AltDaemon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AltDaemon.entitlements; sourceTree = "<group>"; };
|
||||
C9EEAA842DA87A88A870053B /* Pods_AltStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AltStore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D504F42528AD72C50014BB5D /* ProgressRing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressRing.swift; sourceTree = "<group>"; };
|
||||
D52C08ED28AEC37A006C4AE5 /* AppVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppVersion.swift; sourceTree = "<group>"; };
|
||||
D52E988928D002D30032BE6B /* AltStore 11.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AltStore 11.xcdatamodel"; sourceTree = "<group>"; };
|
||||
D533E8B62727841800A9B5DD /* libAppleArchive.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libAppleArchive.tbd; path = usr/lib/libAppleArchive.tbd; sourceTree = SDKROOT; };
|
||||
@@ -1420,7 +1418,6 @@
|
||||
BF42345825101C1D006D1EB2 /* WidgetView.swift */,
|
||||
BF98917C250AAC4F002ACF50 /* Countdown.swift */,
|
||||
D55E163528776CB000A627A1 /* ComplicationView.swift */,
|
||||
D504F42528AD72C50014BB5D /* ProgressRing.swift */,
|
||||
BF989170250AABF4002ACF50 /* Assets.xcassets */,
|
||||
BF989172250AABF4002ACF50 /* Info.plist */,
|
||||
);
|
||||
@@ -2582,7 +2579,6 @@
|
||||
BF42345A25101C35006D1EB2 /* WidgetView.swift in Sources */,
|
||||
D55E163728776CB700A627A1 /* ComplicationView.swift in Sources */,
|
||||
BF98917F250AAC4F002ACF50 /* AltWidget.swift in Sources */,
|
||||
D504F42628AD72C50014BB5D /* ProgressRing.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -23,26 +23,27 @@ struct ComplicationView: View
|
||||
|
||||
let progress = Double(daysRemaining) / Double(totalDays)
|
||||
|
||||
ZStack(alignment: .center) {
|
||||
ProgressRing(progress: progress) {
|
||||
if daysRemaining < 0
|
||||
{
|
||||
Text("Expired")
|
||||
.font(.system(size: 10, weight: .bold))
|
||||
}
|
||||
else
|
||||
{
|
||||
VStack(spacing: -1) {
|
||||
Text("\(daysRemaining)")
|
||||
.font(.system(size: 20, weight: .bold, design: .rounded))
|
||||
|
||||
Text(daysRemaining == 1 ? "DAY" : "DAYS")
|
||||
.font(.caption)
|
||||
}
|
||||
.offset(y: -1)
|
||||
Gauge(value: progress) {
|
||||
if daysRemaining < 0
|
||||
{
|
||||
Text("Expired")
|
||||
.font(.system(size: 10, weight: .bold))
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
.gaugeStyle(.accessoryCircularCapacity)
|
||||
.unredacted()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// ProgressRing.swift
|
||||
// AltWidgetExtension
|
||||
//
|
||||
// Created by Riley Testut on 8/17/22.
|
||||
// Copyright © 2022 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct ProgressRing<Content: View>: View
|
||||
{
|
||||
let progress: Double
|
||||
|
||||
private let content: Content
|
||||
|
||||
init(progress: Double, @ViewBuilder content: () -> Content)
|
||||
{
|
||||
self.progress = progress
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
ring(progress: 1.0)
|
||||
.opacity(0.3)
|
||||
|
||||
ring(progress: self.progress)
|
||||
|
||||
content
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func ring(progress: Double) -> some View {
|
||||
let strokeStyle = StrokeStyle(lineWidth: 4.0, lineCap: .round, lineJoin: .round)
|
||||
|
||||
Circle()
|
||||
.inset(by: 2.0)
|
||||
.trim(from: 0.0, to: progress)
|
||||
.rotation(Angle(degrees: -90), anchor: .center)
|
||||
.stroke(style: strokeStyle)
|
||||
}
|
||||
}
|
||||
|
||||
struct ProgressRing_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ProgressRing(progress: 0.5) {
|
||||
EmptyView()
|
||||
}
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user