Skip to content

Commit

Permalink
PZAccountKit & PZWidgetsKit // Add necessary assets, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Oct 26, 2024
1 parent 0fa0b73 commit 8f0a683
Show file tree
Hide file tree
Showing 131 changed files with 2,948 additions and 373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ private struct NoteView: View {
InformationRowView("app.dailynote.card.resin.label".i18nPZHelper) {
let resinIntel = dailyNote.resinInfo
HStack(spacing: 10) {
AccountKit.imageAsset("gi_note_resin")
let staminaIconName = switch dailyNote.game {
case .genshinImpact: "gi_note_resin"
case .starRail: "hsr_note_trailblazePower"
case .zenlessZone: "zzz_note_battery"
}
AccountKit.imageAsset(staminaIconName)
.resizable()
.scaledToFit()
.scaleEffect(1.1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "gi_note_transformer.heic",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "gi_note_weeklyBosses.heic",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "hsr_note_dailyTask.heic",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "hsr_note_simulatedUniverse.heic",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "hsr_note_weeklyBosses.heic",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ struct ResinRecoveryActivityWidget: Widget {
Image(systemSymbol: .personFill)
Text(context.attributes.accountName)
}
.foregroundColor(Color("textColor.appIconLike"))
.foregroundColor(Color("textColor.appIconLike", bundle: .module))
.font(.caption2)
.padding(.leading)
}
.contentMargins(.trailing, 15)
DynamicIslandExpandedRegion(.trailing) {
HStack(alignment: .center, spacing: 4) {
Image("AppIconSmall")
Image("AppIcon")
.resizable()
.scaledToFit()
.clipShape(RoundedRectangle(cornerRadius: 5))
.frame(width: 15)
Text("app.title.full")
.foregroundColor(Color("textColor.appIconLike"))
Text("app.title.full", bundle: .module)
.foregroundColor(Color("textColor.appIconLike", bundle: .module))
.font(.caption2)
}
.padding(.trailing)
Expand All @@ -52,12 +52,12 @@ struct ResinRecoveryActivityWidget: Widget {
HStack {
if Date() < context.state.next20ResinRecoveryTime {
HStack {
Image("树脂")
AccountKit.imageAsset(resinImageAssetName(context))
.resizable()
.scaledToFit()
.frame(maxHeight: 40)
VStack(alignment: .leading) {
Text("widget.next20Resin:\(context.state.next20ResinCount)")
Text("widget.next20Resin:\(context.state.next20ResinCount)", bundle: .module)
.font(.caption2)
Text(
timerInterval: Date() ... context.state
Expand All @@ -67,23 +67,22 @@ struct ResinRecoveryActivityWidget: Widget {
.multilineTextAlignment(.leading)
.font(.system(.title2, design: .rounded))
.foregroundColor(
Color("textColor.originResin")
Color("textColor.originResin", bundle: .module)
)
}
.gridColumnAlignment(.leading)
.frame(width: 100)
}
}
Spacer()
if Date() < context.state
.resinRecoveryTime {
if Date() < context.state.resinRecoveryTime {
HStack {
Image("浓缩树脂")
AccountKit.imageAsset("gi_note_resin_condensed")
.resizable()
.scaledToFit()
.frame(maxHeight: 40)
VStack(alignment: .leading) {
Text("widget.nextMaxResin")
Text("widget.nextMaxResin", bundle: .module)
.font(.caption2)

Text(
Expand All @@ -94,18 +93,18 @@ struct ResinRecoveryActivityWidget: Widget {
.multilineTextAlignment(.leading)
.font(.system(.title2, design: .rounded))
.foregroundColor(
Color("textColor.originResin")
Color("textColor.originResin", bundle: .module)
)
}
.gridColumnAlignment(.leading)
.frame(width: 100)
}
}
}
.foregroundColor(Color("textColor3"))
.foregroundColor(Color("textColor3", bundle: .module))
}
} compactLeading: {
Image("树脂").resizable().scaledToFit()
AccountKit.imageAsset(resinImageAssetName(context)).resizable().scaledToFit()
} compactTrailing: {
if Date() < context.state
.next20ResinRecoveryTime {
Expand All @@ -118,13 +117,21 @@ struct ResinRecoveryActivityWidget: Widget {
.monospacedDigit()
.multilineTextAlignment(.center)
.frame(width: 60)
.foregroundColor(Color("textColor2"))
.foregroundColor(Color("textColor2", bundle: .module))
}
} minimal: {
Image("树脂").resizable().scaledToFit()
AccountKit.imageAsset(resinImageAssetName(context)).resizable().scaledToFit()
}
}
}

func resinImageAssetName(_ context: ActivityViewContext<ResinRecoveryAttributes>) -> String {
switch context.state.game {
case .genshinImpact: "gi_note_resin"
case .starRail: "hsr_note_trailblazePower"
case .zenlessZone: "zzz_note_battery"
}
}
}

struct ResinRecoveryActivityWidgetLockScreenView: View {
Expand All @@ -134,6 +141,14 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {

var useNoBackground: Bool { context.state.background == .noBackground }

var resinImageAssetName: String {
switch context.state.game {
case .genshinImpact: "gi_note_resin"
case .starRail: "hsr_note_trailblazePower"
case .zenlessZone: "zzz_note_battery"
}
}

@MainActor var body: some View {
let mainContent = contentView
#if !os(watchOS)
Expand Down Expand Up @@ -179,12 +194,12 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {
Grid(verticalSpacing: 7) {
if #available(iOS 17, *) {
GridRow {
Image("树脂")
AccountKit.imageAsset(resinImageAssetName)
.resizable()
.scaledToFit()
.frame(maxHeight: 38)
VStack(alignment: .leading) {
Text("widget.currentResin")
Text("widget.currentResin", bundle: .module)
.font(.caption2)
HStack(alignment: .lastTextBaseline, spacing: 0) {
Text(verbatim: "\(context.state.currentResin)")
Expand All @@ -199,12 +214,12 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {
if context.state.showNext20Resin,
Date() < context.state.next20ResinRecoveryTime {
GridRow {
Image("树脂")
AccountKit.imageAsset(resinImageAssetName)
.resizable()
.scaledToFit()
.frame(maxHeight: 38)
VStack(alignment: .leading) {
Text("widget.next20Resin:\(context.state.next20ResinCount)")
Text("widget.next20Resin:\(context.state.next20ResinCount)", bundle: .module)
.font(.caption2)
Text(
timerInterval: Date() ... context.state
Expand All @@ -218,15 +233,14 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {
}
}
}
if Date() < context.state
.resinRecoveryTime {
if context.state.game == .genshinImpact, Date() < context.state.resinRecoveryTime {
GridRow {
Image("浓缩树脂")
AccountKit.imageAsset("gi_note_resin_condensed")
.resizable()
.scaledToFit()
.frame(maxHeight: 35)
VStack(alignment: .leading) {
Text("widget.nextMaxResin")
Text("widget.nextMaxResin", bundle: .module)
.font(.caption2)
Text(
timerInterval: Date() ... context.state
Expand All @@ -240,16 +254,14 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {
// .frame(width: 140)
}
}
if context.state.showExpedition,
let time = context.state.expeditionAllCompleteTime,
Date() < time {
if context.state.showExpedition, let time = context.state.expeditionAllCompleteTime, Date() < time {
GridRow {
Image("派遣探索")
AccountKit.imageAsset("gi_note_expedition")
.resizable()
.scaledToFit()
.frame(maxHeight: 29)
VStack(alignment: .leading) {
Text("widget.expedition.timeToAllCompletion")
Text("widget.expedition.timeToAllCompletion", bundle: .module)
.font(.caption2)
Text(
timerInterval: Date() ... time,
Expand Down Expand Up @@ -287,7 +299,7 @@ struct ResinRecoveryActivityWidgetLockScreenView: View {
}
}
.shadow(radius: useNoBackground ? 0 : 0.8)
.foregroundColor(useNoBackground ? .primary : Color("textColor3"))
.foregroundColor(useNoBackground ? .primary : Color("textColor3", bundle: .module))
.padding()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,31 @@ struct ResinRecoveryAttributes: ActivityAttributes, Sendable {
self.resinRecoveryTime = dailyNote.staminaFullTimeOnFinish
switch dailyNote {
case let data as WidgetNote4GI:
self.game = .genshinImpact
self.expeditionAllCompleteTime = nil
self.showExpedition = showExpedition
case let data as GeneralNote4GI:
self.game = .genshinImpact
self.expeditionAllCompleteTime = data.expeditions.expeditions.map(\.finishTime).max() ?? .now
self.showExpedition = showExpedition
case let data as Note4HSR:
self.game = .starRail
self.expeditionAllCompleteTime = data.assignmentInfo.assignments.map(\.finishedTime).max() ?? .now
self.showExpedition = showExpedition
case let data as Note4ZZZ:
self.game = .zenlessZone
self.showExpedition = false
self.expeditionAllCompleteTime = nil
default:
self.game = .genshinImpact // 乱填。
self.showExpedition = false
self.expeditionAllCompleteTime = nil
}
}

// MARK: Internal

let game: Pizza.SupportedGame
let resinCountWhenUpdated: Int
let resinRecoveryTime: Date
let expeditionAllCompleteTime: Date?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ struct AlternativeLockScreenResinWidgetCircular: View {

let result: Result<any DailyNoteProtocol, any Error>

var staminaMonochromeIconAssetName: String {
switch result {
case let .success(data):
return switch data.game {
case .genshinImpact: "icon.resin"
case .starRail: "icon.trailblazePower"
case .zenlessZone: "icon.zzzBattery"
}
case .failure: return "icon.resin"
}
}

@MainActor var body: some View {
VStack(spacing: 0) {
let img = Image("icon.resin")
let img = Image(staminaMonochromeIconAssetName, bundle: .module)
.resizable()
.scaledToFit()
switch widgetRenderingMode {
Expand All @@ -40,7 +52,7 @@ struct AlternativeLockScreenResinWidgetCircular: View {
case let .success(data):
switch data {
case let data as any Note4GI:
Text("\(data.resinInfo.currentResinDynamic)")
Text(verbatim: "\(data.resinInfo.currentResinDynamic)")
.font(.system(.body, design: .rounded).weight(.medium))
.minimumScaleFactor(0.1)
default:
Expand Down
Loading

0 comments on commit 8f0a683

Please sign in to comment.