feat: complete UM Trace iOS and field UI integration
This commit is contained in:
40
FieldLogger/Views/Controls/AppStatusBar.xaml.cs
Normal file
40
FieldLogger/Views/Controls/AppStatusBar.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using FieldLogger.ViewModels;
|
||||
|
||||
namespace FieldLogger.Views.Controls;
|
||||
|
||||
public partial class AppStatusBar : ContentView
|
||||
{
|
||||
private IDispatcherTimer? _staleTimer;
|
||||
|
||||
public AppStatusBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnHandlerChanged()
|
||||
{
|
||||
base.OnHandlerChanged();
|
||||
|
||||
if (Handler is null)
|
||||
{
|
||||
_staleTimer?.Stop();
|
||||
_staleTimer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_staleTimer is not null)
|
||||
return;
|
||||
|
||||
_staleTimer = Dispatcher.CreateTimer();
|
||||
_staleTimer.Interval = TimeSpan.FromSeconds(1);
|
||||
_staleTimer.Tick += (_, _) => (BindingContext as AppStatusViewModel)?.Refresh();
|
||||
_staleTimer.Start();
|
||||
(BindingContext as AppStatusViewModel)?.Refresh();
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
(BindingContext as AppStatusViewModel)?.Refresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user