Add manual X close to toast notification
Some checks failed
CI / build-and-test (push) Failing after 26s
Some checks failed
CI / build-and-test (push) Failing after 26s
Toast was auto-dismiss-only (3s timer). Operators running a live show want to clear visual clutter without waiting — added a small X button to the right of the message that calls ToastViewModel.DismissCommand (stops timer + hides immediately). Implementation: ToastViewModel gained a DismissCommand RelayCommand and a Hide() helper. MainWindow toast overlay gained a 20x20 button bound to the command, custom inline template (rounded transparent bg, hover lifts to Wd.Button.HoverBg).
This commit is contained in:
parent
2c607a70ff
commit
8e66491e09
2 changed files with 49 additions and 3 deletions
|
|
@ -997,7 +997,9 @@
|
|||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Toast overlay: bottom-center, auto-dismissing transient notification. -->
|
||||
<!-- Toast overlay: bottom-center, auto-dismissing transient notification.
|
||||
Manual X dismiss for operators running a live show who want
|
||||
to clear visual clutter without waiting the 3s auto-hide. -->
|
||||
<Border Grid.Row="2"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Center"
|
||||
|
|
@ -1006,7 +1008,7 @@
|
|||
BorderBrush="{DynamicResource Wd.BorderStrong}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="999"
|
||||
Padding="14,8"
|
||||
Padding="14,6,8,6"
|
||||
Visibility="{Binding Toast.IsVisible, Converter={StaticResource BoolToVis}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse Width="8" Height="8"
|
||||
|
|
@ -1015,8 +1017,36 @@
|
|||
<TextBlock Text="{Binding Toast.Message}"
|
||||
Style="{StaticResource Wd.Text.Body}"
|
||||
FontSize="12"
|
||||
Margin="10,0,0,0"
|
||||
Margin="10,0,12,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<Button Command="{Binding Toast.DismissCommand}"
|
||||
Width="20" Height="20"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Cursor="Hand"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
ToolTip="Dismiss this toast">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="Bd"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="10">
|
||||
<Path Data="M 0,0 L 8,8 M 8,0 L 0,8"
|
||||
Stroke="{DynamicResource Wd.Text.Tertiary}"
|
||||
StrokeThickness="1.2"
|
||||
Width="8" Height="8"
|
||||
Stretch="None"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Wd.Button.HoverBg}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace TeamsISO.App.ViewModels;
|
||||
|
|
@ -27,6 +28,21 @@ public sealed class ToastViewModel : ObservableObject
|
|||
_hideTimer.Stop();
|
||||
IsVisible = false;
|
||||
};
|
||||
DismissCommand = new RelayCommand(Hide);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manual dismiss. Stops the auto-hide timer and hides the toast
|
||||
/// immediately. Bound to the X close button on the toast overlay so an
|
||||
/// operator running a live show can clear visual clutter without waiting
|
||||
/// 3 seconds.
|
||||
/// </summary>
|
||||
public ICommand DismissCommand { get; }
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
_hideTimer.Stop();
|
||||
IsVisible = false;
|
||||
}
|
||||
|
||||
public string Message
|
||||
|
|
|
|||
Loading…
Reference in a new issue