Skip to content

Commit 839df5d

Browse files
chore: Extract to widget helper method
1 parent 126c02b commit 839df5d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,9 @@ public GamePage()
3232
.Layout(new UniformGridLayout()
3333
.Orientation(Orientation.Vertical)
3434
.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))))),
35+
.ItemTemplate<Cell>(cell => CellTemplate(cell))),
5036
new TextBlock()
51-
.Text(x => x.Binding(() => vm.Score))
37+
.Text(() => vm.Score)
5238
.HorizontalAlignment(HorizontalAlignment.Center)
5339
.Style(Theme.TextBlock.Styles.HeadlineSmall)
5440
.Margin(10)
@@ -66,4 +52,17 @@ public GamePage()
6652
.Value(x => x.Binding(() => vm.Speed).TwoWay())
6753
)));
6854
}
55+
56+
private Grid CellTemplate(Cell cell)
57+
=> new Grid()
58+
.Children(
59+
new Rectangle()
60+
.Width(10)
61+
.Height(10)
62+
.Fill(() => new SolidColorBrush(CellColor(cell))),
63+
new Ellipse()
64+
.Width(10)
65+
.Height(10)
66+
.Fill(() => new SolidColorBrush(PlayerColor(cell)))
67+
.Visibility(() => cell, cell => cell.HasBall ? Visibility.Visible : Visibility.Collapsed));
6968
}

0 commit comments

Comments
 (0)