Merge pull request #28 from TMarccci/dev

Tested functions, BugFixes, Key line tint around Dyn Island
This commit is contained in:
Márton Kiss 2023-08-30 00:47:28 +02:00 committed by GitHub
commit 5052f57ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 4 deletions

View File

@ -11,6 +11,33 @@ struct Widgets: WidgetBundle {
}
}
// Color Converter
extension Color {
init(hex: String, alpha: Double = 1.0) {
var hexValue = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if hexValue.hasPrefix("#") {
hexValue.remove(at: hexValue.startIndex)
}
var rgbValue: UInt64 = 0
Scanner(string: hexValue).scanHexInt64(&rgbValue)
let red = Double((rgbValue & 0xFF0000) >> 16) / 255.0
let green = Double((rgbValue & 0x00FF00) >> 8) / 255.0
let blue = Double(rgbValue & 0x0000FF) / 255.0
self.init(
.sRGB,
red: red,
green: green,
blue: blue,
opacity: alpha
)
}
}
// We need to redefined live activities pipe
struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable {
public struct ContentState: Codable, Hashable { }
@ -69,7 +96,9 @@ struct LockScreenLiveActivityView: View {
.padding(.trailing, CGFloat(24))
}
.activityBackgroundTint(
lesson!.color != "0xFF676767" ? Color(lesson!.color) : nil
lesson!.color == "#676767"
? nil
: Color(hex: lesson!.color)
)
}
}
@ -147,7 +176,11 @@ struct LiveCardWidget: Widget {
.font(.system(size: CGFloat(10)))
}
}
.keylineTint(.accentColor)
.keylineTint(
lesson!.color == "#676767"
? nil
: Color(hex: lesson!.color)
)
}
}
}

View File

@ -87,6 +87,7 @@ class LiveCardProvider extends ChangeNotifier {
// Debugging
static DateTime _now() {
// return DateTime(2023, 8, 31, 8, 0);
return DateTime.now();
}
@ -110,7 +111,8 @@ class LiveCardProvider extends ChangeNotifier {
switch (currentState) {
case LiveCardState.duringLesson:
return {
"color": _settings.liveActivityColor.toString(),
"color":
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
"icon": currentLesson != null
? SubjectIcon.resolveName(subject: currentLesson?.subject)
: "book",
@ -143,7 +145,8 @@ class LiveCardProvider extends ChangeNotifier {
final diff = getFloorDifference();
return {
"color": _settings.liveActivityColor.toString(),
"color":
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
"icon": iconFloorMap[diff] ?? "cup.and.saucer",
"title": "Szünet",
"description": "go $diff".i18n.fill([