feat: Add banner infra.
This commit is contained in:
@@ -5,5 +5,6 @@
|
||||
xmlns:local="using:Ursa.Demo">
|
||||
<Application.Styles>
|
||||
<StyleInclude Source="avares://Semi.Avalonia/Themes/LightTheme.axaml" />
|
||||
<StyleInclude Source="avares://Ursa.Themes.Semi/Index.axaml" />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
|
||||
@@ -21,7 +21,6 @@ public partial class App : Application
|
||||
{
|
||||
// Line below is needed to remove Avalonia data validation.
|
||||
// Without this line you will get duplicate validations from both Avalonia and CT
|
||||
ExpressionObserver.DataValidators.RemoveAll(x => x is DataAnnotationsValidationPlugin);
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = new MainWindowViewModel(),
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview4" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
|
||||
<PackageReference Include="Semi.Avalonia" Version="0.1.0-preview3" />
|
||||
<PackageReference Include="Semi.Avalonia" Version="0.1.0-preview5" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj" />
|
||||
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Ursa.Demo.ViewModels;
|
||||
|
||||
namespace Ursa.Demo;
|
||||
|
||||
public class ViewLocator : IDataTemplate
|
||||
{
|
||||
public IControl Build(object data)
|
||||
{
|
||||
var name = data.GetType().FullName!.Replace("ViewModel", "View");
|
||||
var type = Type.GetType(name);
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
return (Control)Activator.CreateInstance(type)!;
|
||||
}
|
||||
|
||||
return new TextBlock { Text = "Not Found: " + name };
|
||||
}
|
||||
|
||||
public bool Match(object data)
|
||||
{
|
||||
return data is ViewModelBase;
|
||||
}
|
||||
}
|
||||
15
src/Ursa.Themes.Semi/Controls/Banner.axaml
Normal file
15
src/Ursa.Themes.Semi/Controls/Banner.axaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:Banner}" TargetType="u:Banner">
|
||||
<Setter Property="u:Banner.Template">
|
||||
<ControlTemplate TargetType="u:Banner">
|
||||
<Border>
|
||||
<!-- -->
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
6
src/Ursa.Themes.Semi/Controls/_index.axaml
Normal file
6
src/Ursa.Themes.Semi/Controls/_index.axaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
21
src/Ursa.Themes.Semi/Index.axaml
Normal file
21
src/Ursa.Themes.Semi/Index.axaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="20">
|
||||
<!-- Add Controls for Previewer Here -->
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceInclude x:Key="Dark" Source="./Themes/Dark/_index.axaml" />
|
||||
<ResourceInclude x:Key="Light" Source="Themes/Light/_index.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="../Controls/Banner.axaml" />
|
||||
<ResourceInclude Source="Themes/Shared/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Styles.Resources>
|
||||
|
||||
<!-- Add Styles Here -->
|
||||
</Styles>
|
||||
3
src/Ursa.Themes.Semi/Themes/Dark/Banner.axaml
Normal file
3
src/Ursa.Themes.Semi/Themes/Dark/Banner.axaml
Normal file
@@ -0,0 +1,3 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
</ResourceDictionary>
|
||||
6
src/Ursa.Themes.Semi/Themes/Dark/_index.axaml
Normal file
6
src/Ursa.Themes.Semi/Themes/Dark/_index.axaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
3
src/Ursa.Themes.Semi/Themes/Light/Banner.axaml
Normal file
3
src/Ursa.Themes.Semi/Themes/Light/Banner.axaml
Normal file
@@ -0,0 +1,3 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
</ResourceDictionary>
|
||||
6
src/Ursa.Themes.Semi/Themes/Light/_index.axaml
Normal file
6
src/Ursa.Themes.Semi/Themes/Light/_index.axaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
3
src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml
Normal file
3
src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml
Normal file
@@ -0,0 +1,3 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
</ResourceDictionary>
|
||||
6
src/Ursa.Themes.Semi/Themes/Shared/_index.axaml
Normal file
6
src/Ursa.Themes.Semi/Themes/Shared/_index.axaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,13 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>11</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -15,8 +16,4 @@
|
||||
<ProjectReference Include="..\Ursa\Ursa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controls" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
4
src/Ursa/AssemblyInfo.cs
Normal file
4
src/Ursa/AssemblyInfo.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
using Avalonia.Metadata;
|
||||
|
||||
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa")]
|
||||
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls")]
|
||||
44
src/Ursa/Controls/Banner.cs
Normal file
44
src/Ursa/Controls/Banner.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public enum BannerType
|
||||
{
|
||||
None,
|
||||
Info,
|
||||
Warning,
|
||||
Danger,
|
||||
Success,
|
||||
}
|
||||
public class Banner: ContentControl
|
||||
{
|
||||
public static readonly StyledProperty<bool> CanCloseProperty = AvaloniaProperty.Register<Banner, bool>(
|
||||
nameof(CanClose));
|
||||
|
||||
public bool CanClose
|
||||
{
|
||||
get => GetValue(CanCloseProperty);
|
||||
set => SetValue(CanCloseProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<bool> ShowIconProperty = AvaloniaProperty.Register<Banner, bool>(
|
||||
nameof(ShowIcon));
|
||||
|
||||
public bool ShowIcon
|
||||
{
|
||||
get => GetValue(ShowIconProperty);
|
||||
set => SetValue(ShowIconProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<object?> HeaderProperty = AvaloniaProperty.Register<Banner, object?>(
|
||||
nameof(Header));
|
||||
|
||||
public object? Header
|
||||
{
|
||||
get => GetValue(HeaderProperty);
|
||||
set => SetValue(HeaderProperty, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>11</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controls\Menu" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user