Skip to content

Commit 33b6da7

Browse files
committed
Windows application blocks background UI interactions while toast popup is displayed.
#478
1 parent 90d7780 commit 33b6da7

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

Trimble.Modus.Components/Controls/Toast/TMToast.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class TMToast
1313
private Action? action = null;
1414
public ToastTheme theme = ToastTheme.DefaultToast;
1515
public bool isDismissable = true;
16+
public int dismissDelay = 5000;
1617
#endregion
1718
public TMToast(string message, string actionButtonText = null, Action? action = null)
1819
{
@@ -31,7 +32,7 @@ public void Show()
3132
{
3233
throw new ArgumentNullException("Message is required");
3334
}
34-
PopupService.Instance.PresentAsync(new TMToastContents(message, actionButtonText, theme, action, isDismissable), false);
35+
PopupService.Instance.PresentAsync(new TMToastContents(message, actionButtonText, theme, action, isDismissable, dismissDelay), false);
3536
}
3637
#endregion
3738
}

Trimble.Modus.Components/Controls/Toast/TMToastContents.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class TMToastContents : PopupPage
1111
{
1212
#region Private Properties
1313

14-
private const int DELAYTIME = 5000;
14+
private readonly int _delayTime;
1515

1616
#endregion
1717

@@ -40,10 +40,11 @@ public partial class TMToastContents : PopupPage
4040
propertyChanged: OnRightIconTintColorChanged);
4141

4242

43-
internal TMToastContents(string message, string actionButtonText, ToastTheme theme, Action action, bool isDismissable)
43+
internal TMToastContents(string message, string actionButtonText, ToastTheme theme, Action action, bool isDismissable, int dismissDelay = 5000)
4444
{
45+
_delayTime = dismissDelay;
4546
InitializeComponent();
46-
SetTheme(theme.ToString());
47+
SetTheme(theme.ToString());
4748
SetDynamicResource(StyleProperty, theme.ToString());
4849
PopupData(message, actionButtonText, action, isDismissable);
4950
BindingContext = this;
@@ -165,8 +166,8 @@ public void CloseAfterDelay()
165166
{
166167
Task.Run(async () =>
167168
{
168-
await Task.Delay(DELAYTIME);
169-
if (PopupService.Instance.PopupStack.Contains(this))
169+
await Task.Delay(_delayTime);
170+
if (PopupService.Instance.PopupStack.Contains(this))
170171
await PopupService.Instance.RemovePageAsync(this, true);
171172
});
172173
}

Trimble.Modus.Components/Platforms/Windows/Popup/Handler/PopupPageRenderer.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ private void OnUnloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
6464

6565
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
6666
{
67-
DeviceDisplay.Current.MainDisplayInfoChanged += OnDisplayInfoChanged;
68-
PointerPressed += OnBackgroundClick;
67+
DeviceDisplay.Current.MainDisplayInfoChanged += OnDisplayInfoChanged;
68+
if (CurrentElement != null && CurrentElement.BackgroundInputTransparent)
69+
{
70+
this.Background = null;
71+
}
72+
else
73+
{
74+
PointerPressed += OnBackgroundClick;
75+
}
6976
}
7077

7178
private void OnDisplayInfoChanged(object? sender, DisplayInfoChangedEventArgs e)

Trimble.Modus.Components/Trimble.Modus.Components.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2828
<PackageId>Trimble.Modus.Components</PackageId>
2929
<Title>Trimble Modus</Title>
30-
<Version>1.4.0.5</Version>
30+
<Version>1.4.0.6</Version>
3131
<Authors>Trimble Inc</Authors>
3232
<Company>Trimble Inc</Company>
3333
<Product>Trimble.Modus.Components</Product>

0 commit comments

Comments
 (0)