mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-25 08:22:07 +00:00
104 lines
4.0 KiB
Plaintext
104 lines
4.0 KiB
Plaintext
@inherits ViewBase<LaunchView, LaunchViewModel>
|
|
@using Daybreak.Shared.Models
|
|
@using Daybreak.Shared.Models.ColorPalette
|
|
@page "/launch"
|
|
|
|
<div class="launch-container">
|
|
<div class="launch-button-container">
|
|
<!-- Main Launch Button with Dropdown -->
|
|
<div class="launch-button-group" style="@this.GetButtonGroupStyle()">
|
|
<!-- Main Launch Button -->
|
|
<button class="launch-button @(this.ViewModel.CanLaunch ? "enabled" : "disabled")"
|
|
@onclick="this.ViewModel.LaunchSelectedConfiguration">
|
|
<div class="launch-button-content">
|
|
@if (this.ViewModel.IsLaunching)
|
|
{
|
|
<div class="spinner" />
|
|
}
|
|
<div class="launch-text-container">
|
|
<span class="launch-text">@this.ViewModel.LaunchButtonText</span>
|
|
@if (!string.IsNullOrEmpty(this.ViewModel.LaunchButtonSubtext))
|
|
{
|
|
<span class="launch-subtext">@this.ViewModel.LaunchButtonSubtext</span>
|
|
}
|
|
</div>
|
|
</div>
|
|
</button>
|
|
|
|
<!-- Dropdown Arrow Button -->
|
|
<button class="dropdown-toggle-button @(this.ViewModel.LaunchConfigurations.Any() ? "enabled" : "disabled")"
|
|
@onclick="this.ViewModel.ToggleDropdown">
|
|
<span class="dropdown-arrow @(this.ViewModel.IsDropdownOpen ? "open" : "")">⏷</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Dropdown Menu -->
|
|
@if (this.ViewModel.IsDropdownOpen && this.ViewModel.LaunchConfigurations.Any())
|
|
{
|
|
<div class="dropdown-menu" @onclick:stopPropagation="true">
|
|
@foreach (var config in this.ViewModel.LaunchConfigurations.Where(c => c != this.ViewModel.SelectedConfiguration))
|
|
{
|
|
<div class="dropdown-item @(config == ViewModel.SelectedConfiguration ? "selected" : "")"
|
|
style="@this.GetDropdownItemStyle(config)"
|
|
@onclick="() => this.ViewModel.SelectConfiguration(config)">
|
|
<div class="config-info">
|
|
<div class="config-name">@(config.Configuration?.Name is null or ""
|
|
? config.Configuration?.Credentials?.Username ?? "Unknown User"
|
|
: config.Configuration.Name)</div>
|
|
@if (!string.IsNullOrEmpty(config.Configuration?.ExecutablePath))
|
|
{
|
|
<div class="config-path">@config.Configuration.ExecutablePath</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Click outside to close dropdown -->
|
|
@if (this.ViewModel.IsDropdownOpen)
|
|
{
|
|
<div class="dropdown-backdrop" @onclick="this.ViewModel.CloseDropdown" />
|
|
}
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string? AutoLaunchConfigurationId { get; set; }
|
|
|
|
private string GetButtonGroupStyle()
|
|
{
|
|
var colorName = this.ViewModel.SelectedConfiguration?.Configuration?.Color;
|
|
if (string.IsNullOrWhiteSpace(colorName))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var accentColor = AccentColor.Accents.FirstOrDefault(a => a.Name.ToString() == colorName);
|
|
if (accentColor is null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return $"background: {accentColor.Hex};";
|
|
}
|
|
|
|
private string GetDropdownItemStyle(LauncherViewContext config)
|
|
{
|
|
var colorName = config.Configuration?.Color;
|
|
if (string.IsNullOrWhiteSpace(colorName))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var accentColor = AccentColor.Accents.FirstOrDefault(a => a.Name.ToString() == colorName);
|
|
if (accentColor is null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return $"border-left: 4px solid {accentColor.Hex};";
|
|
}
|
|
}
|