Refactor LoginPage to MVVM
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
Title="{Binding Title}">
|
||||
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<models:LoginViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
<!-- BindingContext wird via DI im Code-Behind gesetzt -->
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<conv:StringVisibilityConverter x:Key="StringVisibilityConverter" />
|
||||
<conv:InverseBoolConverter x:Key="InverseBoolConverter" />
|
||||
<conv:EventArgsPassThroughConverter x:Key="EventArgsPassThroughConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</HorizontalStackLayout>
|
||||
<Grid Grid.Column="1" ColumnDefinitions="*,50" ColumnSpacing="10">
|
||||
<Label Text="Login QR/manuell" VerticalOptions="Center" Grid.Column="0" />
|
||||
<Switch x:Name="LoginSwitch" IsToggled="False" Toggled="Switch_Toggled" VerticalOptions="Center"
|
||||
<Switch x:Name="LoginSwitch" IsToggled="{Binding IsManualMode}" VerticalOptions="Center"
|
||||
Grid.Column="1" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
@@ -47,25 +47,30 @@
|
||||
<Label x:Name="ServerLabel" Text="{Binding Server}"
|
||||
IsVisible="{Binding Server, Converter={StaticResource StringVisibilityConverter}}" />
|
||||
|
||||
<VerticalStackLayout x:Name="LoginQR" Margin="0,20,0,0">
|
||||
<VerticalStackLayout x:Name="LoginQR" Margin="0,20,0,0" IsVisible="{Binding IsManualMode, Converter={StaticResource InverseBoolConverter}}">
|
||||
<Label Text="Login mit QR-Code" FontSize="32" HorizontalOptions="Start" />
|
||||
<Label x:Name="Message" Text="{Binding Message}" Margin="0,15" />
|
||||
|
||||
<Border HeightRequest="300" Padding="0">
|
||||
<zxing:CameraBarcodeReaderView
|
||||
x:Name="barcodeScannerView"
|
||||
BarcodesDetected="BarcodesDetected"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand" />
|
||||
VerticalOptions="FillAndExpand"
|
||||
IsDetecting="{Binding IsDetecting}">
|
||||
<zxing:CameraBarcodeReaderView.Behaviors>
|
||||
<toolkit:EventToCommandBehavior EventName="BarcodesDetected"
|
||||
Command="{Binding QrDetectedCommand}"
|
||||
EventArgsConverter="{StaticResource EventArgsPassThroughConverter}" />
|
||||
</zxing:CameraBarcodeReaderView.Behaviors>
|
||||
</zxing:CameraBarcodeReaderView>
|
||||
</Border>
|
||||
</VerticalStackLayout>
|
||||
|
||||
<VerticalStackLayout x:Name="LoginManual" Spacing="25">
|
||||
<VerticalStackLayout x:Name="LoginManual" Spacing="25" IsVisible="{Binding IsManualMode}">
|
||||
<Label Text="Manueller Login" FontSize="32" HorizontalOptions="Start" Margin="0, 20, 0, 0" />
|
||||
<Entry x:Name="UsernameEntry" Placeholder="Benutzername (Mailadresse)" Keyboard="Email" />
|
||||
<Entry x:Name="PasswordEntry" Placeholder="Passwort" IsPassword="True" />
|
||||
<Entry x:Name="ServerEntry" Placeholder="Server (gleich wie im Browser)" Keyboard="Url" />
|
||||
<Button Text="Login" Clicked="OnLoginButtonClicked"
|
||||
<Entry x:Name="UsernameEntry" Text="{Binding Username}" Placeholder="Benutzername (Mailadresse)" Keyboard="Email" />
|
||||
<Entry x:Name="PasswordEntry" Text="{Binding Password}" Placeholder="Passwort" IsPassword="True" />
|
||||
<Entry x:Name="ServerEntry" Text="{Binding Server}" Placeholder="Server (gleich wie im Browser)" Keyboard="Url" />
|
||||
<Button Text="Login" Command="{Binding LoginCommand}"
|
||||
TextColor="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource White}}" />
|
||||
</VerticalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
|
||||
Reference in New Issue
Block a user