Merge pull request #111 from geryyhu/dev

LiveActivities design fix
This commit is contained in:
Márton Kiss 2024-05-06 21:29:42 +02:00 committed by GitHub
commit 9e9e46d0f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 114 additions and 39 deletions

View File

@ -52,14 +52,30 @@ struct LockScreenLiveActivityView: View {
VStack(alignment: .center) { VStack(alignment: .center) {
// Jelenlegi óra // Jelenlegi óra
VStack { VStack {
Text(context.state.index + " " + context.state.title) if(context.state.title.contains("Az első órádig")) {
.font(.body) Text(context.state.title)
.bold() .font(.system(size: 15))
.multilineTextAlignment(.center) .bold()
.multilineTextAlignment(.center)
} else if(context.state.title == "Szünet") {
Text(context.state.title)
.font(.body)
.bold()
.padding(.trailing, 90)
Text("Terem: \(context.state.subtitle)") } else {
.italic() Text(context.state.index + " " + context.state.title)
.font(.caption) .font(.body)
.bold()
.multilineTextAlignment(.center)
}
//Terem
if (!context.state.subtitle.isEmpty) {
Text(context.state.subtitle)
.italic()
.font(.system(size: 13))
}
} }
// Leírás // Leírás
@ -69,6 +85,7 @@ struct LockScreenLiveActivityView: View {
} }
// Következő óra // Következő óra
if(context.state.nextSubject != "" && context.state.nextRoom != "") {
HStack { HStack {
Image(systemName: "arrow.right") Image(systemName: "arrow.right")
.resizable() .resizable()
@ -80,18 +97,24 @@ struct LockScreenLiveActivityView: View {
.font(.caption2) .font(.caption2)
} }
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
} else {
Spacer(minLength: 5)
Text("Ez az utolsó óra! Kitartást!")
.font(.system(size: 15))
}
} }
.padding(15) .padding(15)
Spacer() Spacer()
// Visszaszámláló // Visszaszámláló
Text(timerInterval: context.state.date, countsDown: true) Text(timerInterval: context.state.date, countsDown: true)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.frame(width: 85) .frame(width: 85)
.font(.title2) .font(.title2)
.monospacedDigit() .monospacedDigit()
.padding(.trailing, CGFloat(24)) .padding(.trailing)
} }
.activityBackgroundTint( .activityBackgroundTint(
context.state.color != "#676767" context.state.color != "#676767"
@ -109,7 +132,7 @@ struct LiveCardWidget: Widget {
LockScreenLiveActivityView(context: context) LockScreenLiveActivityView(context: context)
/// Dynamic Island /// Dynamic Island
} dynamicIsland: { context in } dynamicIsland: { context in
/// Expanded /// Expanded
return DynamicIsland { return DynamicIsland {
DynamicIslandExpandedRegion(.leading) { DynamicIslandExpandedRegion(.leading) {
@ -133,39 +156,91 @@ struct LiveCardWidget: Widget {
).progressViewStyle(.circular) ).progressViewStyle(.circular)
} }
} }
DynamicIslandExpandedRegion(.center) { DynamicIslandExpandedRegion(.center) {
VStack(alignment: .center) { VStack(alignment: .center) {
Text(context.state.index + context.state.title) // Első óra előtti expanded DynamicIsland
.lineLimit(1) if(context.state.title.contains("Az első órádig")) {
.font(.body) Text("Az első órád:")
.bold() .font(.body)
.bold()
Text(context.state.subtitle) .padding(.leading, 15)
.lineLimit(1) Text(context.state.nextSubject)
.font(.subheadline) .font(.body)
Spacer() .padding(.leading, 15)
Text(context.state.description) Text("Ebben a teremben:")
.lineLimit(2) .font(.body)
.font(.caption) .bold()
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0)) .padding(.leading, 15)
} Text(context.state.nextRoom)
.font(.body)
.padding(.leading, 15)
} else if(context.state.title == "Szünet") {
// Amikor szünet van, expanded DynamicIsland
Text(context.state.title)
.lineLimit(1)
.font(.body)
.bold()
.padding(.leading, 15)
Spacer(minLength: 5)
Text("Következő óra és terem:")
.font(.system(size: 13))
.padding(.leading, 25)
Text(context.state.nextSubject)
.font(.caption)
.padding(.leading, 15)
Text(context.state.nextRoom)
.font(.caption2)
.padding(.leading, 15)
} else {
// Amikor óra van, expanded DynamicIsland
Text(context.state.index + context.state.title)
.lineLimit(1)
.font(.body)
.bold()
.padding(.trailing, -35)
Text(context.state.subtitle)
.lineLimit(1)
.font(.subheadline)
.padding(.trailing, -50)
Spacer(minLength: 5)
if(context.state.nextRoom != "" && context.state.nextSubject != "") {
Text("Következő óra és terem:")
.font(.system(size: 13))
.padding(.trailing, -35)
Text(context.state.nextSubject)
.font(.caption)
.padding(.trailing, -35)
Text(context.state.nextRoom)
.font(.caption2)
.padding(.trailing, -35)
} else {
Text("Ez az utolsó óra! Kitartást!")
.font(.system(size: 14))
.padding(.trailing, -30)
}
}
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
}
/// Compact /// Compact
} compactLeading: { } compactLeading: {
Label { Image(systemName: context.state.icon)
Text(context.state.title)
} icon: {
Image(systemName: context.state.icon)
}
.font(.caption2)
} }
compactTrailing: { compactTrailing: {
Text(timerInterval: context.state.date, countsDown: true) Text(timerInterval: context.state.date, countsDown: true)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.frame(width: 40) .frame(width: 40)
.font(.caption2) .font(.caption2)
/// Collapsed /// Collapsed
} minimal: { } minimal: {
VStack(alignment: .center, content: { VStack(alignment: .center, content: {
@ -191,7 +266,7 @@ struct LiveCardWidget: Widget {
context.state.color != "#676767" context.state.color != "#676767"
? Color(hex: context.state.color) ? Color(hex: context.state.color)
: Color.clear : Color.clear
) )
} }
} }
} }

View File

@ -92,7 +92,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null "icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject) ? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book", : "book",
"title": "Első órádig:", "title": "Jó reggelt! Az első órádig:",
"subtitle": "", "subtitle": "",
"description": "", "description": "",
"startDate": storeFirstRunDate != null "startDate": storeFirstRunDate != null
@ -117,7 +117,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null "icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject) ? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book", : "book",
"title": "Első órádig:", "title": "Jó napot! Az első órádig:",
"subtitle": "", "subtitle": "",
"description": "", "description": "",
"startDate": storeFirstRunDate != null "startDate": storeFirstRunDate != null
@ -142,7 +142,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null "icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject) ? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book", : "book",
"title": "Első órádig:", "title": "Jó estét! Az első órádig:",
"subtitle": "", "subtitle": "",
"description": "", "description": "",
"startDate": storeFirstRunDate != null "startDate": storeFirstRunDate != null
@ -174,7 +174,7 @@ class LiveCardProvider extends ChangeNotifier {
ShortSubject.resolve(subject: currentLesson?.subject) ShortSubject.resolve(subject: currentLesson?.subject)
.capital() .capital()
: "", : "",
"subtitle": currentLesson?.room.replaceAll("_", " ") ?? "", "subtitle": "Terem: ${currentLesson?.room.replaceAll("_", " ") ?? ""}",
"description": currentLesson?.description ?? "", "description": currentLesson?.description ?? "",
"startDate": ((currentLesson?.start.millisecondsSinceEpoch ?? 0) - "startDate": ((currentLesson?.start.millisecondsSinceEpoch ?? 0) -
_delay.inMilliseconds) _delay.inMilliseconds)