mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix: welcome page should use a shared singleton instance to manage and filter repositories (#117)
This commit is contained in:
parent
06ca29b2b2
commit
4af8cc18d2
5 changed files with 5 additions and 11 deletions
|
@ -114,7 +114,7 @@ namespace SourceGit.ViewModels
|
||||||
repo.Close();
|
repo.Close();
|
||||||
|
|
||||||
last.Node = new RepositoryNode() { Id = Guid.NewGuid().ToString() };
|
last.Node = new RepositoryNode() { Id = Guid.NewGuid().ToString() };
|
||||||
last.Data = new Welcome();
|
last.Data = Welcome.Instance;
|
||||||
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace SourceGit.ViewModels
|
||||||
public LauncherPage()
|
public LauncherPage()
|
||||||
{
|
{
|
||||||
_node = new RepositoryNode() { Id = Guid.NewGuid().ToString() };
|
_node = new RepositoryNode() { Id = Guid.NewGuid().ToString() };
|
||||||
_data = new Welcome();
|
_data = Welcome.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LauncherPage(RepositoryNode node, Repository repo)
|
public LauncherPage(RepositoryNode node, Repository repo)
|
||||||
|
|
|
@ -8,7 +8,6 @@ using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
|
@ -9,10 +9,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class Welcome : ObservableObject
|
public class Welcome : ObservableObject
|
||||||
{
|
{
|
||||||
public bool IsClearSearchVisible
|
public static Welcome Instance => _instance;
|
||||||
{
|
|
||||||
get => !string.IsNullOrEmpty(_searchFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AvaloniaList<RepositoryNode> RepositoryNodes
|
public AvaloniaList<RepositoryNode> RepositoryNodes
|
||||||
{
|
{
|
||||||
|
@ -25,10 +22,7 @@ namespace SourceGit.ViewModels
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SetProperty(ref _searchFilter, value))
|
if (SetProperty(ref _searchFilter, value))
|
||||||
{
|
|
||||||
Referesh();
|
Referesh();
|
||||||
OnPropertyChanged(nameof(IsClearSearchVisible));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +199,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Welcome _instance = new Welcome();
|
||||||
private string _searchFilter = string.Empty;
|
private string _searchFilter = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
</TextBox.InnerLeftContent>
|
</TextBox.InnerLeftContent>
|
||||||
|
|
||||||
<TextBox.InnerRightContent>
|
<TextBox.InnerRightContent>
|
||||||
<Button Classes="icon_button" IsVisible="{Binding IsClearSearchVisible}" Command="{Binding ClearSearchFilter}">
|
<Button Classes="icon_button" IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" Command="{Binding ClearSearchFilter}">
|
||||||
<Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
|
<Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
|
||||||
</Button>
|
</Button>
|
||||||
</TextBox.InnerRightContent>
|
</TextBox.InnerRightContent>
|
||||||
|
|
Loading…
Reference in a new issue