-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathFlutterPage.cs
More file actions
56 lines (45 loc) · 1.59 KB
/
Copy pathFlutterPage.cs
File metadata and controls
56 lines (45 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Linq;
using CSharpMarkup.Wpf;
using static CSharpMarkup.Wpf.Helpers;
namespace WpfCsMarkupExamples;
partial class FlutterPage
{
public void Build() => Content =
VStack (
HStack (
Button ("\u1438") .Style (HeaderButton)
.Width (50)
.Bind (vm.BackCommand),
TextBlock ()
.VCenter ()
.Bind (vm.Title)
),
Button(
TextBlock() .Foreground (Black) .Bind (vm.ToggleMoreText)
) .Template (RoundButton)
.Foreground (Red) .Size (65)
.Bind (vm.ToggleMoreCommand),
vm.ShowMore ?
TextBlock ("Demonstrate Flutter-like UI building features:\nConditional UI and the Spread() operator") .Center()
: null,
TextBlock ("Subtitles:"),
Spread (Subtitles),
TextBlock ("Pairs:"),
Spread (Pairs())
) .Background (Black) .TextBlock_Foreground(SolidColorBrush(White));
ControlTemplate RoundButton = ControlTemplate(typeof(Button), () =>
Grid (
Ellipse()
.Fill (RadialGradientBrush (Silver, Gold))
.Stroke().BindTemplate (b?.Foreground),
ContentPresenter()
.Center()
));
IEnumerable<UI.UIElement> Subtitles => vm.Subtitles.Select(subtitle => TextBlock(subtitle) .Margin (0, 5) .UI);
IEnumerable <UI.UIElement> Pairs() {
for (int i = 1; i <= 5; i++) {
yield return TextBlock($"Field {i}:") .Margins (top: 20);
yield return TextBox(Text: $"Enter value for {i}");
}
}
}