- tweak: UI improvement

This commit is contained in:
2025-02-02 10:57:29 +03:00
parent 32fd63c5f3
commit 3c980659be
21 changed files with 283 additions and 83 deletions

View File

@@ -11,6 +11,7 @@
<entry key="Nebula.Launcher/ViewModels/Styles1.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Controls/PlayerContainerControl.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Controls/ServerContainerControl.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/ExceptionView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/MainView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/MainWindow.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Pages/AccountInfoPage.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
@@ -20,6 +21,7 @@
<entry key="Nebula.Launcher/Views/Pages/FavoriteServerListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Pages/ServerListPage.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Pages/ServerListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Popup/ExceptionListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Popup/ExceptionView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Popup/InfoPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
<entry key="Nebula.Launcher/Views/Popup/LoadingContextView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />

View File

@@ -3,4 +3,8 @@
<SolidColorBrush x:Key="DefaultForeground">#121212</SolidColorBrush>
<SolidColorBrush x:Key="DefaultSelected">#D95F59</SolidColorBrush>
<BoxShadows x:Key="DefaultShadow">0 0 10 -1 #121212</BoxShadows>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%" x:Key="DefaultGrad">
<GradientStop Color="#262222" Offset="0.0" />
<GradientStop Color="#222222" Offset="1.0" />
</LinearGradientBrush>
</ResourceDictionary>

View File

@@ -59,7 +59,13 @@
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="CornerRadius" Value="0,8,8,0" />
<Setter Property="Background" Value="{StaticResource DefaultSelected}" />
<Setter Property="Background">
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#ae4c47" Offset="0.0" />
<GradientStop Color="#D95F59" Offset="0.2" />
<GradientStop Color="#D95F59" Offset="1.0" />
</LinearGradientBrush>
</Setter>
<Setter Property="BoxShadow" Value="0 0 15 1 #1212" />
</Style>
<Style Selector="ListBoxItem:pointerover">

View File

@@ -3,6 +3,7 @@ using System.Reflection;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Nebula.Launcher.ViewModels;
using Nebula.Launcher.Views;
namespace Nebula.Launcher;
@@ -12,6 +13,11 @@ public class ViewLocator : IDataTemplate
{
if (param is null)
return null;
if (param is Exception e)
{
return new ExceptionView(e);
}
var type = param.GetType().GetCustomAttribute<ViewModelRegisterAttribute>()?.Type;
@@ -22,6 +28,6 @@ public class ViewLocator : IDataTemplate
public bool Match(object? data)
{
return data is ViewModelBase;
return data is ViewModelBase || data is Exception;
}
}

View File

@@ -115,7 +115,7 @@ public partial class MainViewModel : ViewModelBase
PopupMessage(@base);
break;
case Exception error:
var err = ViewHelperService.GetViewModel<ExceptionViewModel>();
var err = ViewHelperService.GetViewModel<ExceptionListViewModel>();
DebugService.Error(error);
err.AppendError(error);
PopupMessage(err);

View File

@@ -24,6 +24,7 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
[ObservableProperty] private bool _isFavoriteMode;
public ObservableCollection<ServerEntryModelView> Servers { get; }= new();
public ObservableCollection<Exception> HubErrors { get; } = new();
public Action? OnSearchChange;
[GenerateProperty] private HubService HubService { get; }
@@ -40,6 +41,7 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
protected override void InitialiseInDesignMode()
{
ServerViewContainer = new ServerViewContainer(this, RestService, CancellationService, DebugService, ViewHelperService);
HubErrors.Add(new Exception("UVI"));
}
//real think
@@ -51,12 +53,18 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
HubService.HubServerChangedEventArgs += HubServerChangedEventArgs;
HubService.HubServerLoaded += UpdateServerEntries;
HubService.HubServerLoadingError += HubServerLoadingError;
OnSearchChange += OnChangeSearch;
if (!HubService.IsUpdating) UpdateServerEntries();
UpdateFavoriteEntries();
}
private void HubServerLoadingError(Exception obj)
{
HubErrors.Add(obj);
}
private void UpdateServerEntries()
{
Servers.Clear();
@@ -120,6 +128,7 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
public void UpdateRequired()
{
HubErrors.Clear();
Task.Run(HubService.UpdateHub);
}

View File

@@ -5,9 +5,9 @@ using Nebula.Shared.Services;
namespace Nebula.Launcher.ViewModels.Popup;
[ViewModelRegister(typeof(ExceptionView), false)]
[ViewModelRegister(typeof(ExceptionListView), false)]
[ConstructGenerator]
public sealed partial class ExceptionViewModel : PopupViewModelBase
public sealed partial class ExceptionListViewModel : PopupViewModelBase
{
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
public override string Title => "Oopsie! Some shit is happened now!";

View File

@@ -281,6 +281,7 @@ public partial class ServerEntryModelView : ViewModelBase
Description = info.Desc;
Links.Clear();
if(info.Links is null) return;
foreach (var link in info.Links)
{
Links.Add(link);

View File

@@ -0,0 +1,46 @@
<UserControl
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="Nebula.Launcher.Views.ExceptionView"
x:DataType="system:Exception"
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.DataContext>
<system:Exception />
</Design.DataContext>
<Border
BoxShadow="{StaticResource DefaultShadow}"
CornerRadius="5"
Margin="0,0,0,5">
<Border.Background>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#443333" Offset="0.0" />
<GradientStop Color="#333333" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<StackPanel>
<Border CornerRadius="5,5,0,0">
<Border.Background>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#FF6B6B" Offset="0.0" />
<GradientStop Color="#FF8E53" Offset="0.3" />
<GradientStop Color="#FF5E3A" Offset="0.6" />
<GradientStop Color="#FF5e5e" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<ScrollViewer>
<Label Margin="4">
<TextBlock Text="{Binding Message}" />
</Label>
</ScrollViewer>
</Border>
<Label Margin="4">
<TextBlock Text="{Binding StackTrace}" TextWrapping="Wrap" />
</Label>
</StackPanel>
</Border>
</UserControl>

View File

@@ -0,0 +1,19 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Nebula.Launcher.Views;
public partial class ExceptionView : UserControl
{
public ExceptionView()
{
InitializeComponent();
}
public ExceptionView(Exception exception): this()
{
DataContext = exception;
}
}

View File

@@ -1,5 +1,4 @@
<UserControl
Background="#1a1a1a"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -15,6 +14,12 @@
<Design.DataContext>
<viewModels:MainViewModel />
</Design.DataContext>
<UserControl.Background>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#121212" Offset="0.0" />
<GradientStop Color="#181212" Offset="1.0" />
</LinearGradientBrush>
</UserControl.Background>
<Panel>
<Grid
@@ -29,7 +34,7 @@
Grid.Row="0" />
<SplitView
CompactPaneLength="65"
CompactPaneLength="70"
DisplayMode="CompactInline"
Grid.Column="0"
Grid.ColumnSpan="2"
@@ -38,13 +43,19 @@
PaneBackground="Transparent">
<SplitView.Pane>
<Border
Background="{StaticResource DefaultBackground}"
BoxShadow="0 0 15 -2 #121212"
CornerRadius="0,8,8,0"
CornerRadius="0,0,0,0"
Grid.Column="0"
Grid.Row="0"
Margin="0,0,5,0"
Padding="0,0,-4,0">
<Border.Background>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#1f1f1f" Offset="0.0" />
<GradientStop Color="#222222" Offset="0.2" />
<GradientStop Color="#222222" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Grid ColumnDefinitions="*" RowDefinitions="*,40">
<ListBox
Background="Transparent"
@@ -53,7 +64,7 @@
SelectedItem="{Binding SelectedListItem}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type models:ListItemTemplate}">
<StackPanel Orientation="Horizontal" Spacing="17">
<StackPanel Orientation="Horizontal" Spacing="19">
<Svg
Height="40"
Path="{Binding IconKey, Converter={x:Static converters:TypeConverters.IconConverter}}"
@@ -78,14 +89,20 @@
</SplitView>
<Border
Background="{StaticResource DefaultBackground}"
BoxShadow="{StaticResource DefaultShadow}"
Background="{StaticResource DefaultGrad}"
BorderThickness="0,2,0,0"
CornerRadius="0,0,0,0"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
Margin="0,0,0,0"
Padding="5">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#222222" Offset="0.0" />
<GradientStop Color="#442222" Offset="1.0" />
</LinearGradientBrush>
</Border.BorderBrush>
<Label FontSize="10" Foreground="#777777">
<Panel>
<Button

View File

@@ -1,10 +1,17 @@
<Window
Background="{x:Null}"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaTitleBarHeightHint="-1"
ExtendClientAreaToDecorationsHint="True"
Height="500"
Icon="/Assets/avalonia-logo.ico"
MinHeight="500"
MinWidth="800"
SystemDecorations="BorderOnly"
Title="Nebula.Launcher"
TransparencyLevelHint="AcrylicBlur"
Width="800"
WindowStartupLocation="CenterScreen"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -12,4 +19,54 @@
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" />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid ColumnDefinitions="*" RowDefinitions="30,*">
<Border
Background="{StaticResource DefaultGrad}"
BorderThickness="0,0,0,2"
CornerRadius="0"
Grid.Column="0"
Grid.Row="0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
<GradientStop Color="#222222" Offset="0.0" />
<GradientStop Color="#442222" Offset="1.0" />
</LinearGradientBrush>
</Border.BorderBrush>
<Panel
Background="{StaticResource DefaultGrad}"
Height="30"
PointerPressed="InputElement_OnPointerPressed">
<TextBlock
FontSize="10"
Foreground="White"
IsVisible="False"
Margin="15,0"
Text="Nebula Launcher"
VerticalAlignment="Center" />
<StackPanel
HorizontalAlignment="Right"
Margin="5,0,5,0"
Orientation="Horizontal"
Spacing="8">
<Button
Click="Minimize_Click"
Content="🗕"
Foreground="Azure" />
<Button
Click="Maximize_Click"
Content="🗗"
Foreground="Azure" />
<Button
Click="Close_Click"
Content="🗙"
Foreground="Azure" />
</StackPanel>
</Panel>
</Border>
<UserControl
Grid.Column="0"
Grid.Row="1"
x:Name="Control" />
</Grid>
</Window>

View File

@@ -1,5 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
namespace Nebula.Launcher.Views;
@@ -15,9 +17,29 @@ public partial class MainWindow : Window
public MainWindow(MainView mainView)
: this()
{
Content = mainView;
Control.Content = mainView;
#if DEBUG
this.AttachDevTools();
#endif
}
private void Minimize_Click(object? sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void Maximize_Click(object? sender, RoutedEventArgs e)
{
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
}
private void Close_Click(object? sender, RoutedEventArgs e)
{
Close();
}
private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
}

View File

@@ -18,11 +18,16 @@
RowDefinitions="*">
<StackPanel Grid.Column="1" Grid.Row="0">
<Border
Background="{StaticResource DefaultBackground}"
BoxShadow="0 -1 15 -2 #121212"
CornerRadius="10,10,0,0"
Margin="5,5,5,0"
Padding="5">
<Border.Background>
<LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
<GradientStop Color="#222222" Offset="0.0" />
<GradientStop Color="#292222" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Label HorizontalAlignment="Center">Profiles:</Label>
</Border>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
@@ -33,11 +38,16 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type pages:ProfileAuthCredentials}">
<Border
Background="{StaticResource DefaultBackground}"
BoxShadow="0 1 15 -2 #121212"
CornerRadius="0,10,0,10"
Margin="5,5,5,5"
VerticalAlignment="Center">
<Border.Background>
<LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
<GradientStop Color="#292222" Offset="0.0" />
<GradientStop Color="#222222" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Panel>
<StackPanel Margin="10,5,5,5" Orientation="Horizontal">
<Label>Name:</Label>
@@ -76,11 +86,16 @@
Grid.ColumnSpan="{Binding AuthViewSpan}"
Grid.Row="0">
<Border
Background="{StaticResource DefaultBackground}"
BoxShadow="{StaticResource DefaultShadow}"
CornerRadius="10"
Margin="5"
Padding="15">
<Border.Background>
<LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
<GradientStop Color="#292222" Offset="0.0" />
<GradientStop Color="#222222" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Panel>
<StackPanel IsVisible="{Binding !IsLogged}" Spacing="15">
<Svg

View File

@@ -20,9 +20,10 @@
RowDefinitions="*,40">
<ScrollViewer
Grid.RowSpan="2"
Margin="0,0,0,10"
Margin="5,0,0,10"
Padding="0,0,10,0">
<Panel>
<StackPanel>
<ItemsControl ItemsSource="{Binding HubErrors}" Margin="10,0,10,0" />
<ItemsControl
IsVisible="{Binding IsFavoriteMode}"
ItemsSource="{Binding FavoriteServers}"
@@ -31,7 +32,7 @@
IsVisible="{Binding !IsFavoriteMode}"
ItemsSource="{Binding Servers}"
Padding="0" />
</Panel>
</StackPanel>
</ScrollViewer>
<Border
@@ -43,10 +44,10 @@
<Grid
ColumnDefinitions="*,40,40,40"
Grid.Row="1"
Margin="5,0,0,0"
Margin="-25,0,0,0"
RowDefinitions="*">
<TextBox
Margin="0"
Margin="25,0,0,0"
Text="{Binding SearchText}"
TextChanged="TextBox_OnTextChanged"
VerticalAlignment="Center"

View File

@@ -0,0 +1,22 @@
<UserControl
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="Nebula.Launcher.Views.Popup.ExceptionListView"
x:DataType="popup:ExceptionListViewModel"
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:popup="clr-namespace:Nebula.Launcher.ViewModels.Popup"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.DataContext>
<popup:ExceptionListViewModel />
</Design.DataContext>
<ScrollViewer Margin="10" Padding="0,0,8,0">
<ItemsControl
Background="#00000000"
ItemsSource="{Binding Errors}"
Padding="0" />
</ScrollViewer>
</UserControl>

View File

@@ -0,0 +1,17 @@
using Avalonia.Controls;
using Nebula.Launcher.ViewModels.Popup;
namespace Nebula.Launcher.Views.Popup;
public partial class ExceptionListView : UserControl
{
public ExceptionListView()
{
InitializeComponent();
}
public ExceptionListView(ExceptionListViewModel listViewModel) : this()
{
DataContext = listViewModel;
}
}

View File

@@ -1,36 +0,0 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:popup="clr-namespace:Nebula.Launcher.ViewModels.Popup"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Nebula.Launcher.Views.Popup.ExceptionView"
x:DataType="popup:ExceptionViewModel">
<Design.DataContext>
<popup:ExceptionViewModel />
</Design.DataContext>
<ScrollViewer Margin="10" Padding="0,0,8,0">
<ItemsControl
Background="#00000000"
ItemsSource="{Binding Errors}"
Padding="0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type system:Exception}">
<Border Background="#333333" CornerRadius="5" Margin="0,0,0,5">
<StackPanel>
<Border Background="#aa2222" CornerRadius="5,5,0,0">
<Label Margin="4">
<TextBlock Text="{Binding Message}" />
</Label>
</Border>
<Label Margin="4">
<TextBlock Text="{Binding StackTrace}" />
</Label>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</UserControl>

View File

@@ -1,17 +0,0 @@
using Avalonia.Controls;
using Nebula.Launcher.ViewModels.Popup;
namespace Nebula.Launcher.Views.Popup;
public partial class ExceptionView : UserControl
{
public ExceptionView()
{
InitializeComponent();
}
public ExceptionView(ExceptionViewModel viewModel) : this()
{
DataContext = viewModel;
}
}

View File

@@ -19,14 +19,15 @@
</Design.DataContext>
<Border
Background="{StaticResource DefaultBackground}"
Background="{StaticResource DefaultGrad}"
BoxShadow="-2 0 5 -1 #121212"
CornerRadius="10"
Margin="5">
<Grid ColumnDefinitions="*,80,50,50" RowDefinitions="35,*,*">
<Border
Background="Transparent"
BoxShadow="0 3 3 -1 #121212"
BoxShadow="0 3 3 -2 #121212"
CornerRadius="10"
Grid.Column="0"
Grid.ColumnSpan="2"
@@ -34,7 +35,7 @@
IsVisible="{Binding ExpandInfo}" />
<Button
Background="#00000000"
Background="Transparent"
Command="{Binding ExpandInfoRequired}"
Grid.Column="0"
Grid.Row="0"
@@ -124,7 +125,7 @@
<Border
Background="Transparent"
BoxShadow="0 -3 3 -1 #121212"
BoxShadow="0 -3 3 -2 #121212"
CornerRadius="10"
Grid.Column="0"
Grid.ColumnSpan="3"

View File

@@ -12,6 +12,7 @@ public class HubService
public Action<HubServerChangedEventArgs>? HubServerChangedEventArgs;
public Action? HubServerLoaded;
public Action<Exception>? HubServerLoadingError;
public HubService(ConfigurationService configurationService, RestService restService)
{
@@ -36,10 +37,17 @@ public class HubService
foreach (var urlStr in _configurationService.GetConfigValue(CurrentConVar.Hub)!)
{
var servers =
await _restService.GetAsyncDefault<List<ServerHubInfo>>(new Uri(urlStr), [], CancellationToken.None);
_serverList.AddRange(servers);
HubServerChangedEventArgs?.Invoke(new HubServerChangedEventArgs(servers, HubServerChangeAction.Add));
try
{
var servers =
await _restService.GetAsync<List<ServerHubInfo>>(new Uri(urlStr), CancellationToken.None);
_serverList.AddRange(servers);
HubServerChangedEventArgs?.Invoke(new HubServerChangedEventArgs(servers, HubServerChangeAction.Add));
}
catch (Exception e)
{
HubServerLoadingError?.Invoke(e);
}
}
IsUpdating = false;