code_review: PR #160

* should be `Icons.Copy` not `Icon.Copy`
* remove unused using
* keep the same code style in a function
This commit is contained in:
leo 2024-06-01 12:34:16 +08:00
parent 04e6ed45a7
commit 9d9dd6acb5
3 changed files with 27 additions and 22 deletions

View file

@ -10,7 +10,6 @@ using Avalonia.Platform.Storage;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using SourceGit.Models;
namespace SourceGit.ViewModels
{
@ -219,17 +218,17 @@ namespace SourceGit.ViewModels
ev.Handled = true;
};
menu.Items.Add(copyPath);
var copyFileName = new MenuItem()
{
Header = App.Text("CopyFileName"),
Icon = App.CreateMenuIcon("Icon.Copy"),
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
e.Handled = true;
};
menu.Items.Add(copyFileName);
return menu;
}
@ -295,11 +294,9 @@ namespace SourceGit.ViewModels
ev.Handled = true;
};
var copyFileName = new MenuItem()
{
Header = App.Text("CopyFileName"),
Icon = App.CreateMenuIcon("Icon.Copy"),
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(file.Path));

View file

@ -181,19 +181,18 @@ namespace SourceGit.ViewModels
App.CopyText(change.Path);
ev.Handled = true;
};
menu.Items.Add(copyPath);
var copyFileName = new MenuItem()
{
Header = App.Text("CopyFileName"),
Icon = App.CreateMenuIcon("Icon.Copy"),
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
e.Handled = true;
};
menu.Items.Add(copyFileName);
return menu;
}

View file

@ -584,11 +584,10 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
menu.Items.Add(copy);
var copyFileName = new MenuItem()
{
Header = App.Text("CopyFileName"),
Icon = App.CreateMenuIcon("Icon.Copy"),
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
@ -802,6 +801,15 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
e.Handled = true;
};
menu.Items.Add(explore);
menu.Items.Add(openWith);
menu.Items.Add(new MenuItem() { Header = "-" });
@ -811,6 +819,7 @@ namespace SourceGit.ViewModels
menu.Items.Add(patch);
menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
}
else
{