2016-07-12 06:55:16 +03:00
|
|
|
|
using Bit.App.Abstractions;
|
2016-06-28 02:53:31 +03:00
|
|
|
|
using Xamarin.Forms;
|
2016-07-12 06:55:16 +03:00
|
|
|
|
using XLabs.Ioc;
|
2016-06-28 02:53:31 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class ExtendedContentPage : ContentPage
|
|
|
|
|
{
|
2016-07-12 06:55:16 +03:00
|
|
|
|
private ISyncService _syncService;
|
2016-08-05 06:56:44 +03:00
|
|
|
|
private bool _syncIndicator;
|
2016-07-12 06:55:16 +03:00
|
|
|
|
|
2016-08-06 18:43:22 +03:00
|
|
|
|
public ExtendedContentPage(bool syncIndicator = false)
|
2016-06-28 02:53:31 +03:00
|
|
|
|
{
|
2016-08-05 06:56:44 +03:00
|
|
|
|
_syncIndicator = syncIndicator;
|
2016-07-12 06:55:16 +03:00
|
|
|
|
_syncService = Resolver.Resolve<ISyncService>();
|
|
|
|
|
|
2016-06-28 02:53:31 +03:00
|
|
|
|
BackgroundColor = Color.FromHex("efeff4");
|
2016-07-12 06:55:16 +03:00
|
|
|
|
|
2016-08-05 06:56:44 +03:00
|
|
|
|
if(_syncIndicator)
|
2016-07-12 06:55:16 +03:00
|
|
|
|
{
|
2016-07-13 01:59:09 +03:00
|
|
|
|
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
|
|
|
|
{
|
|
|
|
|
IsBusy = _syncService.SyncInProgress;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MessagingCenter.Subscribe<Application>(Application.Current, "SyncStarted", (sender) =>
|
|
|
|
|
{
|
|
|
|
|
IsBusy = _syncService.SyncInProgress;
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-06-28 02:53:31 +03:00
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2016-08-06 18:43:22 +03:00
|
|
|
|
IsBusy = false;
|
2016-08-05 06:56:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-05 06:14:47 +03:00
|
|
|
|
base.OnDisappearing();
|
|
|
|
|
}
|
2016-06-28 02:53:31 +03:00
|
|
|
|
}
|
|
|
|
|
}
|