Skip to content

Commit 0519445

Browse files
committed
Add a copy button on the error dialog
1 parent fadd08b commit 0519445

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/NexusMods.App.UI/Overlays/Generic/MessageBox/Ok/MessageBoxOkView.axaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@
4545
Text="Description" />
4646

4747
<!-- Supporting Markdown -->
48-
<reactiveUi:ViewModelViewHost x:Name="MarkdownRendererViewModelViewHost" MaxHeight="640"
49-
MaxWidth="600" />
48+
<StackPanel Orientation="Vertical" x:Name="DetailsSection">
49+
<controls:StandardButton x:Name="CopyDetailsButton"
50+
LeftIcon="{x:Static icons:IconValues.Copy}"
51+
ShowIcon="Left"
52+
ShowLabel="False"/>
53+
<reactiveUi:ViewModelViewHost x:Name="MarkdownRendererViewModelViewHost" MaxHeight="640"
54+
MaxWidth="600" />
55+
</StackPanel>
56+
5057
</StackPanel>
5158

5259
</DockPanel>

src/NexusMods.App.UI/Overlays/Generic/MessageBox/Ok/MessageBoxOkView.axaml.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reactive.Disposables;
22
using System.Reactive.Linq;
3+
using Avalonia.Controls;
34
using Avalonia.ReactiveUI;
45
using R3;
56
using ReactiveUI;
@@ -28,7 +29,7 @@ public MessageBoxOkView()
2829

2930
this.WhenAnyValue(view => view.ViewModel!.MarkdownRenderer)
3031
.Select(vm => vm != null)
31-
.BindTo(this, v => v.MarkdownRendererViewModelViewHost.IsVisible)
32+
.BindTo(this, v => v.DetailsSection.IsVisible)
3233
.DisposeWith(disposables);
3334

3435
// Bind commands
@@ -41,6 +42,11 @@ public MessageBoxOkView()
4142
{
4243
ViewModel!.Complete(Unit.Default);
4344
});
45+
46+
CopyDetailsButton.Command = ReactiveCommand.CreateFromTask(async () =>
47+
{
48+
await TopLevel.GetTopLevel(this)!.Clipboard!.SetTextAsync(ViewModel?.MarkdownRenderer?.Contents);
49+
});
4450
});
4551
}
4652
}

0 commit comments

Comments
 (0)