|
2 | 2 | <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
3 | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 | xmlns:local="clr-namespace:Codebreaker.MAUI.Views.Pages" |
| 5 | + xmlns:vm="clr-namespace:Codebreaker.ViewModels;assembly=Codebreaker.ViewModels" |
5 | 6 | xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" |
6 | 7 | xmlns:components="clr-namespace:Codebreaker.MAUI.Views.Components" |
7 | 8 | xmlns:conv="clr-namespace:Codebreaker.MAUI.Converters" |
8 | 9 | Title="Codebreaker" |
9 | 10 | x:Class="Codebreaker.MAUI.Views.Pages.GamePage" |
| 11 | + x:DataType="{x:Type vm:GamePageViewModel}" |
10 | 12 | x:Name="this"> |
11 | 13 |
|
12 | 14 | <ContentPage.Resources> |
13 | 15 | <conv:GameStatusToIsVisibleConverter x:Key="GameStatusVisibleConverter" /> |
14 | 16 | </ContentPage.Resources> |
15 | 17 | <Grid RowDefinitions="auto, *, auto"> |
16 | 18 | <components:GameResultDisplay |
17 | | - Grid.Row="0" |
18 | | - GameMode="{Binding ViewModel.GameStatus, Mode=OneWay, Source={x:Reference this}}" |
19 | | - WonCommand="{Binding ViewModel.StartGameCommand, Mode=OneTime, Source={x:Reference this}}" |
20 | | - LostCommand="{Binding ViewModel.StartGameCommand, Mode=OneTime, Source={x:Reference this}}" /> |
| 19 | + Grid.Row="0" /> |
21 | 20 | <ScrollView Grid.Row="1"> |
22 | 21 | <VerticalStackLayout |
23 | 22 | Spacing="25" |
24 | 23 | Padding="30,0" |
25 | 24 | VerticalOptions="FillAndExpand"> |
26 | 25 | <ActivityIndicator |
27 | | - IsRunning="{Binding ViewModel.InProgress, Mode=OneWay}" |
| 26 | + IsRunning="{Binding InProgress, Mode=OneWay}" |
28 | 27 | HorizontalOptions="Center" |
29 | 28 | VerticalOptions="Center" /> |
30 | 29 |
|
|
33 | 32 | ColumnDefinitions="*, Auto" |
34 | 33 | ColumnSpacing="8" |
35 | 34 | RowSpacing="8" |
36 | | - IsVisible="{Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start}"> |
| 35 | + IsVisible="{Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start}"> |
37 | 36 | <Label |
38 | 37 | Grid.Column="0" |
39 | 38 | Grid.Row="0" |
|
43 | 42 | <Entry |
44 | 43 | Grid.Column="0" |
45 | 44 | Grid.Row="1" |
46 | | - IsEnabled="{Binding ViewModel.IsNameEnterable, Mode=OneWay}" |
47 | | - Text="{Binding ViewModel.Name, Mode=TwoWay }" |
| 45 | + IsEnabled="{Binding IsNameEnterable, Mode=OneWay}" |
| 46 | + Text="{Binding Name, Mode=TwoWay }" |
48 | 47 | Placeholder="Enter your name"/> |
49 | 48 | <Button |
50 | 49 | Grid.Column="1" |
|
54 | 53 | VerticalOptions="EndAndExpand" |
55 | 54 | Text="Start the game" |
56 | 55 | IsVisible="{OnIdiom |
57 | | - Default={Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start}, |
| 56 | + Default={Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start}, |
58 | 57 | Phone=False, |
59 | 58 | Watch=False |
60 | 59 | }" |
61 | | - Command="{Binding ViewModel.StartGameCommand, Mode=OneTime}" /> |
| 60 | + Command="{Binding StartGameCommand, Mode=OneTime}" /> |
62 | 61 | </Grid> |
63 | 62 |
|
64 | | - <components:PegSelectionView IsVisible="{Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Cancelable}" /> |
| 63 | + <components:PegSelectionView IsVisible="{Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Cancelable}" /> |
65 | 64 |
|
66 | 65 | <ListView |
67 | | - IsVisible="{Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Running}" |
68 | | - ItemsSource="{Binding ViewModel.GameMoves, Mode=OneWay}" |
| 66 | + IsVisible="{Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Running}" |
| 67 | + ItemsSource="{Binding GameMoves, Mode=OneWay}" |
69 | 68 | ItemTemplate="{StaticResource PegsTemplate}"/> |
70 | 69 |
|
71 | 70 | </VerticalStackLayout> |
|
79 | 78 | Text="Start the game" |
80 | 79 | IsVisible="{OnIdiom |
81 | 80 | Default=False, |
82 | | - Phone={Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start} |
| 81 | + Phone={Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Start} |
83 | 82 | }" |
84 | | - Command="{Binding ViewModel.StartGameCommand, Mode=OneTime}" /> |
| 83 | + Command="{Binding StartGameCommand, Mode=OneTime}" /> |
85 | 84 | <Button |
86 | 85 | Margin="20" |
87 | 86 | HorizontalOptions="Fill" |
88 | 87 | VerticalOptions="End" |
89 | 88 | Text="Move" |
90 | | - IsVisible="{Binding ViewModel.GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Cancelable}" |
91 | | - Command="{Binding ViewModel.SetMoveCommand, Mode=OneTime}" /> |
| 89 | + IsVisible="{Binding GameStatus, Mode=OneWay, Converter={StaticResource GameStatusVisibleConverter}, ConverterParameter=Cancelable}" |
| 90 | + Command="{Binding SetMoveCommand, Mode=OneTime}" /> |
92 | 91 | </VerticalStackLayout> |
93 | 92 | </Grid> |
94 | 93 | </ContentPage> |
0 commit comments