Skip to content

Commit b842725

Browse files
authored
Merge pull request #226 from TeamWheelWizard/any-status-badge
more flexible status icon
2 parents cf119aa + 265ce54 commit b842725

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

WheelWizard/Features/WheelWizardData/Domain/WhWzStatus.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
public class WhWzStatus
44
{
5-
public required WhWzStatusVariant Variant { get; set; }
5+
/// <summary>
6+
/// The variant type (used for preset icon styles). Optional if Icon is provided.
7+
/// </summary>
8+
public WhWzStatusVariant? Variant { get; set; }
9+
10+
/// <summary>
11+
/// Custom SVG path data for the icon. If provided, this takes precedence over Variant.
12+
/// </summary>
13+
public string? Icon { get; set; }
14+
15+
/// <summary>
16+
/// Custom color for the icon (hex format like "#123456"). Used when Icon is provided.
17+
/// </summary>
18+
public string? Color { get; set; }
19+
620
public required string Message { get; set; }
721
}

WheelWizard/Views/Layout.axaml.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,46 @@ public void UpdatePlayerAndRoomCount(RRLiveRooms sender)
180180

181181
private void UpdateLiveAlert(WhWzStatusManager sender)
182182
{
183-
var visible = sender.Status != null && sender.Status.Variant != WhWzStatusVariant.None;
183+
var hasVariant = sender.Status?.Variant != null && sender.Status.Variant != WhWzStatusVariant.None;
184+
var hasCustomIcon = !string.IsNullOrEmpty(sender.Status?.Icon);
185+
var visible = hasVariant || hasCustomIcon;
186+
184187
LiveStatusBorder.IsVisible = visible;
185188
if (!visible)
186189
return;
187190

188191
ToolTip.SetTip(LiveStatusBorder, sender.Status!.Message);
189192
LiveStatusBorder.Classes.Clear();
190-
LiveStatusBorder.Classes.Add(sender.Status!.Variant.ToString());
193+
194+
// If custom icon is provided, use it instead of variant
195+
if (hasCustomIcon)
196+
{
197+
// Clear any variant-based classes
198+
LiveStatusBorder.Classes.Add("Custom");
199+
200+
// Find the PathIcon in the LiveStatusBorder and update it dynamically
201+
if (LiveStatusBorder.Child is PathIcon pathIcon)
202+
{
203+
// Parse the SVG path data
204+
var geometry = Geometry.Parse(sender.Status.Icon!);
205+
pathIcon.Data = geometry;
206+
207+
// Apply custom color if provided, otherwise use a default
208+
if (!string.IsNullOrEmpty(sender.Status.Color))
209+
{
210+
pathIcon.Foreground = new SolidColorBrush(Color.Parse(sender.Status.Color));
211+
}
212+
else
213+
{
214+
pathIcon.Foreground = new SolidColorBrush(Colors.White);
215+
}
216+
}
217+
}
218+
else
219+
{
220+
// Use variant-based styling
221+
LiveStatusBorder.Classes.Add(sender.Status.Variant.ToString()!);
222+
}
191223
}
192224

193225
private void TopBar_PointerPressed(object? sender, PointerPressedEventArgs e)

0 commit comments

Comments
 (0)