Skip to content

Commit bcb1d1d

Browse files
authored
Merge pull request #684 from unoplatform/dev/doti/update-pw-sample
chore: Update PongWars GamePage
2 parents ad049be + 626f152 commit bcb1d1d

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

UI/PongWars/src/UnoPongWars/Presentation/GamePage.cs

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ namespace UnoPongWars.Presentation;
22

33
public sealed partial class GamePage : Page
44
{
5-
private readonly Color UnoBleu = Color.FromArgb(255, 27, 154, 249);
6-
private readonly Color UnoVert = Color.FromArgb(255, 107, 227, 173);
5+
private readonly Color Blue = Color.FromArgb(255, 27, 154, 249);
6+
private readonly Color Green = Color.FromArgb(255, 107, 227, 173);
77

88
public object ViewModel { get; set; }
99

10-
public Color PlayerColor(Cell cell) => cell.Player == 0 ? UnoBleu : UnoVert;
11-
public Color CellColor(Cell cell) => cell.Player == 0 ? UnoVert : UnoBleu;
10+
public Color PlayerColor(Cell cell) => cell.Player == 0 ? Blue : Green;
11+
public Color CellColor(Cell cell) => cell.Player == 0 ? Green : Blue;
1212

1313
public GamePage()
1414
{
@@ -18,52 +18,52 @@ public GamePage()
1818
.Background(Theme.Brushes.Background.Default)
1919
.Content(
2020
new Grid()
21-
.Margin(20)
22-
.RowDefinitions("*,auto,auto")
23-
.Children(
24-
new Viewbox()
25-
.HorizontalAlignment(HorizontalAlignment.Center)
26-
.Child(
27-
new ItemsRepeater()
28-
.ItemsSource(() => vm.Cells)
29-
.VerticalAlignment(VerticalAlignment.Center)
30-
.Width(160)
31-
.Height(160)
32-
.Layout(new UniformGridLayout()
33-
.Orientation(Orientation.Vertical)
34-
.MaximumRowsOrColumns(16))
35-
.ItemTemplate<Cell>(cell =>
36-
new Grid()
37-
.Children(
38-
new Rectangle()
39-
.Width(10)
40-
.Height(10)
41-
.Fill(x => x.Binding(() => cell)
42-
.Convert(cell => new SolidColorBrush(CellColor(cell)))),
43-
new Ellipse()
44-
.Width(10)
45-
.Height(10)
46-
.Fill(x => x.Binding(() => cell)
47-
.Convert(cell => new SolidColorBrush(PlayerColor(cell))))
48-
.Visibility(x => x.Binding(() => cell)
49-
.Convert(cell => cell.HasBall ? Visibility.Visible : Visibility.Collapsed))))),
50-
new TextBlock()
51-
.Text(x => x.Binding(() => vm.Score))
21+
.Margin(20)
22+
.RowDefinitions("*,Auto,Auto")
23+
.Children(
24+
new Viewbox()
5225
.HorizontalAlignment(HorizontalAlignment.Center)
53-
.Style(Theme.TextBlock.Styles.HeadlineSmall)
54-
.Margin(10)
55-
.Grid(row: 1),
56-
new Slider()
57-
.MaxWidth(400)
58-
.Margin(16)
59-
.Maximum(1000)
26+
.Child(
27+
new ItemsRepeater()
28+
.ItemsSource(() => vm.Cells)
29+
.VerticalAlignment(VerticalAlignment.Center)
30+
.Width(160)
31+
.Height(160)
32+
.Layout(
33+
new UniformGridLayout()
34+
.Orientation(Orientation.Vertical)
35+
.MaximumRowsOrColumns(16))
36+
.ItemTemplate<Cell>(cell => CellTemplate(cell))),
37+
new TextBlock()
38+
.Text(() => vm.Score)
39+
.HorizontalAlignment(HorizontalAlignment.Center)
40+
.Style(Theme.TextBlock.Styles.HeadlineSmall)
41+
.Margin(10)
42+
.Grid(row: 1),
43+
new Slider()
44+
.MaxWidth(400)
45+
.Margin(16)
46+
.Maximum(1000)
6047
#if __ANDROID__
61-
.Minimum(100)
48+
.Minimum(100)
6249
#else
63-
.Minimum(10)
50+
.Minimum(10)
6451
#endif
65-
.Grid(row: 2)
66-
.Value(x => x.Binding(() => vm.Speed).TwoWay())
52+
.Grid(row: 2)
53+
.Value(x => x.Binding(() => vm.Speed).TwoWay())
6754
)));
6855
}
56+
57+
private Grid CellTemplate(Cell cell)
58+
=> new Grid()
59+
.Children(
60+
new Rectangle()
61+
.Width(10)
62+
.Height(10)
63+
.Fill(() => cell, cell => new SolidColorBrush(CellColor(cell))),
64+
new Ellipse()
65+
.Width(10)
66+
.Height(10)
67+
.Fill(() => cell, cell => new SolidColorBrush(PlayerColor(cell)))
68+
.Visibility(() => cell, cell => cell.HasBall ? Visibility.Visible : Visibility.Collapsed));
6969
}

0 commit comments

Comments
 (0)