Commit 79b7154b authored by shrabbit's avatar shrabbit
Browse files

移除自定义主题并切换到 Semi.Avalonia 主题

- 移除 `Seek.Theme/Styles/Colors.axaml`、`Controls.axaml` 和 `Typography.axaml`
- 更新 `Seek.Theme/SeekTheme.axaml`,移除合并的自定义样式资源
- 更新 `Seek/Seek.csproj` 和 `Seek.Theme/Seek.Theme.csproj` 项目文件,添加 `Semi.Avalonia` 及其相关依赖项
- 更新 `Seek.Theme.Demo/Program.cs`,移除 Inter 字体配置
- 更新 `Seek.Theme.Demo/App.axaml`,添加 `semi` 命名空间
- 更新 `Seek.Theme.Demo/MainWindow.axaml` 和 `MainWindow.axaml.cs`,添加新的控件和功能以支持新主题
- 更新 `Seek.Theme.Demo/Seek.Theme.Demo.csproj`,添加 `Dock.Model` 和 `Dock.Model.Mvvm` 依赖项
parent da4abf19
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="Seek.Theme.Demo.App"
             RequestedThemeVariant="Default">
             RequestedThemeVariant="Default"
             xmlns:semi="https://irihi.tech/semi">

    <Application.Styles>
        <StyleInclude Source="avares://Seek.Theme/SeekTheme.axaml" />
+337 −155

File changed.

Preview size limit exceeded, changes collapsed.

+158 −1
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Styling;
using Dock.Avalonia.Controls;
using Dock.Model.Controls;
using Dock.Model.Core;
using Dock.Model.Mvvm;
using Dock.Model.Mvvm.Controls;

namespace Seek.Theme.Demo;

public partial class MainWindow : Window
{
    private DemoDockFactory? _dockFactory;

    public MainWindow()
    {
        InitializeComponent();
        InitializeDock();
    }

    private void InitializeDock()
    {
        _dockFactory = new DemoDockFactory();
        var layout = _dockFactory.CreateLayout();
        if (layout != null)
        {
            _dockFactory.InitLayout(layout);
            DockControl.Layout = layout;
        }
    }

    private void SwitchToLight(object? sender, RoutedEventArgs e)
    {
        RequestedThemeVariant = ThemeVariant.Light;
    }

    private void SwitchToDark(object? sender, RoutedEventArgs e)
    {
        RequestedThemeVariant = ThemeVariant.Dark;
    }

    private void SwitchToDefault(object? sender, RoutedEventArgs e)
    {
        RequestedThemeVariant = ThemeVariant.Default;
    }

    private void CloseFlyout(object? sender, RoutedEventArgs e)
    {
        if (sender is Control control)
        {
            FlyoutBase.GetAttachedFlyout(control)?.Hide();
        }
    }

    private void TogglePopup(object? sender, RoutedEventArgs e)
    {
        if (DemoPopup != null)
        {
            DemoPopup.IsOpen = !DemoPopup.IsOpen;
            if (DemoPopup.IsOpen)
            {
                DemoPopup.PlacementTarget = sender as Control;
                DemoPopup.Placement = PlacementMode.Bottom;
            }
        }
    }

    private void ClosePopup(object? sender, RoutedEventArgs e)
    {
        DemoPopup?.SetCurrentValue(Popup.IsOpenProperty, false);
    }
}

public class DemoDockFactory : Factory
{
    private IRootDock? _rootDock;

    public override IRootDock CreateLayout()
    {
        var explorerTool = new Tool { Id = "Explorer", Title = "Explorer" };
        var searchTool = new Tool { Id = "Search", Title = "Search" };
        var outputTool = new Tool { Id = "Output", Title = "Output" };
        var problemsTool = new Tool { Id = "Problems", Title = "Problems" };
        var terminalTool = new Tool { Id = "Terminal", Title = "Terminal" };

        var document1 = new Document { Id = "Welcome", Title = "Welcome.md" };
        var document2 = new Document { Id = "App", Title = "App.axaml" };
        var document3 = new Document { Id = "Main", Title = "MainWindow.axaml" };

        var documentDock = new DocumentDock
        {
            Id = "DocumentDock",
            Title = "Documents",
            Proportion = double.NaN,
            CanCreateDocument = true,
            ActiveDockable = document1,
            VisibleDockables = CreateList<IDockable>(document1, document2, document3)
        };

        var leftToolDock = new ToolDock
        {
            ActiveDockable = explorerTool,
            VisibleDockables = CreateList<IDockable>(explorerTool, searchTool),
            Alignment = Alignment.Left,
            Proportion = 0.25
        };

        var bottomToolDock = new ToolDock
        {
            ActiveDockable = outputTool,
            VisibleDockables = CreateList<IDockable>(outputTool, problemsTool, terminalTool),
            Alignment = Alignment.Bottom,
            Proportion = 0.25
        };

        var mainLayout = new ProportionalDock
        {
            Orientation = Orientation.Horizontal,
            VisibleDockables = CreateList<IDockable>
            (
                leftToolDock,
                new ProportionalDockSplitter(),
                new ProportionalDock
                {
                    Orientation = Orientation.Vertical,
                    VisibleDockables = CreateList<IDockable>
                    (
                        documentDock,
                        new ProportionalDockSplitter(),
                        bottomToolDock
                    )
                }
            )
        };

        var rootDock = CreateRootDock();
        rootDock.IsCollapsable = false;
        rootDock.ActiveDockable = mainLayout;
        rootDock.VisibleDockables = CreateList<IDockable>(mainLayout);
        rootDock.DefaultDockable = documentDock;

        _rootDock = rootDock;
        return rootDock;
    }

    public override void InitLayout(IDockable layout)
    {
        ContextLocator = new Dictionary<string, Func<object?>>();

        DockableLocator = new Dictionary<string, Func<IDockable?>>
        {
            ["Root"] = () => _rootDock,
            ["Documents"] = () => layout
        };

        HostWindowLocator = new Dictionary<string, Func<IHostWindow?>>
        {
            [nameof(IDockWindow)] = () => new HostWindow()
        };

        base.InitLayout(layout);
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -16,6 +16,5 @@ class Program
    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .WithInterFont()
            .LogToTrace();
}
 No newline at end of file
+5 −6
Original line number Diff line number Diff line
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net10.0</TargetFramework>
@@ -10,13 +10,12 @@
    <ItemGroup>
        <PackageReference Include="Avalonia" Version="11.3.13" />
        <PackageReference Include="Avalonia.Desktop" Version="11.3.13" />
        <PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.13"/>
        <PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.13"/>
        <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
        <PackageReference Include="Avalonia.Diagnostics" Version="11.3.13">
            <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
            <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Dock.Model" Version="11.3.11.22" />
        <PackageReference Include="Dock.Model.Mvvm" Version="11.3.11.22" />
    </ItemGroup>

    <ItemGroup>
Loading