Added: Login Pages (Select Host, Choose Login Method, Login with Password)

This commit is contained in:
TheJoKlLa 2020-11-23 19:20:34 +01:00
parent a7a4cb1146
commit 065ed2bfa0
13 changed files with 289 additions and 6 deletions

View File

@ -18,7 +18,7 @@ namespace Borepin
{ {
InitializeComponent(); InitializeComponent();
var result = await NavigationService.NavigateAsync("MainPage/NavigationPage/MachinesPage"); var result = await NavigationService.NavigateAsync("//NavigationPage/HostSelectPage");
if (!result.Success) if (!result.Success)
{ {
@ -33,9 +33,9 @@ namespace Borepin
containerRegistry.RegisterForNavigation<MachinesPage, MachinesPageModel>(); containerRegistry.RegisterForNavigation<MachinesPage, MachinesPageModel>();
containerRegistry.RegisterForNavigation<SettingsPage>(); containerRegistry.RegisterForNavigation<SettingsPage>();
containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>(); containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>();
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>();
// Use Admin as Default containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>();
containerRegistry.RegisterInstance(typeof(BFFHInterface), BFFHService.Auth(BFFHService.AdminID)); containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>();
} }
} }
} }

View File

@ -46,6 +46,15 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="Page\HostSelectPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\LoginChoosePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\LoginPasswordPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\MachinePage.xaml"> <EmbeddedResource Update="Page\MachinePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.HostSelectPage">
<NavigationPage.TitleView>
<Label Text="FabAccess" FontAttributes="Bold" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView>
<ContentPage.Content>
<StackLayout Padding="20">
<Label Text="Host" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Entry Text="{Binding Host}"/>
<Button Text="Detect local host" Command="{Binding DetectHostCommand}" Style="{StaticResource ButtonStyle_Primary}"/>
<Button Text="Select Host" Command="{Binding UseHostCommand}" Style="{StaticResource ButtonStyle_Primary}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HostSelectPage : ContentPage
{
public HostSelectPage()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.LoginChoosePage">
<NavigationPage.TitleView>
<Label Text="FabAccess" FontAttributes="Bold" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView>
<ContentPage.Content>
<StackLayout Padding="20">
<Label Text="Sign In:" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Button Text="Login with Password" Command="{Binding LoginPasswordCommand}" Style="{StaticResource ButtonStyle_Primary}"/>
<Label Text="or" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Button Text="Login with Card" Style="{StaticResource ButtonStyle_Primary}" IsEnabled="False"/>
<Label Text="Sign Up:" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Button Text="Register" Style="{StaticResource ButtonStyle_Primary}" IsEnabled="False"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LoginChoosePage : ContentPage
{
public LoginChoosePage()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.LoginPasswordPage">
<NavigationPage.TitleView>
<Label Text="FabAccess" FontAttributes="Bold" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView>
<ContentPage.Content>
<StackLayout Padding="20">
<Label Text="Username" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Entry Text="{Binding Username}"/>
<Label Text="Password" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
<Entry Text="{Binding Password}" IsPassword="True"/>
<Button Text="Login" Command="{Binding AuthenticateCommand}" Style="{StaticResource ButtonStyle_Primary}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LoginPasswordPage : ContentPage
{
public LoginPasswordPage()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,60 @@
using Borepin.Service;
using Prism.Mvvm;
using Prism.Navigation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class HostSelectPageModel : BindableBase
{
private INavigationService _NavigationService;
public HostSelectPageModel(INavigationService navigationService)
{
_NavigationService = navigationService;
UseHostCommand = new Command(UseHostCommandExecuted);
DetectHostCommand = new Command(DetectHostCommandExecuted);
}
private string _Host;
public string Host
{
get => _Host;
set => SetProperty(ref _Host, value);
}
private ICommand _UseHostCommand;
public ICommand UseHostCommand
{
get => _UseHostCommand;
set => SetProperty(ref _UseHostCommand, value);
}
private async void UseHostCommandExecuted()
{
INavigationResult result = await _NavigationService.NavigateAsync($"LoginChoosePage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
private ICommand _DetectHostCommand;
public ICommand DetectHostCommand
{
get => _DetectHostCommand;
set => SetProperty(ref _DetectHostCommand, value);
}
private void DetectHostCommandExecuted()
{
// Use Demo Host
Host = "demo.fab-access.org";
}
}
}

View File

@ -0,0 +1,38 @@
using Prism.Mvvm;
using Prism.Navigation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class LoginChoosePageModel : BindableBase
{
private INavigationService _NavigationService;
public LoginChoosePageModel(INavigationService navigationService)
{
_NavigationService = navigationService;
LoginPasswordCommand = new Command(LoginPasswordCommandExecuted);
}
private ICommand _LoginPasswordCommand;
public ICommand LoginPasswordCommand
{
get => _LoginPasswordCommand;
set => SetProperty(ref _LoginPasswordCommand, value);
}
private async void LoginPasswordCommandExecuted()
{
INavigationResult result = await _NavigationService.NavigateAsync($"LoginPasswordPage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
}
}

View File

@ -0,0 +1,56 @@
using Borepin.Service;
using Prism.Mvvm;
using Prism.Navigation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class LoginPasswordPageModel : BindableBase
{
private INavigationService _NavigationService;
public LoginPasswordPageModel(INavigationService navigationService)
{
_NavigationService = navigationService;
AuthenticateCommand = new Command(AuthenticateCommandExecuted);
}
private string _Username;
public string Username
{
get => _Username;
set => SetProperty(ref _Username, value);
}
private string _Password;
public string Password
{
get => _Password;
set => SetProperty(ref _Password, value);
}
private ICommand _AuthenticateCommand;
public ICommand AuthenticateCommand
{
get => _AuthenticateCommand;
set => SetProperty(ref _AuthenticateCommand, value);
}
private async void AuthenticateCommandExecuted()
{
BFFHActiveInterface.Interface = BFFHService.Auth(Username);
var result = await _NavigationService.NavigateAsync("//MainPage/NavigationPage/MachinesPage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
}
}

View File

@ -16,10 +16,10 @@ namespace Borepin.PageModel
private INavigationService _NavigationService; private INavigationService _NavigationService;
private BFFHInterface _BFFHInterface; private BFFHInterface _BFFHInterface;
public MachinePageModel(INavigationService navigationService, BFFHInterface bffhInterface) public MachinePageModel(INavigationService navigationService)
{ {
_NavigationService = navigationService; _NavigationService = navigationService;
_BFFHInterface = bffhInterface; _BFFHInterface = BFFHActiveInterface.Interface;
ReserveMachineCommand = new Command(ReserveMachineCommandExecuted); ReserveMachineCommand = new Command(ReserveMachineCommandExecuted);
UseMachineCommand = new Command(UseMachineCommandExecuted); UseMachineCommand = new Command(UseMachineCommandExecuted);

View File

@ -104,6 +104,11 @@ namespace Borepin.Service
} }
} }
public static class BFFHActiveInterface
{
public static BFFHInterface Interface;
}
public class BFFHInterface public class BFFHInterface
{ {
public readonly User ActiveUser; public readonly User ActiveUser;