bitwarden-android/src/App/Controls/ExtendedContentPage.cs

58 lines
1.6 KiB
C#
Raw Normal View History

using Bit.App.Abstractions;
using Xamarin.Forms;
using XLabs.Ioc;
namespace Bit.App.Controls
{
public class ExtendedContentPage : ContentPage
{
private ISyncService _syncService;
2016-08-05 06:56:44 +03:00
private bool _syncIndicator;
public ExtendedContentPage(bool syncIndicator = true)
{
2016-08-05 06:56:44 +03:00
_syncIndicator = syncIndicator;
_syncService = Resolver.Resolve<ISyncService>();
BackgroundColor = Color.FromHex("efeff4");
2016-08-05 06:56:44 +03:00
if(_syncIndicator)
{
IsBusy = _syncService.SyncInProgress;
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
{
IsBusy = _syncService.SyncInProgress;
});
MessagingCenter.Subscribe<Application>(Application.Current, "SyncStarted", (sender) =>
{
IsBusy = _syncService.SyncInProgress;
});
}
}
2016-08-04 04:45:01 +03:00
protected override void OnAppearing()
{
2016-08-05 06:56:44 +03:00
if(_syncIndicator)
{
IsBusy = _syncService.SyncInProgress;
}
2016-08-04 04:45:01 +03:00
var googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
googleAnalyticsService.TrackPage(GetType().Name);
base.OnAppearing();
}
2016-08-05 06:14:47 +03:00
protected override void OnDisappearing()
{
2016-08-05 06:56:44 +03:00
if(_syncIndicator)
{
IsBusy = _syncService.SyncInProgress;
}
2016-08-05 06:14:47 +03:00
base.OnDisappearing();
}
}
}