Skip to content

Commit

Permalink
- update readme
Browse files Browse the repository at this point in the history
- add cake script
  • Loading branch information
tuyen-vuduc committed Jan 14, 2023
1 parent 1bd614d commit 84def43
Show file tree
Hide file tree
Showing 11 changed files with 571 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,62 @@ Made with [contrib.rocks](https://contrib.rocks).
# Development Guide
- Repo template: [Chick and Paddy MAUI template](https://github.com/tuyen-vuduc/chick-and-paddy-dotnet-maui)
- Coding guidelines: [Naxam coding guidelines and pactices](https://github.com/NAXAM/guidelines-n-practices)

# How to create demo page for a control

## The steps
- Create a folder under `Gallery/Pages/{control-group}`
- folder name must be the control name
- control group can be BuiltIn, Syncfusion, etc.
- Create
- a ControlInfo class
- a XAML page
- a VM class

e.g A demo page for Button built-in control will have below structure
```
|
|--Features
|--Gallery
|--Pages
|--Button
|--ButtonControlInfo
|--ButtonPage.xaml
|--ButtonPage.xaml.cs
|--ButtonPageViewModel.cs
```

class diagram
```mermaid
classDiagram
ButtonPage ..|> IControlPage
ButtonPage --|> BasePage
ButtonControlInfo ..|> IControlInfo
ButtonPageViewModel --|> NavigationAwareBaseViewModel
ButtonPage o-- ButtonPageViewModel: BindingContext
ButtonPage .. ButtonControlInfo: route name
class IControlInfo
<<interface>> IControlInfo
class IControlPage
<<interface>> IControlPage
class NavigationAwareBaseViewModel
<<abstract>> NavigationAwareBaseViewModel
class BasePage
<<abstract>> BasePage
class ButtonPage
class ButtonControlInfo
class ButtonPageViewModel
```

## Use script

```
dotnet cake --group DESIRE_GROUP --name CONTROL_NAME
```

### Available groups
- `BuiltIn` - [MAUI built-in controls](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/?view=net-maui-7.0)
- `Syncfusion` - [Syncfusion controls for MAUI](https://www.syncfusion.com/maui-controls)

NOTE: We can add any new group we want.
87 changes: 87 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#addin nuget:?package=Cake.FileHelpers&version=6.0.0

var target = Argument("target", "Default");
var group = Argument("group", "BuiltIn");
var name = Argument("name", "AwesomeControl");
var configuration = Argument("configuration", "Release");

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

const string CONTROL_FODLER_PATH_TEMPLATE="./src/Features/Gallery/Pages/{0}/{1}";

Task("Default")
.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 : IControlInfo
{{
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 => throw new NotImplementedException();
public string GitHubUrl => $""https://github.com/Strypper/MAUIsland/tree/main/MAUIsland/Features/Gallery/MAUI/{{ControlName}}"";
public string DocumentUrl => $""https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/{{ControlName}}/?view=net-maui-7.0"";
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""
x:Class=""MAUIsland.{name}Page""
x:DataType=""app:{name}PageViewModel""
Title=""{name}"">
<VerticalStackLayout>
<Label
Text=""Welcome to {name} Page!""
VerticalOptions=""Center""
HorizontalOptions=""Center"" />
</VerticalStackLayout>
</app:BasePage>");

Information($"\n>> Generate >> {name}Page.xaml.cs");
FileWriteText($"{controlFolderPath}/{name}Page.xaml.cs", $@"namespace MAUIsland;
public partial class {name}Page : IControlPage
{{
public {name}Page()
{{
InitializeComponent();
}}
}}");

Information($"\n>> Generate >> {name}PageViewModel.cs");
FileWriteText($"{controlFolderPath}/{name}PageViewModel.cs", $@"namespace MAUIsland;
public partial class {name}PageViewModel : NavigationAwareBaseViewModel
{{
public {name}PageViewModel(
IAppNavigator appNavigator
) : base(appNavigator)
{{
}}
}}");
});

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////

RunTarget(target);
3 changes: 3 additions & 0 deletions src/MAUIsland.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
<MauiXaml Condition=" '$(EnableDefaultXamlItems)' == 'true' " Update="Features\Gallery\Pages\Syncfusion\SfListView\SfListViewPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Features\Gallery\Pages\BuiltIn\Xxxx\XxxxPage.xaml">
<SubType></SubType>
</MauiXaml>
</ItemGroup>

<ItemGroup>
Expand Down
Binary file not shown.
22 changes: 22 additions & 0 deletions tools/Addins/Cake.FileHelpers.6.0.0/Cake.FileHelpers.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Cake.FileHelpers</id>
<version>6.0.0</version>
<title>Cake.FileHelpers</title>
<authors>Redth</authors>
<license type="expression">Apache-2.0</license>
<licenseUrl>https://licenses.nuget.org/Apache-2.0</licenseUrl>
<icon>icon.png</icon>
<projectUrl>https://github.com/cake-contrib/Cake.FileHelpers</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/addin/cake-contrib-addin-medium.png</iconUrl>
<description>Cake Build addon to provide Aliases for common File operations (Reading, Writing, Replacing Text).</description>
<copyright>Copyright 2017-2023 - Cake Contributions</copyright>
<tags>cake script build cake-addin cake-build addin</tags>
<repository type="git" url="https://github.com/cake-contrib/Cake.FileHelpers.git" commit="7962e55b54989881495229367958b3367408219c" />
<dependencies>
<group targetFramework="net6.0" />
<group targetFramework="net7.0" />
</dependencies>
</metadata>
</package>
Binary file added tools/Addins/Cake.FileHelpers.6.0.0/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
194 changes: 194 additions & 0 deletions tools/Addins/Cake.FileHelpers.6.0.0/lib/net6.0/Cake.FileHelpers.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit 84def43

Please sign in to comment.