feat(ui): show errors in a popup with the message
Failed saves, searches, imports and invalid input in the edit windows now open a modal popup instead of a bar at the top of the page or red text in the dialog. Hints and warnings stay in the bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b1d09c6abd
commit
459f8ea7f5
11 files changed
+44
-13
No files matched your search
@@ -48,6 +48,8 @@ The interface is in German. This section names the controls as they appear on sc
|
|||||||
|
|
||||||
News, ads and moderator talk are placeholders: the app shows them in the timeline and keeps silent for their duration, so the speaker can talk live.
|
News, ads and moderator talk are placeholders: the app shows them in the timeline and keeps silent for their duration, so the speaker can talk live.
|
||||||
|
|
||||||
|
Errors, such as invalid input or a failed save, search or import, open a popup with the message. Hints and warnings stay in the bar at the top of the page.
|
||||||
|
|
||||||
## How the schedule is built
|
## How the schedule is built
|
||||||
|
|
||||||
`ScheduleGenerator` plans in half-hour slots:
|
`ScheduleGenerator` plans in half-hour slots:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<data name="Audio_FileUnreadable" xml:space="preserve"><value>Audio file cannot be read: {0}</value></data>
|
<data name="Audio_FileUnreadable" xml:space="preserve"><value>Audio file cannot be read: {0}</value></data>
|
||||||
<data name="Audio_MicrophoneFailed" xml:space="preserve"><value>The microphone could not be turned on: {0}</value></data>
|
<data name="Audio_MicrophoneFailed" xml:space="preserve"><value>The microphone could not be turned on: {0}</value></data>
|
||||||
<data name="Audio_NoMicrophone" xml:space="preserve"><value>No microphone was found.</value></data>
|
<data name="Audio_NoMicrophone" xml:space="preserve"><value>No microphone was found.</value></data>
|
||||||
|
<data name="Error_InvalidInput" xml:space="preserve"><value>Invalid input</value></data>
|
||||||
<data name="Import_AllLicenses" xml:space="preserve"><value>All licenses</value></data>
|
<data name="Import_AllLicenses" xml:space="preserve"><value>All licenses</value></data>
|
||||||
<data name="Import_ChooseFiles" xml:space="preserve"><value>Choose files...</value></data>
|
<data name="Import_ChooseFiles" xml:space="preserve"><value>Choose files...</value></data>
|
||||||
<data name="Import_ColCreator" xml:space="preserve"><value>Creator</value></data>
|
<data name="Import_ColCreator" xml:space="preserve"><value>Creator</value></data>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<data name="Audio_FileUnreadable" xml:space="preserve"><value>Audiodatei kann nicht gelesen werden: {0}</value></data>
|
<data name="Audio_FileUnreadable" xml:space="preserve"><value>Audiodatei kann nicht gelesen werden: {0}</value></data>
|
||||||
<data name="Audio_MicrophoneFailed" xml:space="preserve"><value>Das Mikrofon konnte nicht eingeschaltet werden: {0}</value></data>
|
<data name="Audio_MicrophoneFailed" xml:space="preserve"><value>Das Mikrofon konnte nicht eingeschaltet werden: {0}</value></data>
|
||||||
<data name="Audio_NoMicrophone" xml:space="preserve"><value>Es wurde kein Mikrofon gefunden.</value></data>
|
<data name="Audio_NoMicrophone" xml:space="preserve"><value>Es wurde kein Mikrofon gefunden.</value></data>
|
||||||
|
<data name="Error_InvalidInput" xml:space="preserve"><value>UngĂĽltige Eingabe</value></data>
|
||||||
<data name="Import_AllLicenses" xml:space="preserve"><value>Alle Lizenzen</value></data>
|
<data name="Import_AllLicenses" xml:space="preserve"><value>Alle Lizenzen</value></data>
|
||||||
<data name="Import_ChooseFiles" xml:space="preserve"><value>Dateien auswählen...</value></data>
|
<data name="Import_ChooseFiles" xml:space="preserve"><value>Dateien auswählen...</value></data>
|
||||||
<data name="Import_ColCreator" xml:space="preserve"><value>Urheber</value></data>
|
<data name="Import_ColCreator" xml:space="preserve"><value>Urheber</value></data>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using Radiosender.Services.Localization;
|
||||||
|
using MessageBox = Wpf.Ui.Controls.MessageBox;
|
||||||
|
|
||||||
|
namespace Radiosender.Views;
|
||||||
|
|
||||||
|
// Errors as a modal popup, so they cannot be missed like an InfoBar at the top of a long page.
|
||||||
|
public static class ErrorPopup
|
||||||
|
{
|
||||||
|
public static void Show(DependencyObject source, string title, string message) =>
|
||||||
|
_ = new MessageBox
|
||||||
|
{
|
||||||
|
Title = title,
|
||||||
|
Content = message,
|
||||||
|
CloseButtonText = Loc.T("Main_Ok"),
|
||||||
|
Owner = Window.GetWindow(source) is { IsLoaded: true } owner ? owner : null,
|
||||||
|
WindowStartupLocation = WindowStartupLocation.CenterScreen,
|
||||||
|
}.ShowDialogAsync();
|
||||||
|
}
|
||||||
@@ -322,6 +322,12 @@ public partial class ImportPage : Page
|
|||||||
|
|
||||||
private void Show(InfoBarSeverity severity, string title, string message)
|
private void Show(InfoBarSeverity severity, string title, string message)
|
||||||
{
|
{
|
||||||
|
if (severity == InfoBarSeverity.Error)
|
||||||
|
{
|
||||||
|
Message.IsOpen = false;
|
||||||
|
ErrorPopup.Show(this, title, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Message.Severity = severity;
|
Message.Severity = severity;
|
||||||
Message.Title = title;
|
Message.Title = title;
|
||||||
Message.Message = message;
|
Message.Message = message;
|
||||||
|
|||||||
@@ -667,6 +667,12 @@ public partial class SchedulePage : Page
|
|||||||
|
|
||||||
private void ShowMessage(InfoBarSeverity severity, string title, string text)
|
private void ShowMessage(InfoBarSeverity severity, string title, string text)
|
||||||
{
|
{
|
||||||
|
if (severity == InfoBarSeverity.Error)
|
||||||
|
{
|
||||||
|
Message.IsOpen = false;
|
||||||
|
ErrorPopup.Show(this, title, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Message.Severity = severity;
|
Message.Severity = severity;
|
||||||
Message.Title = title;
|
Message.Title = title;
|
||||||
Message.Message = text;
|
Message.Message = text;
|
||||||
|
|||||||
@@ -132,6 +132,12 @@ public partial class SettingsPage : Page
|
|||||||
|
|
||||||
private void ShowMessage(InfoBarSeverity severity, string title, string text)
|
private void ShowMessage(InfoBarSeverity severity, string title, string text)
|
||||||
{
|
{
|
||||||
|
if (severity == InfoBarSeverity.Error)
|
||||||
|
{
|
||||||
|
Message.IsOpen = false;
|
||||||
|
ErrorPopup.Show(this, title, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Message.Severity = severity;
|
Message.Severity = severity;
|
||||||
Message.Title = title;
|
Message.Title = title;
|
||||||
Message.Message = text;
|
Message.Message = text;
|
||||||
|
|||||||
@@ -21,12 +21,6 @@
|
|||||||
<Label x:Name="DurationLabel" Content="{l:Tr ItemEdit_Length}" Target="{Binding ElementName=DurationBox}" />
|
<Label x:Name="DurationLabel" Content="{l:Tr ItemEdit_Length}" Target="{Binding ElementName=DurationBox}" />
|
||||||
<ui:TextBox x:Name="DurationBox" />
|
<ui:TextBox x:Name="DurationBox" />
|
||||||
|
|
||||||
<TextBlock x:Name="ErrorText"
|
|
||||||
Margin="0,12,0,0"
|
|
||||||
Foreground="{DynamicResource SystemFillColorCriticalBrush}"
|
|
||||||
Text="{l:Tr ItemEdit_LengthError}"
|
|
||||||
TextWrapping="Wrap"
|
|
||||||
Visibility="Collapsed" />
|
|
||||||
|
|
||||||
<StackPanel Margin="0,24,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel Margin="0,24,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
<ui:Button x:Name="SaveButton" Content="{l:Tr ItemEdit_Save}" Appearance="Primary" IsDefault="True" MinWidth="90" Click="OnSave" />
|
<ui:Button x:Name="SaveButton" Content="{l:Tr ItemEdit_Save}" Appearance="Primary" IsDefault="True" MinWidth="90" Click="OnSave" />
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public partial class ScheduleItemEditWindow : FluentWindow
|
|||||||
if (!TimeSpan.TryParseExact(DurationBox.Text.Trim(), DurationFormats, CultureInfo.InvariantCulture, out var duration)
|
if (!TimeSpan.TryParseExact(DurationBox.Text.Trim(), DurationFormats, CultureInfo.InvariantCulture, out var duration)
|
||||||
|| duration <= TimeSpan.Zero)
|
|| duration <= TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
ErrorText.Visibility = Visibility.Visible;
|
ErrorPopup.Show(this, Loc.T("Error_InvalidInput"), Loc.T("ItemEdit_LengthError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Duration = duration;
|
Duration = duration;
|
||||||
|
|||||||
@@ -27,11 +27,6 @@
|
|||||||
<Label Content="{l:Tr SongEdit_LabelAttribution}" Target="{Binding ElementName=AttributionBox}" />
|
<Label Content="{l:Tr SongEdit_LabelAttribution}" Target="{Binding ElementName=AttributionBox}" />
|
||||||
<ui:TextBox x:Name="AttributionBox" PlaceholderText="{l:Tr SongEdit_Optional}" />
|
<ui:TextBox x:Name="AttributionBox" PlaceholderText="{l:Tr SongEdit_Optional}" />
|
||||||
|
|
||||||
<TextBlock x:Name="ErrorText"
|
|
||||||
Margin="0,12,0,0"
|
|
||||||
Foreground="{DynamicResource SystemFillColorCriticalBrush}"
|
|
||||||
Text="{l:Tr SongEdit_Required}"
|
|
||||||
Visibility="Collapsed" />
|
|
||||||
|
|
||||||
<StackPanel Margin="0,24,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel Margin="0,24,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
<ui:Button Content="{l:Tr SongEdit_Save}" Appearance="Primary" IsDefault="True" MinWidth="90" Click="OnSave" />
|
<ui:Button Content="{l:Tr SongEdit_Save}" Appearance="Primary" IsDefault="True" MinWidth="90" Click="OnSave" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Radiosender.Services.Localization;
|
||||||
using Radiosender.Models;
|
using Radiosender.Models;
|
||||||
using Wpf.Ui.Controls;
|
using Wpf.Ui.Controls;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ public partial class SongEditWindow : FluentWindow
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(SongTitle) || string.IsNullOrWhiteSpace(Artist))
|
if (string.IsNullOrWhiteSpace(SongTitle) || string.IsNullOrWhiteSpace(Artist))
|
||||||
{
|
{
|
||||||
ErrorText.Visibility = Visibility.Visible;
|
ErrorPopup.Show(this, Loc.T("Error_InvalidInput"), Loc.T("SongEdit_Required"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user