This commit is contained in:
Tihanyi Marcell
2023-08-29 13:27:25 +02:00
parent 2406e9a45d
commit 894f370dad
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)
)
}
}
}