Files
GreadyPoang/GreadyPoang/Views/RoundStartingView.xaml

171 lines
12 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
x:Class="GreadyPoang.Views.RoundStartingView"
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
x:DataType="vm:RoundStartingViewModelCommands"
x:Name="GameRoundStartingPage"
Title="Starta ny Runda">
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
<Grid Style="{StaticResource Grid.Page}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<partial:HeaderView Grid.Row="0"
Grid.ColumnSpan="2"
ViewTitle="Starta en Spelrunda"
ViewDescription="Välj deltagare och initiera spel" />
<Border Grid.Row="1" Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" >
<HorizontalStackLayout>
<Border Stroke="Gray"
StrokeThickness="2"
BackgroundColor="LightGray"
Padding="10"
Margin="2"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="250">
<Picker ItemsSource="{Binding ParticipantList}"
ItemDisplayBinding="{Binding LastNameFirstName}"
SelectedItem="{Binding SelectedItem}"
Title="Välj deltagare"/>
</Border>
<Border Stroke="Gold" StrokeThickness="2" BackgroundColor="LightCyan" >
<CollectionView
ItemsSource="{Binding RoundElements}"
ItemsLayout="HorizontalList"
x:Name="ParticipantList"
SelectionMode="None">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:RoundBuilderElement">
<Border
Padding="2"
Margin="5"
WidthRequest="150"
HeightRequest="100"
Stroke="LightGray"
StrokeThickness="1"
x:Name="RoundElementBorder"
BackgroundColor="{Binding Status, Converter={StaticResource StatusToColorConverter}}"
StrokeShape="RoundRectangle 10">
<Border.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding BindingContext.ParticipantTappedCommand, Source={x:Reference Name=ParticipantList}}"
CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<Border.Triggers>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="New">
<Setter Property="BackgroundColor" Value="LightGreen" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="InProgress">
<Setter Property="BackgroundColor" Value="LightYellow" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Completed">
<Setter Property="BackgroundColor" Value="DarkGreen" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Cancelled">
<Setter Property="BackgroundColor" Value="LightCoral" />
</DataTrigger>
</Border.Triggers>
<Border Margin="1" Padding="2" StrokeThickness="3" >
<VerticalStackLayout>
<Label Text="{Binding ParticipantName}" FontAttributes="Bold" FontSize="14" TextColor="Black"/>
<Label Text="{Binding GameRoundStartDateString}" FontAttributes="Bold" FontSize="14" TextColor="Black"/>
<Label Text="{Binding StatusString}" FontSize="14" TextColor="White" />
</VerticalStackLayout>
</Border>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Border>
<Border
HorizontalOptions="End"
Padding="2"
Margin="5"
WidthRequest="150"
HeightRequest="100"
Stroke="LightGray"
StrokeThickness="1"
x:Name="RoundElementBorder"
BackgroundColor="BlanchedAlmond"
StrokeShape="RoundRectangle 10">
<VerticalStackLayout Spacing="5" Padding="4">
<Button Text="Spara omgång" WidthRequest="130"
Style="{StaticResource HoverButtonBlueStyle}"
Command="{Binding SaveCommand}" />
<Button Text="Rensa" WidthRequest="130"
Style="{StaticResource HoverButtonRedStyle}"
Command="{Binding RensaCommand}" />
</VerticalStackLayout>
</Border>
</HorizontalStackLayout>
</Border>
<Border Grid.Row="2" Stroke="Gold" BackgroundColor="Ivory" StrokeThickness="2" Padding="5">
<CollectionView ItemsSource="{Binding GameRoundList}" x:Name="OuterList">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:RoundBuilderGroup">
<VerticalStackLayout Padding="10">
<!-- Gruppens rubrik -->
<HorizontalStackLayout>
<Label Text="{Binding GameRoundId, StringFormat='Runda: {0}'}" FontAttributes="Bold" FontSize="18" />
<Label Text="{Binding GameRoundStartDate, StringFormat='Startdatum: {0}'}" FontAttributes="Bold" FontSize="18" />
<Label Text="{Binding Status, StringFormat='Status: {0}'}" FontAttributes="Bold" FontSize="18" />
</HorizontalStackLayout>
<!-- Horisontell lista med deltagare -->
<CollectionView ItemsSource="{Binding Elements}"
ItemsLayout="HorizontalList"
x:Name="InnerList"
Margin="0,10,0,10"
ItemSizingStrategy="MeasureAllItems">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:RoundBuilderElement">
<Border
Stroke="Gray"
Padding="5"
Margin="5,0"
BackgroundColor="{Binding Status, Converter={StaticResource StatusToColorConverter}}" >
<Border.Triggers>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="New">
<Setter Property="BackgroundColor" Value="LightGreen" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="InProgress">
<Setter Property="BackgroundColor" Value="LightYellow" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Completed">
<Setter Property="BackgroundColor" Value="DarkGreen" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Cancelled">
<Setter Property="BackgroundColor" Value="LightCoral" />
</DataTrigger>
</Border.Triggers>
<Border.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Path=BindingContext.ElementTappedCommand,Source={x:Reference OuterList}}"
CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<VerticalStackLayout>
<Label Text="{Binding ParticipantName}" FontAttributes="Bold" />
<Label Text="{Binding GameRegPoints, StringFormat='Poäng: {0}'}" />
<Label Text="{Binding GameRoundRegNr, StringFormat='RegNr: {0}'}" />
</VerticalStackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Border>
</Grid>
</Border>
</ContentPage>