Merge branch 'dev' of github.com:refilc/naplo into dev
This commit is contained in:
commit
308c8f966f
@ -20,7 +20,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="1."
|
android:text="1."
|
||||||
android:textColor="@color/filc"
|
android:textColor="@color/filc"
|
||||||
android:textColorLink="#ff3D7BF4"
|
android:textColorLink="#ff052460"
|
||||||
android:textSize="30sp"
|
android:textSize="30sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="HardcodedText" />
|
tools:ignore="HardcodedText" />
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<color name="yellow_light">#ffFFCC00</color>
|
<color name="yellow_light">#ffFFCC00</color>
|
||||||
<color name="light_yellow_light">#40FFD60A</color>
|
<color name="light_yellow_light">#40FFD60A</color>
|
||||||
<color name="green_light">#ff34C759</color>
|
<color name="green_light">#ff34C759</color>
|
||||||
<color name="filc_light">#ff3D7BF4</color>
|
<color name="filc_light">#ff052460</color>
|
||||||
<color name="teal_light">#ff5AC8FA</color>
|
<color name="teal_light">#ff5AC8FA</color>
|
||||||
<color name="blue_light">#ff007AFF</color>
|
<color name="blue_light">#ff007AFF</color>
|
||||||
<color name="indigo_light">#ff5856D6</color>
|
<color name="indigo_light">#ff5856D6</color>
|
||||||
@ -49,8 +49,8 @@
|
|||||||
<color name="yellow">#ffFFD60A</color>
|
<color name="yellow">#ffFFD60A</color>
|
||||||
<color name="light_yellow">#40FFD60A</color>
|
<color name="light_yellow">#40FFD60A</color>
|
||||||
<color name="green">#ff32D74B</color>
|
<color name="green">#ff32D74B</color>
|
||||||
<color name="filc">#ff3D7BF4</color>
|
<color name="filc">#ff052460</color>
|
||||||
<color name="filc_gradient">#ff3D93F5</color>
|
<color name="filc_gradient">#ff06348f</color>
|
||||||
<color name="teal">#ff64D2FF</color>
|
<color name="teal">#ff64D2FF</color>
|
||||||
<color name="blue">#ff0A84FF</color>
|
<color name="blue">#ff0A84FF</color>
|
||||||
<color name="indigo">#ff5E5CE6</color>
|
<color name="indigo">#ff5E5CE6</color>
|
||||||
|
@ -52,14 +52,31 @@ 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")) {
|
||||||
|
Text(context.state.title)
|
||||||
|
.font(.system(size: 15))
|
||||||
|
.bold()
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
} else if(context.state.title == "Szünet") {
|
||||||
|
Text(context.state.title)
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.padding(.trailing, 90)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MultilineTextView(text: "\(context.state.index) \(context.state.title)", limit: 25)
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.bold()
|
.bold()
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
|
}
|
||||||
|
|
||||||
Text("Terem: \(context.state.subtitle)")
|
//Terem
|
||||||
|
if (!context.state.subtitle.isEmpty) {
|
||||||
|
Text(context.state.subtitle)
|
||||||
.italic()
|
.italic()
|
||||||
.font(.caption)
|
.bold()
|
||||||
|
.font(.system(size: 13))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leírás
|
// Leírás
|
||||||
@ -69,6 +86,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,6 +98,12 @@ 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)
|
||||||
|
|
||||||
@ -91,7 +115,7 @@ struct LockScreenLiveActivityView: View {
|
|||||||
.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"
|
||||||
@ -135,31 +159,87 @@ struct LiveCardWidget: Widget {
|
|||||||
}
|
}
|
||||||
DynamicIslandExpandedRegion(.center) {
|
DynamicIslandExpandedRegion(.center) {
|
||||||
VStack(alignment: .center) {
|
VStack(alignment: .center) {
|
||||||
Text(context.state.index + context.state.title)
|
// Első óra előtti expanded DynamicIsland
|
||||||
|
if(context.state.title.contains("Az első órádig")) {
|
||||||
|
Text("Az első órád:")
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.padding(.trailing, -15)
|
||||||
|
MultilineTextView(text: "\(context.state.nextSubject)", limit: 25)
|
||||||
|
.font(.body)
|
||||||
|
.padding(.trailing, -25)
|
||||||
|
|
||||||
|
Text("Ebben a teremben:")
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.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)
|
.lineLimit(1)
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.bold()
|
.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
|
||||||
|
MultilineTextView(text: "\(context.state.index) \(context.state.title)", limit: 25)
|
||||||
|
.lineLimit(1)
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.padding(.trailing, -35)
|
||||||
|
|
||||||
Text(context.state.subtitle)
|
Text(context.state.subtitle)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.font(.subheadline)
|
.italic()
|
||||||
Spacer()
|
.bold()
|
||||||
|
.font(.system(size: 13))
|
||||||
|
.padding(.trailing, -50)
|
||||||
|
|
||||||
|
Spacer(minLength: 5)
|
||||||
|
|
||||||
|
if(context.state.nextRoom != "" && context.state.nextSubject != "") {
|
||||||
|
Text("Következő óra és terem:")
|
||||||
|
.font(.system(size: 14))
|
||||||
|
.padding(.trailing, -35)
|
||||||
|
Spacer(minLength: 2)
|
||||||
|
Text(context.state.nextSubject)
|
||||||
|
.modifier(DynamicFontSizeModifier(text: context.state.nextSubject))
|
||||||
|
.padding(.trailing, -35)
|
||||||
|
Text(context.state.nextRoom)
|
||||||
|
// ignore: based on nextSubject characters, I check that the font size of the room is the same as the next subject.
|
||||||
|
.modifier(DynamicFontSizeModifier(text: context.state.nextSubject))
|
||||||
|
.padding(.trailing, -35)
|
||||||
|
} else {
|
||||||
|
Text("Ez az utolsó óra! Kitartást!")
|
||||||
|
.font(.system(size: 14))
|
||||||
|
.padding(.trailing, -30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Text(context.state.description)
|
|
||||||
.lineLimit(2)
|
|
||||||
.font(.caption)
|
|
||||||
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
|
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compact
|
/// Compact
|
||||||
} compactLeading: {
|
} compactLeading: {
|
||||||
Label {
|
|
||||||
Text(context.state.title)
|
|
||||||
} icon: {
|
|
||||||
Image(systemName: context.state.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)
|
||||||
@ -195,3 +275,55 @@ struct LiveCardWidget: Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MultilineTextView: View {
|
||||||
|
var text: String
|
||||||
|
var limit: Int = 20 // default is 20 character
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
let words = text.split(separator: " ")
|
||||||
|
var currentLine = ""
|
||||||
|
var lines: [String] = []
|
||||||
|
|
||||||
|
for word in words {
|
||||||
|
if (currentLine.count + word.count + 1) > limit {
|
||||||
|
lines.append(currentLine)
|
||||||
|
currentLine = ""
|
||||||
|
}
|
||||||
|
if !currentLine.isEmpty {
|
||||||
|
currentLine += " "
|
||||||
|
}
|
||||||
|
currentLine += word
|
||||||
|
}
|
||||||
|
if !currentLine.isEmpty {
|
||||||
|
lines.append(currentLine)
|
||||||
|
}
|
||||||
|
|
||||||
|
return VStack(alignment: .center) {
|
||||||
|
ForEach(lines, id: \.self) { line in
|
||||||
|
Text(line)
|
||||||
|
}
|
||||||
|
Spacer(minLength: 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DynamicFontSizeModifier: ViewModifier {
|
||||||
|
var text: String
|
||||||
|
|
||||||
|
func body(content: Content) -> some View {
|
||||||
|
content
|
||||||
|
.font(.system(size: fontSize(for: text)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private func fontSize(for text: String) -> CGFloat {
|
||||||
|
let length = text.count
|
||||||
|
if length < 10 {
|
||||||
|
return 12
|
||||||
|
} else if length < 20 {
|
||||||
|
return 12
|
||||||
|
} else {
|
||||||
|
return 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user