-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into features/addons-enhancement
- Loading branch information
Showing
18 changed files
with
429 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,94 @@ | ||
using System.Collections.Generic; | ||
using Avalonia.Controls; | ||
using Avalonia.Media; | ||
using CommunityToolkit.Mvvm.Input; | ||
using FluentAvalonia.UI.Controls; | ||
using SkEditor.Controls.Sidebar; | ||
using SkEditor.Utilities; | ||
|
||
namespace SkEditor.Controls; | ||
public partial class SideBarControl : UserControl | ||
{ | ||
private static readonly List<SidebarPanel> Panels = new(); | ||
|
||
public readonly ExplorerSidebarPanel.ExplorerPanel ProjectPanel = new(); | ||
|
||
public static void RegisterPanel(SidebarPanel panel) | ||
{ | ||
Panels.Add(panel); | ||
} | ||
|
||
private SidebarPanel? _currentPanel; | ||
public SideBarControl() | ||
{ | ||
InitializeComponent(); | ||
|
||
RegisterPanel(ProjectPanel); | ||
} | ||
|
||
AssignCommands(); | ||
public void LoadPanels() | ||
{ | ||
foreach (SidebarPanel panel in Panels) | ||
{ | ||
var btn = CreatePanelButton(panel); | ||
var content = panel.Content; | ||
content.Width = 0; | ||
|
||
btn.Command = new RelayCommand(() => | ||
{ | ||
if (_currentPanel == panel) | ||
{ | ||
_currentPanel.Content.Width = 0; // Close current panel | ||
_currentPanel.OnClose(); | ||
_currentPanel = null; | ||
return; | ||
} | ||
if (panel.IsDisabled) | ||
return; | ||
if (_currentPanel != null) | ||
{ | ||
_currentPanel.OnClose(); | ||
_currentPanel.Content.Width = 0; // Close current panel | ||
_currentPanel = null; | ||
} | ||
_currentPanel = panel; | ||
_currentPanel.Content.Width = 250; | ||
_currentPanel.OnOpen(); | ||
}); | ||
|
||
GridPanels.Children.Add(content); | ||
Grid.SetColumn(content, 1); | ||
|
||
Buttons.Children.Add(btn); | ||
} | ||
} | ||
|
||
private void AssignCommands() | ||
private Button CreatePanelButton(SidebarPanel panel) | ||
{ | ||
ProjectsButton.Command = new RelayCommand(() => | ||
var icon = panel.Icon; | ||
if (icon is SymbolIconSource symbolIcon) symbolIcon.FontSize = 24; | ||
IconSourceElement iconElement = new() | ||
{ | ||
IconSource = icon, | ||
Width = 24, | ||
Height = 24, | ||
Foreground = new SolidColorBrush(Color.Parse("#bfffffff")), | ||
}; | ||
|
||
Button button = new() | ||
{ | ||
ScrollViewer.SetHorizontalScrollBarVisibility(FileTreeView, Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled); | ||
ScrollViewer.SetVerticalScrollBarVisibility(FileTreeView, Avalonia.Controls.Primitives.ScrollBarVisibility.Auto); | ||
ExtendedSideBar.Width = ExtendedSideBar.Width == 0 ? 250 : 0; | ||
}); | ||
Height = 36, | ||
Width = 36, | ||
Classes = { "barButton" }, | ||
Content = iconElement, | ||
IsEnabled = !panel.IsDisabled, | ||
}; | ||
|
||
return button; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<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:ui="using:FluentAvalonia.UI.Controls" | ||
x:Class="SkEditor.Controls.Sidebar.ExplorerSidebarPanel"> | ||
|
||
<UserControl.Styles> | ||
<Style Selector="Button.barButton"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="BorderThickness" Value="0"/> | ||
<Setter Property="Padding" Value="0"/> | ||
</Style> | ||
<Style Selector="Separator"> | ||
<Setter Property="Margin" Value="0,1"/> | ||
</Style> | ||
<Style Selector="TreeViewItem"> | ||
<Setter Property="FontWeight" Value="Regular"/> | ||
</Style> | ||
</UserControl.Styles> | ||
|
||
<Border Name="ExtendedSideBar" Background="{DynamicResource SkEditorBorderBackground}" CornerRadius="7" Margin="10,0,0,0"> | ||
<Border.Transitions> | ||
<Transitions> | ||
<DoubleTransition Property="Width" Duration="0:0:0.05" Easing="QuadraticEaseIn"/> | ||
</Transitions> | ||
</Border.Transitions> | ||
|
||
<Grid RowDefinitions="auto,auto,*"> | ||
<TextBlock Grid.Row="0" Text="Explorer" FontWeight="DemiBold" Margin="20,10,20,10"/> | ||
<Separator Grid.Row="1" Margin="0,0,0,10"/> | ||
<TreeView Grid.Row="2" Name="FileTreeView"> | ||
|
||
</TreeView> | ||
</Grid> | ||
</Border> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using FluentAvalonia.UI.Controls; | ||
using SkEditor.Utilities; | ||
|
||
namespace SkEditor.Controls.Sidebar; | ||
|
||
public partial class ExplorerSidebarPanel : UserControl | ||
{ | ||
public ExplorerSidebarPanel() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public class ExplorerPanel : SidebarPanel | ||
{ | ||
public override UserControl Content => Panel; | ||
public override IconSource Icon => new SymbolIconSource() { Symbol = Symbol.Folder }; | ||
public override bool IsDisabled => false; | ||
|
||
public readonly ExplorerSidebarPanel Panel = new (); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.