bitwarden-android/src/App/Pages/Settings/SettingsAboutPage.cs

108 lines
3 KiB
C#
Raw Normal View History

using System;
using Bit.App.Controls;
using Xamarin.Forms;
using Bit.App.Abstractions;
using XLabs.Ioc;
using Bit.App.Resources;
2017-02-16 05:56:02 +03:00
using FFImageLoading.Forms;
namespace Bit.App.Pages
{
public class SettingsAboutPage : ExtendedContentPage
{
private readonly IAppInfoService _appInfoService;
public SettingsAboutPage()
{
_appInfoService = Resolver.Resolve<IAppInfoService>();
Init();
}
2017-02-18 05:18:59 +03:00
public ExtendedTextCell CreditsCell { get; set; }
public void Init()
{
2017-02-16 05:56:02 +03:00
var logo = new CachedImage
{
Source = "logo",
2017-02-16 05:56:02 +03:00
HorizontalOptions = LayoutOptions.Center,
WidthRequest = 282,
HeightRequest = 44
};
var versionLabel = new Label
{
2016-08-23 01:59:15 +03:00
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Text = $@"{AppResources.Version} {_appInfoService.Version} ({_appInfoService.Build})
© 8bit Solutions LLC 2015-{DateTime.Now.Year}",
HorizontalTextAlignment = TextAlignment.Center
};
var logoVersionStackLayout = new StackLayout
{
Children = { logo, versionLabel },
Spacing = 20,
Padding = new Thickness(0, 40, 0, 0)
};
2017-02-18 05:18:59 +03:00
CreditsCell = new ExtendedTextCell
{
Text = AppResources.Credits,
ShowDisclousure = true
};
var table = new ExtendedTableView
{
VerticalOptions = LayoutOptions.Start,
EnableScrolling = false,
2016-07-28 07:39:35 +03:00
Intent = TableIntent.Settings,
HasUnevenRows = true,
Root = new TableRoot
{
new TableSection(" ")
{
2017-02-18 05:18:59 +03:00
CreditsCell
}
}
};
if(Device.OS == TargetPlatform.iOS)
{
table.RowHeight = -1;
table.EstimatedRowHeight = 44;
}
var stackLayout = new StackLayout
{
Children = { logoVersionStackLayout, table },
Spacing = 0
};
if(Device.OS == TargetPlatform.iOS)
{
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
}
Title = AppResources.About;
Content = new ScrollView { Content = stackLayout };
}
private void RateCell_Tapped(object sender, EventArgs e)
{
Navigation.PushAsync(new SettingsCreditsPage());
}
2017-02-18 05:18:59 +03:00
protected override void OnAppearing()
{
base.OnAppearing();
CreditsCell.Tapped += RateCell_Tapped;
}
protected override void OnDisappearing()
{
base.OnDisappearing();
CreditsCell.Tapped -= RateCell_Tapped;
}
}
}