Update Numeric Text transition

This commit is contained in:
Hariharan Mudaliar 2025-12-23 01:52:05 +05:30
commit 8942e1f8a5
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
3 changed files with 61 additions and 10 deletions

View file

@ -73,11 +73,14 @@ struct VerticalHUDView: View {
// Icon & Text overlay
VStack {
if showValue {
Text("\(Int(state.value * 100))%")
.font(.system(size: 10, weight: .bold))
.foregroundStyle(state.value > 0.85 ? (useAccentColor ? .white : .black) : .secondary)
.padding(.top, 8 + (stretchOffset < 0 ? abs(stretchOffset/4) : 0))
.contentTransition(.numericText())
HUDNumericLabel(
value: state.value,
font: .system(size: 10, weight: .bold),
color: valueLabelColor,
alignment: .center,
width: hudWidth * 0.8
)
.padding(.top, 8 + (stretchOffset < 0 ? abs(stretchOffset/4) : 0))
}
Spacer()
@ -225,5 +228,12 @@ struct VerticalHUDView: View {
return AnyShapeStyle(useAccentColor ? Color.accentColor : Color.white)
}
private var valueLabelColor: Color {
if state.value > 0.85 {
return useAccentColor ? .white : .black
}
return .secondary
}
}
#endif