Idk, dev work goin on

This commit is contained in:
2026-09-09 16:19:45 +03:00 Unverified
parent b0d8bcd742
commit 17a0a9f7a6
318 changed files with 11908 additions and 81 deletions
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="WinWARP.Ui.Views.Components.ServerListElement"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinWARP.Ui.Views.Components"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ct="using:CommunityToolkit.WinUI.Controls"
xmlns:w="using:WinWARP.Core.ViewModels.Wrappers"
xmlns:conv="using:WinWARP.Ui.Converters"
xmlns:h="using:WinWARP.Ui.Helpers"
Height="64" Width="300"
mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate x:DataType="w:StandaloneServerViewModel" x:Key="StandaloneServerTemplate">
<StackPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:DataType="w:SubscriptionServerViewModel" x:Key="SubscriptionServerTemplate">
<StackPanel>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<UserControl.ContextFlyout>
<MenuFlyout x:Name="ServerListFlyout">
<MenuFlyoutItem Text="Option 1"/>
<MenuFlyoutItem Text="Option 2"/>
</MenuFlyout>
</UserControl.ContextFlyout>
<Grid MaxHeight="64">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle Grid.RowSpan="3" Height="64"/>
<Border Grid.RowSpan="3" MinHeight="64" MaxHeight="64" VerticalAlignment="Top">
<Border Width="48" Height="48" VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="24">
<Image Stretch="UniformToFill">
<Image.Source>
<SvgImageSource UriSource="{x:Bind CountryCodeToUri(ServerData.Region), Mode=OneWay}"/>
</Image.Source>
</Image>
</Border>
</Border>
<!--<Rectangle Grid.Column="1" Fill="Aqua"/>
<Rectangle Grid.Column="1" Grid.Row="1" Fill="Beige"/>
<Rectangle Grid.Column="1" Grid.Row="2" Fill="Brown"/>-->
<StackPanel Grid.Column="1">
<TextBlock Text="{x:Bind Title(ServerData), Mode=OneWay}" Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Text="{x:Bind ServerData.DefaultTitle, Mode=OneWay}" Style="{StaticResource CaptionTextBlockStyle}" Visibility="{x:Bind IsNotDefaultTitle(ServerData), Mode=OneWay}"/>
</StackPanel>
<Button Grid.Column="2" Height="24" Width="24" Padding="0" Margin="4" VerticalAlignment="Top" Click="MenuButton_Click">
<FontIcon Glyph="&#xE712;" FontSize="10"/>
</Button>
<ItemsView Grid.Column="1" Grid.Row="1" ItemsSource="{x:Bind ServerData.Tags, Mode=OneWay}" VerticalAlignment="Center" SelectionMode="None">
<ItemsView.Layout>
<ct:WrapLayout Orientation="Horizontal" HorizontalSpacing="4" VerticalSpacing="4"/>
</ItemsView.Layout>
<ItemsView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<ItemContainer>
<Border Background="{ThemeResource SystemControlBackgroundAccentBrush}" CornerRadius="4" Padding="4,0">
<TextBlock Text="{x:Bind}" Style="{StaticResource CaptionTextBlockStyle}"/>
</Border>
</ItemContainer>
</DataTemplate>
</ItemsView.ItemTemplate>
</ItemsView>
<!--<TextBlock Grid.Column="1" Text="both server"/>-->
<!--<ContentPresenter Grid.Column="1" Grid.Row="1" Content="{x:Bind ServerData}" ContentTemplate="{x:Bind ChooseTemplate(ServerData), Mode=OneWay}"/>-->
</Grid>
</UserControl>
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using WinWARP.Core.ViewModels;
using WinWARP.Core.ViewModels.Wrappers;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace WinWARP.Ui.Views.Components;
public sealed partial class ServerListElement : UserControl
{
public static readonly DependencyProperty ServerDataProperty =
DependencyProperty.Register(nameof(ServerData), typeof(ServerItemViewModel),
typeof(ServerListElement), new PropertyMetadata(null));
public ServerItemViewModel ServerData
{
get => (ServerItemViewModel)GetValue(ServerDataProperty);
set => SetValue(ServerDataProperty, value);
}
public string Title(ServerItemViewModel serverData) => string.IsNullOrEmpty(serverData?.Title) ? (string.IsNullOrEmpty(serverData?.DefaultTitle) ? string.Empty : serverData.DefaultTitle) : serverData.Title;
public Visibility IsNotDefaultTitle(ServerItemViewModel serverData) => (!string.IsNullOrEmpty(serverData?.Title) && serverData?.Title != serverData?.DefaultTitle) ? Visibility.Visible : Visibility.Collapsed;
public ServerListElement()
{
InitializeComponent();
}
private DataTemplate ChooseTemplate(ServerItemViewModel data)
{
if (data == null) return null;
return data switch
{
StandaloneServerViewModel => (DataTemplate)Resources["StandaloneServerTemplate"],
SubscriptionServerViewModel => (DataTemplate)Resources["SubscriptionServerTemplate"],
_ => (DataTemplate)Resources["StandaloneServerTemplate"]
};
}
private Uri CountryCodeToUri(string countryCode)
{
if (!string.IsNullOrWhiteSpace(countryCode))
{
return new Uri($"ms-appx:///Assets/Flags/{countryCode.ToLower()}.svg", UriKind.Absolute);
}
else
{
return new Uri("ms-appx:///Assets/Flags/xx.svg", UriKind.Absolute);
}
}
private void MenuButton_Click(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
var options = new FlyoutShowOptions
{
Placement = FlyoutPlacementMode.LeftEdgeAlignedTop,
ShowMode = FlyoutShowMode.Standard
};
ServerListFlyout.ShowAt(button, options);
}
}
}