LANCommander/LANCommander.Launcher/UI/Components/Authentication/AuthenticationForm.razor
Pat Hartl 698a7523b6 Code cleanup
- Move all Launcher components to LANCommander.Launcher.UI namespace
- Move all SCSS files next to components (when possible)
- Refactor styles that control overflow of content into titlebar to MainWindow only
- Remove use in launcher UI of SDK.Client
2025-12-31 20:01:04 -06:00

61 lines
No EOL
1.9 KiB
Text

@namespace LANCommander.Launcher.UI
@inject IMessageService MessageService
@inject IConnectionClient ConnectionClient
<Layout Style="background-image: url('/assets/auth-background.jpg'); background-size: cover;">
<Content Class="authentication-form">
<div class="authentication-logo">
<img src="/assets/logo.svg" width="300" />
</div>
<div class="authentication-box">
@if (_stage == AuthenticationStage.SelectServer)
{
<ServerSelector OnSelected="ServerSelected" Connecting="_connecting" />
}
else if (_stage == AuthenticationStage.Login)
{
<LoginForm ServerAddress="@ConnectionClient.GetServerAddress()" OnBack="() => _stage = AuthenticationStage.SelectServer" OnRegister="() => _stage = AuthenticationStage.Register" />
}
else if (_stage == AuthenticationStage.Register)
{
<RegistrationForm ServerAddress="@ConnectionClient.GetServerAddress()" OnBack="() => _stage = AuthenticationStage.Login" />
}
</div>
</Content>
</Layout>
@code {
bool _connecting { get; set; } = false;
AuthenticationStage _stage = AuthenticationStage.None;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (ConnectionClient.HasServerAddress())
_stage = AuthenticationStage.Login;
else
_stage = AuthenticationStage.SelectServer;
}
async Task ServerSelected(Uri serverAddress)
{
try
{
_connecting = true;
await ConnectionClient.UpdateServerAddressAsync(serverAddress);
_stage = AuthenticationStage.Login;
}
catch (Exception ex)
{
MessageService.Error(ex.Message);
}
finally
{
_connecting = false;
}
}
}