-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.cake
159 lines (134 loc) · 5.86 KB
/
build.cake
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#addin nuget:?package=Cake.FileHelpers&version=6.0.0
var target = Argument("target", "BuiltInControlPage");
var group = Argument("group", "BuiltIn");
var name = Argument("name", "AwesomeControl");
var cardDetail = Argument("cardDetail", "CardDetail");
var originalDocumentUrl = Argument("originalDocumentUrl", "DocumentLink");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
const string CONTROL_FODLER_PATH_TEMPLATE="./src/Features/Gallery/Pages/{0}/{1}";
Task("BuiltInControlPage")
.Does(() =>
{
var controlFolderPath = string.Format(CONTROL_FODLER_PATH_TEMPLATE, group, name);
Information("Control folder path: " + controlFolderPath);
if (DirectoryExists(controlFolderPath)) {
Warning("Control folder path exists");
return;
}
CreateDirectory(controlFolderPath);
Information($"\n>> Generate >> {name}ControlInfo.cs");
FileWriteText($"{controlFolderPath}/{name}ControlInfo.cs", $@"namespace MAUIsland.Gallery.{group};
class {name}ControlInfo : IGalleryCardInfo
{{
public string ControlName => nameof({name});
public string ControlRoute => typeof({name}Page).FullName;
public ImageSource ControlIcon => new FontImageSource()
{{
FontFamily = FontNames.FluentSystemIconsRegular,
Glyph = FluentUIIcon.Ic_fluent_approvals_app_20_regular
}};
public string ControlDetail => ""{cardDetail}"";
public string GitHubUrl => $""https://github.com/Strypper/mauisland/tree/main/src/Features/Gallery/Pages/{group}/{{ControlName}}"";
public string DocumentUrl => $""{originalDocumentUrl}"";
public string GroupName => ControlGroupInfo.{group}Controls;
}}");
Information($"\n>> Generate >> {name}Page.xaml");
FileWriteText($"{controlFolderPath}/{name}Page.xaml", $@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<app:BasePage
xmlns=""http://schemas.microsoft.com/dotnet/2021/maui""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
xmlns:app=""clr-namespace:MAUIsland""
Padding=""10""
x:Class=""MAUIsland.{name}Page""
x:DataType=""app:{name}PageViewModel""
Title=""{name}"">
<app:BasePage.ToolbarItems>
<ToolbarItem
Command=""{{x:Binding OpenUrlCommand}}""
CommandParameter=""{{x:Binding ControlInformation.GitHubUrl}}""
IconImageSource=""github.png""
Text=""Source code"" />
<ToolbarItem
Command=""{{x:Binding OpenUrlCommand}}""
CommandParameter=""{{x:Binding ControlInformation.DocumentUrl}}""
IconImageSource=""microsoft.png""
Text=""Original Document"" />
</app:BasePage.ToolbarItems>
<app:BasePage.Resources>
<x:String x:Key=""PropertiesListHeader"">
{name} defines the following properties:
</x:String>
<x:String x:Key=""PropertiesListFooter"">
These properties are backed by BindableProperty objects, which means that they can be targets of data bindings, and styled.
</x:String>
<x:Array x:Key=""PropertiesItemsSource"" Type=""{{x:Type x:String}}"">
<x:String>
<![CDATA[
<strong style=""color:blue"">Color</strong>, of type <strong style=""color:blue"">Color </strong>, value that defines the color of the ActivityIndicator.
]]>
</x:String>
<x:String>
<![CDATA[
<strong style=""color:blue"">IsRunning</strong>, of type <strong style=""color:blue"">bool</strong>,value that indicates whether the ActivityIndicator should be visible and animating, or hidden. The default value of this property is false, which indicates that the ActivityIndicator isn't visible.
]]>
</x:String>
</x:Array>
</app:BasePage.Resources>
<ScrollView>
<VerticalStackLayout Spacing=""20"">
<Frame Style=""{{x:StaticResource DocumentContentFrameStyle}}"">
<Label Text=""{{x:Binding ControlInformation.ControlDetail}}"" />
</Frame>
<Frame Style=""{{x:StaticResource DocumentContentFrameStyle}}"">
<CollectionView
Footer=""{{x:StaticResource PropertiesListFooter}}""
Header=""{{x:StaticResource PropertiesListHeader}}""
ItemsSource=""{{x:StaticResource PropertiesItemsSource}}""
Style=""{{x:StaticResource PropertiesListStyle}}"" />
</Frame>
</VerticalStackLayout>
</ScrollView>
</app:BasePage>");
Information($"\n>> Generate >> {name}Page.xaml.cs");
FileWriteText($"{controlFolderPath}/{name}Page.xaml.cs", $@"namespace MAUIsland;
public partial class {name}Page : IGalleryPage
{{
#region [CTor]
public {name}Page({name}PageViewModel vm)
{{
InitializeComponent();
BindingContext = vm;
}}
#endregion
}}");
Information($"\n>> Generate >> {name}PageViewModel.cs");
FileWriteText($"{controlFolderPath}/{name}PageViewModel.cs", $@"namespace MAUIsland;
public partial class {name}PageViewModel : NavigationAwareBaseViewModel
{{
#region [CTor]
public {name}PageViewModel(
IAppNavigator appNavigator
) : base(appNavigator)
{{
}}
#endregion
#region [Properties]
[ObservableProperty]
IGalleryCardInfo controlInformation;
#endregion
#region [Overrides]
protected override void OnInit(IDictionary<string, object> query)
{{
base.OnInit(query);
ControlInformation = query.GetData<IGalleryCardInfo>();
}}
#endregion
}}");
});
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);