LiveActivities design fix

- Fixed if the user opens the app 1 hour before their first class, the Room section is empty in LiveActivity lock screen
- DynamicIsland reworked and improved
- The room section moved to Flutter side
This commit is contained in:
Horváth Gergely 2024-05-06 06:01:15 +02:00
parent 587c16fb1f
commit ae66a462e7
2 changed files with 61 additions and 32 deletions

View File

@ -52,15 +52,25 @@ struct LockScreenLiveActivityView: View {
VStack(alignment: .center) {
// Jelenlegi óra
VStack {
if(context.state.title.contains("Az első órádig")) {
Text(context.state.title)
.font(.system(size: 15))
.bold()
.multilineTextAlignment(.center)
} else {
Text(context.state.index + " " + context.state.title)
.font(.body)
.bold()
.multilineTextAlignment(.center)
}
Text("Terem: \(context.state.subtitle)")
//Terem
if (!context.state.subtitle.isEmpty) {
Text(context.state.subtitle)
.italic()
.font(.caption)
}
}
// Leírás
if (context.state.description != "") {
@ -91,7 +101,7 @@ struct LockScreenLiveActivityView: View {
.frame(width: 85)
.font(.title2)
.monospacedDigit()
.padding(.trailing, CGFloat(24))
.padding(.trailing)
}
.activityBackgroundTint(
context.state.color != "#676767"
@ -135,6 +145,23 @@ struct LiveCardWidget: Widget {
}
DynamicIslandExpandedRegion(.center) {
VStack(alignment: .center) {
if(context.state.title.contains("Az első órádig")) {
Text("Az első órád:")
.font(.body)
.bold()
.padding(.leading, 15)
Text(context.state.nextSubject)
.font(.body)
.padding(.leading, 15)
Text("Ebben a teremben:")
.font(.body)
.bold()
.padding(.leading, 15)
Text(context.state.nextRoom)
.font(.body)
.padding(.leading, 15)
} else {
Text(context.state.index + context.state.title)
.lineLimit(1)
.font(.body)
@ -143,23 +170,25 @@ struct LiveCardWidget: Widget {
Text(context.state.subtitle)
.lineLimit(1)
.font(.subheadline)
Spacer()
Spacer(minLength: 5)
Text(context.state.description)
.lineLimit(2)
Text("Következő óra és terem:")
.font(.system(size: 13))
Text(context.state.nextSubject)
.font(.caption)
Text(context.state.nextRoom)
.font(.caption2)
}
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
}
/// Compact
} compactLeading: {
Label {
Text(context.state.title)
} icon: {
Image(systemName: context.state.icon)
}
.font(.caption2)
}
compactTrailing: {
Text(timerInterval: context.state.date, countsDown: true)
.multilineTextAlignment(.center)

View File

@ -91,7 +91,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book",
"title": "Első órádig:",
"title": "Jó reggelt! Az első órádig:",
"subtitle": "",
"description": "",
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",
@ -111,7 +111,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book",
"title": "Első órádig:",
"title": "Jó napot! Az első órádig:",
"subtitle": "",
"description": "",
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",
@ -131,7 +131,7 @@ class LiveCardProvider extends ChangeNotifier {
"icon": nextLesson != null
? SubjectIcon.resolveName(subject: nextLesson?.subject)
: "book",
"title": "Első órádig:",
"title": "Jó estét! Az első órádig:",
"subtitle": "",
"description": "",
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",