2016-06-22 06:54:51 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Acr.UserDialogs;
|
|
|
|
|
using Bit.App.Abstractions;
|
|
|
|
|
using Bit.App.Resources;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
using XLabs.Ioc;
|
|
|
|
|
using Plugin.Settings.Abstractions;
|
2016-06-24 06:03:00 +03:00
|
|
|
|
using Bit.App.Controls;
|
2016-06-22 06:54:51 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Pages
|
|
|
|
|
{
|
2016-06-28 02:53:31 +03:00
|
|
|
|
public class HomePage : ExtendedContentPage
|
2016-06-22 06:54:51 +03:00
|
|
|
|
{
|
|
|
|
|
private readonly IAuthService _authService;
|
|
|
|
|
private readonly IUserDialogs _userDialogs;
|
|
|
|
|
private readonly ISettings _settings;
|
|
|
|
|
|
|
|
|
|
public HomePage()
|
|
|
|
|
{
|
|
|
|
|
_authService = Resolver.Resolve<IAuthService>();
|
|
|
|
|
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
|
|
|
|
_settings = Resolver.Resolve<ISettings>();
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
var logo = new Image
|
|
|
|
|
{
|
|
|
|
|
Source = "logo",
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|
|
|
|
HorizontalOptions = LayoutOptions.Center
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var message = new Label
|
|
|
|
|
{
|
2016-06-24 06:03:00 +03:00
|
|
|
|
Text = "Log in or create a new account to access your secure vault.",
|
2016-06-23 06:50:38 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.StartAndExpand,
|
2016-06-24 06:03:00 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.Center,
|
|
|
|
|
HorizontalTextAlignment = TextAlignment.Center,
|
|
|
|
|
LineBreakMode = LineBreakMode.WordWrap,
|
2016-06-28 03:56:59 +03:00
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
|
2016-06-22 06:54:51 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createAccountButton = new Button
|
|
|
|
|
{
|
|
|
|
|
Text = "Create Account",
|
2016-06-26 03:54:17 +03:00
|
|
|
|
Command = new Command(async () => await RegisterAsync()),
|
2016-06-22 06:54:51 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.End,
|
2016-06-23 06:50:38 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.Fill,
|
|
|
|
|
Style = (Style)Application.Current.Resources["btn-primary"],
|
2016-06-28 03:56:59 +03:00
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
|
2016-06-22 06:54:51 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var loginButton = new Button
|
|
|
|
|
{
|
|
|
|
|
Text = AppResources.LogIn,
|
|
|
|
|
Command = new Command(async () => await LoginAsync()),
|
|
|
|
|
VerticalOptions = LayoutOptions.End,
|
2016-06-23 06:50:38 +03:00
|
|
|
|
Style = (Style)Application.Current.Resources["btn-primaryAccent"],
|
|
|
|
|
HorizontalOptions = LayoutOptions.Fill,
|
2016-06-28 03:56:59 +03:00
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
|
2016-06-22 06:54:51 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var buttonStackLayout = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Padding = new Thickness(30, 40),
|
|
|
|
|
Spacing = 10,
|
|
|
|
|
Children = { logo, message, createAccountButton, loginButton }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Title = "bitwarden";
|
|
|
|
|
Content = buttonStackLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task LoginAsync()
|
|
|
|
|
{
|
2016-06-24 06:03:00 +03:00
|
|
|
|
await Navigation.PushModalAsync(new ExtendedNavigationPage(new LoginPage()));
|
2016-06-22 06:54:51 +03:00
|
|
|
|
}
|
2016-06-26 03:54:17 +03:00
|
|
|
|
|
|
|
|
|
public async Task RegisterAsync()
|
|
|
|
|
{
|
|
|
|
|
await Navigation.PushModalAsync(new ExtendedNavigationPage(new RegisterPage()));
|
|
|
|
|
}
|
2016-06-22 06:54:51 +03:00
|
|
|
|
}
|
|
|
|
|
}
|