feature: saving as patch supports multiple commits (#658)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-06 12:35:55 +08:00
parent c72506d939
commit 9cb85081ab
No known key found for this signature in database
9 changed files with 110 additions and 8 deletions

View file

@ -1,5 +1,7 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace SourceGit.Views
{
@ -28,5 +30,27 @@ namespace SourceGit.Views
e.Handled = true;
}
private async void OnSaveAsPatch(object sender, RoutedEventArgs e)
{
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null)
return;
var vm = DataContext as ViewModels.RevisionCompare;
if (vm == null)
return;
var options = new FilePickerSaveOptions();
options.Title = App.Text("FileCM.SaveAsPatch");
options.DefaultExtension = ".patch";
options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
var storageFile = await topLevel.StorageProvider.SaveFilePickerAsync(options);
if (storageFile != null)
vm.SaveAsPatch(storageFile.Path.LocalPath);
e.Handled = true;
}
}
}