- add: Auth service

This commit is contained in:
2024-12-22 21:38:19 +03:00
parent 4d64c995f1
commit fd347a4fc8
30 changed files with 894 additions and 211 deletions

View File

@@ -1,37 +0,0 @@
<UserControl
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="Nebula.Launcher.Views.Controls.PlayerContainerControl"
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Border
BorderThickness="0,0,1,0"
CornerRadius="0,10,0,10"
Margin="5,4,5,0"
VerticalAlignment="Center">
<Panel>
<StackPanel Margin="10,5,5,5" Orientation="Horizontal">
<Label Margin="0,0,2,0">Name:</Label>
<Label>Ni Higgers</Label>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button CornerRadius="0,0,0,10" Padding="5">
<Label>
Select
</Label>
</Button>
<Button
BorderThickness="2,0,0,0"
CornerRadius="0,10,0,0"
Padding="5">
<Label>
Delete
</Label>
</Button>
</StackPanel>
</Panel>
</Border>
</UserControl>

View File

@@ -1,13 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Nebula.Launcher.Views.Controls;
public partial class PlayerContainerControl : UserControl
{
public PlayerContainerControl()
{
InitializeComponent();
}
}

View File

@@ -1,57 +0,0 @@
<UserControl
d:DesignHeight="100"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="Nebula.Launcher.Views.Controls.ServerContainerControl"
xmlns="https://github.com/avaloniaui"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid
ColumnDefinitions="*,70"
Margin="0,5,0,5"
RowDefinitions="40,*">
<Border
BorderThickness="2,0,0,0"
Grid.Column="0"
Grid.Row="0"
Padding="10">
<TextBlock x:Name="ServerNameLabel">Server name</TextBlock>
</Border>
<Border
BorderThickness="2,0,0,0"
CornerRadius="0"
Grid.Column="1"
Grid.Row="0"
Padding="5">
<Label HorizontalAlignment="Center" VerticalAlignment="Center">15/15</Label>
</Border>
<Border
BorderThickness="2,0,0,0"
CornerRadius="0,0,10,10"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
MinHeight="50">
<Border.Background>
<ImageBrush Stretch="UniformToFill" asyncImageLoader:ImageBrushLoader.Source="https://t4.ftcdn.net/jpg/00/81/55/69/360_F_81556974_8sF8cKszJaRfBGd5sDt1RXE2QbzDtQqs.jpg" />
</Border.Background>
</Border>
<Panel Grid.Column="1" Grid.Row="1">
<Border Classes="ButtonBack" CornerRadius="0,0,10,0">
<Button
CornerRadius="0,0,10,0"
HorizontalAlignment="Stretch"
Padding="0"
VerticalAlignment="Stretch">
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
Play
</Label>
</Button>
</Border>
</Panel>
</Grid>
</UserControl>

View File

@@ -1,25 +0,0 @@
using Avalonia;
using Avalonia.Controls;
namespace Nebula.Launcher.Views.Controls;
public partial class ServerContainerControl : UserControl
{
public static readonly StyledProperty<string> ServerNameProperty
= AvaloniaProperty.Register<ServerContainerControl, string>(nameof (ServerName));
public string ServerName
{
get => GetValue(ServerNameProperty);
set
{
SetValue(ServerNameProperty, value);
ServerNameLabel.Text = value;
}
}
public ServerContainerControl()
{
InitializeComponent();
}
}

View File

@@ -5,11 +5,13 @@
x:Class="Nebula.Launcher.Views.Pages.AccountInfoView"
x:DataType="viewModels:AccountInfoViewModel"
xmlns="https://github.com/avaloniaui"
xmlns:controls="clr-namespace:Nebula.Launcher.Views.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels">
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels" IsEnabled="{Binding PageEnabled}">
<Design.DataContext>
<viewModels:AccountInfoViewModel />
</Design.DataContext>
<Grid ColumnDefinitions="*,1.5*" RowDefinitions="*">
<StackPanel Grid.Column="0" Grid.Row="0">
<Border
@@ -23,21 +25,28 @@
Source="/Assets/account.png" />
<Grid ColumnDefinitions="120, 100" RowDefinitions="Auto, Auto, Auto">
<Label Grid.Column="0" Grid.Row="0">Login:</Label>
<TextBox Grid.Column="1" Grid.Row="0" />
<TextBox
Grid.Column="1"
Grid.Row="0"
Text="{Binding CurrentLogin}"/>
<Label Grid.Column="0" Grid.Row="1">Password:</Label>
<TextBox
Grid.Column="1"
Grid.Row="1"
PasswordChar="#"
Text="Sas" />
Text="{Binding CurrentPassword}" />
<Label Grid.Column="0" Grid.Row="2">Auth server:</Label>
<TextBox Grid.Column="1" Grid.Row="2" />
<TextBox
Grid.Column="1"
Grid.Row="2"
Text="{Binding CurrentAuthServer}"/>
</Grid>
<StackPanel
HorizontalAlignment="Center"
Margin="5"
Margin="5" Spacing="5"
Orientation="Horizontal">
<Button>Save profile</Button>
<Button Command="{Binding OnSaveProfile}"><Label>Save profile</Label></Button>
<Button Command="{Binding DoAuth}"><Label>Auth</Label></Button>
</StackPanel>
</StackPanel>
</Border>
@@ -51,10 +60,40 @@
<Label HorizontalAlignment="Center">Profiles:</Label>
</Border>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<controls:PlayerContainerControl />
<controls:PlayerContainerControl />
</StackPanel>
<ListBox
Background="#00000000"
ItemsSource="{Binding Accounts}"
Padding="0" Classes="AccountSelector">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type viewModels:AuthLoginPasswordModel}">
<Border Margin="5,5,5,0"
CornerRadius="0,10,0,10"
VerticalAlignment="Center">
<Panel>
<StackPanel Margin="10,5,5,5" Orientation="Horizontal">
<Label>Name:</Label>
<Label><TextBlock Text="{Binding Login}"/></Label>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button CornerRadius="0,0,0,10" Padding="5" Command="{Binding OnSelect}">
<Label>
Select
</Label>
</Button>
<Button
BorderThickness="2,0,0,0"
CornerRadius="0,10,0,0"
Padding="5" Command="{Binding OnDelete}">
<Label>
Delete
</Label>
</Button>
</StackPanel>
</Panel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</StackPanel>
</Grid>

View File

@@ -11,7 +11,7 @@ public partial class AccountInfoView : UserControl
InitializeComponent();
}
public AccountInfoView(ViewModels.AccountInfoViewModel viewModel)
public AccountInfoView(AccountInfoViewModel viewModel)
: this()
{
DataContext = viewModel;

View File

@@ -5,12 +5,12 @@
x:Class="Nebula.Launcher.Views.Pages.ServerListView"
x:DataType="viewModels:ServerListViewModel"
xmlns="https://github.com/avaloniaui"
xmlns:controls="clr-namespace:Nebula.Launcher.Views.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Nebula.Launcher.Models"
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia">
<Design.DataContext>
<viewModels:ServerListViewModel />
@@ -23,8 +23,57 @@
ItemsSource="{Binding ServerInfos}"
Padding="0">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type models:ServerInfo}">
<controls:ServerContainerControl ServerName="{Binding StatusData.Name}" />
<DataTemplate DataType="{x:Type models:ServerHubInfo}">
<Grid
ColumnDefinitions="*,70"
Margin="0,5,0,5"
RowDefinitions="40,*">
<Border
BorderThickness="2,0,0,0"
Grid.Column="0"
Grid.Row="0"
Padding="10">
<TextBlock Text="{Binding StatusData.Name}"/>
</Border>
<Border
BorderThickness="2,0,0,0"
CornerRadius="0"
Grid.Column="1"
Grid.Row="0"
Padding="5">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="{Binding StatusData.Players}"/>
<TextBlock>/</TextBlock>
<TextBlock Text="{Binding StatusData.SoftMaxPlayers}"/>
</StackPanel>
</Border>
<Border
BorderThickness="2,0,0,0"
CornerRadius="0,0,10,10"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
MinHeight="50">
<Border.Background>
<ImageBrush Stretch="UniformToFill" asyncImageLoader:ImageBrushLoader.Source="https://t4.ftcdn.net/jpg/00/81/55/69/360_F_81556974_8sF8cKszJaRfBGd5sDt1RXE2QbzDtQqs.jpg" />
</Border.Background>
</Border>
<Panel Grid.Column="1" Grid.Row="1">
<Border Classes="ButtonBack" CornerRadius="0,0,10,0">
<Button
CornerRadius="0,0,10,0"
HorizontalAlignment="Stretch"
Padding="0"
VerticalAlignment="Stretch">
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
Play
</Label>
</Button>
</Border>
</Panel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>