Skip to content

Commit c11cbba

Browse files
authored
Merge pull request #30 from MADE-Apps/feature/ui-data-converters
Added UI Data Converter library
2 parents 7986008 + 1464b20 commit c11cbba

28 files changed

+929
-24
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ body:
2121
- "UI.Controls.ChipBox"
2222
- "UI.Controls.DropDownList"
2323
- "UI.Controls.FilePicker"
24+
- "UI.Controls.RichEditToolbar"
2425
- "UI.Controls.Validator"
26+
- "UI.Data.Converters"
2527
- "UI.Styling"
2628
- "UI.ViewManagement"
2729
- "UI.Views.Dialogs"

MADE-Uno.sln

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MADE.UI.Controls.ChipBox",
4343
EndProject
4444
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MADE.UI.Controls.RichEditToolbar", "src\MADE.UI.Controls.RichEditToolbar\MADE.UI.Controls.RichEditToolbar.csproj", "{258FB310-DC02-488C-97C7-CD1226EAAEC8}"
4545
EndProject
46+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MADE.UI.Data.Converters", "src\MADE.UI.Data.Converters\MADE.UI.Data.Converters.csproj", "{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}"
47+
EndProject
4648
Global
4749
GlobalSection(SharedMSBuildProjectFiles) = preSolution
4850
samples\MADE.Samples\MADE.Samples.Shared\MADE.Samples.Shared.projitems*{04f1b32d-9056-43fc-b4c2-b8c5481bdacb}*SharedItemsImports = 4
@@ -1104,6 +1106,76 @@ Global
11041106
{258FB310-DC02-488C-97C7-CD1226EAAEC8}.Release|x64.Build.0 = Release|Any CPU
11051107
{258FB310-DC02-488C-97C7-CD1226EAAEC8}.Release|x86.ActiveCfg = Release|Any CPU
11061108
{258FB310-DC02-488C-97C7-CD1226EAAEC8}.Release|x86.Build.0 = Release|Any CPU
1109+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
1110+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
1111+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
1112+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
1113+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|ARM64.ActiveCfg = Debug|Any CPU
1114+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|ARM64.Build.0 = Debug|Any CPU
1115+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
1116+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
1117+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1118+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
1119+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
1120+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
1121+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
1122+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
1123+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
1124+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|Any CPU.Build.0 = Debug|Any CPU
1125+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|ARM.ActiveCfg = Debug|Any CPU
1126+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|ARM.Build.0 = Debug|Any CPU
1127+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|ARM64.ActiveCfg = Debug|Any CPU
1128+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|ARM64.Build.0 = Debug|Any CPU
1129+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
1130+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|iPhone.Build.0 = Debug|Any CPU
1131+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1132+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
1133+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|x64.ActiveCfg = Debug|Any CPU
1134+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|x64.Build.0 = Debug|Any CPU
1135+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|x86.ActiveCfg = Debug|Any CPU
1136+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.AppStore|x86.Build.0 = Debug|Any CPU
1137+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1138+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
1139+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|ARM.ActiveCfg = Debug|Any CPU
1140+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|ARM.Build.0 = Debug|Any CPU
1141+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
1142+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|ARM64.Build.0 = Debug|Any CPU
1143+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
1144+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|iPhone.Build.0 = Debug|Any CPU
1145+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1146+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
1147+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|x64.ActiveCfg = Debug|Any CPU
1148+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|x64.Build.0 = Debug|Any CPU
1149+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|x86.ActiveCfg = Debug|Any CPU
1150+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Debug|x86.Build.0 = Debug|Any CPU
1151+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|Any CPU.ActiveCfg = Debug|Any CPU
1152+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|Any CPU.Build.0 = Debug|Any CPU
1153+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|ARM.ActiveCfg = Debug|Any CPU
1154+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|ARM.Build.0 = Debug|Any CPU
1155+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|ARM64.ActiveCfg = Debug|Any CPU
1156+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|ARM64.Build.0 = Debug|Any CPU
1157+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|iPhone.ActiveCfg = Debug|Any CPU
1158+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|iPhone.Build.0 = Debug|Any CPU
1159+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1160+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|iPhoneSimulator.Build.0 = Debug|Any CPU
1161+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|x64.ActiveCfg = Debug|Any CPU
1162+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|x64.Build.0 = Debug|Any CPU
1163+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|x86.ActiveCfg = Debug|Any CPU
1164+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Package|x86.Build.0 = Debug|Any CPU
1165+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
1166+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|Any CPU.Build.0 = Release|Any CPU
1167+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|ARM.ActiveCfg = Release|Any CPU
1168+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|ARM.Build.0 = Release|Any CPU
1169+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|ARM64.ActiveCfg = Release|Any CPU
1170+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|ARM64.Build.0 = Release|Any CPU
1171+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|iPhone.ActiveCfg = Release|Any CPU
1172+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|iPhone.Build.0 = Release|Any CPU
1173+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
1174+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
1175+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|x64.ActiveCfg = Release|Any CPU
1176+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|x64.Build.0 = Release|Any CPU
1177+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|x86.ActiveCfg = Release|Any CPU
1178+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C}.Release|x86.Build.0 = Release|Any CPU
11071179
EndGlobalSection
11081180
GlobalSection(SolutionProperties) = preSolution
11091181
HideSolutionNode = FALSE
@@ -1126,6 +1198,7 @@ Global
11261198
{442D1E25-FFD1-405D-A1FC-40CAFCAD190C} = {01380FB8-F8A7-4416-AABA-5407574B7723}
11271199
{D1A16208-5A34-4CC1-B175-01B5AC99E69E} = {01380FB8-F8A7-4416-AABA-5407574B7723}
11281200
{258FB310-DC02-488C-97C7-CD1226EAAEC8} = {01380FB8-F8A7-4416-AABA-5407574B7723}
1201+
{55D12223-8B53-4EC7-8CD2-05FC8A84BA7C} = {01380FB8-F8A7-4416-AABA-5407574B7723}
11291202
EndGlobalSection
11301203
GlobalSection(ExtensibilityGlobals) = postSolution
11311204
SolutionGuid = {3921AD86-E6C0-4436-8880-2D9EDFAD6151}

assets/SampleIcons.afdesign

12.9 KB
Binary file not shown.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
uid: package-ui-data-converters
3+
title: Using the UI Data Converters package
4+
---
5+
6+
# Using the UI Data Converters package
7+
8+
The UI Data Converters package is designed for making the conversion of data objects to a different type in native applications for Windows, Android, iOS, macOS, Linux, and the web easier.
9+
10+
## Converting boolean values to a string (and back) with the BooleanToStringValueConverter
11+
12+
The `MADE.UI.Data.Converters.BooleanToStringValueConverter` provides a way to convert a boolean value to a string and back with a bound data source in a XAML view.
13+
14+
```xml
15+
<Grid>
16+
<Grid.Resources>
17+
<converters:BooleanToStringValueConverter x:Key="BooleanToStringValueConverter" TrueValue="Yes" FalseValue="No" />
18+
</Grid.Resources>
19+
20+
<!-- A true boolean will return the TrueValue of the converter -->
21+
<TextBlock Text="{x:Bind ViewModel.True, Converter={StaticResource BooleanToStringValueConverter}}" />
22+
23+
<!-- A false boolean will return the FalseValue of the converter -->
24+
<TextBlock Text="{x:Bind ViewModel.False, Converter={StaticResource BooleanToStringValueConverter}}" />
25+
</Grid>
26+
```
27+
28+
Instances of the converter can be set up with varying values for the `TrueValue` and `FalseValue` properties that will represent the value shown when the boolean is true and false, respectively. The default values are `Yes` and `No`.
29+
30+
**Note**, when converting back from the string value to a boolean when used in a `TwoWay` binding, the `TrueValue` and `FalseValue` properties are used to determine which value is considered true and false. If the string value does not match, an exception will be thrown.
31+
32+
## Displaying a byte array as an image with the ByteArrayToImageSourceValueConverter
33+
34+
The `MADE.UI.Data.Converters.ByteArrayToImageSourceValueConverter` provides a way to convert a bound byte array containing the details of an image to an image source that can be bound to an `Image` XAML element.
35+
36+
```xml
37+
<Grid>
38+
<Grid.Resources>
39+
<converters:ByteArrayToImageSourceValueConverter x:Key="ByteArrayToImageSourceValueConverter" />
40+
</Grid.Resources>
41+
42+
<!-- Converts the image's byte array into a source image that is loaded into the element -->
43+
<Image Source="{x:Bind ViewModel.ImageBytes, Converter={StaticResource ByteArrayToImageSourceValueConverter}, Mode=OneWay}" />
44+
</Grid>
45+
```
46+
47+
## Formatting a DateTime value with the DateTimeToStringValueConverter
48+
49+
The `MADE.UI.Data.Converters.DateTimeToStringValueConverter` converts a given `DateTime` object into a string using the provided format in the binding `ConverterParameter` property.
50+
51+
```xml
52+
<Grid>
53+
<Grid.Resources>
54+
<converters:DateTimeToStringValueConverter x:Key="DateTimeToStringValueConverter" />
55+
</Grid.Resources>
56+
57+
<!-- Converts the DateTime object into the dd/MM/yyyy format -->
58+
<TextBlock Text="{x:Bind ViewModel.DateTime, Converter={StaticResource DateTimeToStringValueConverter}, ConverterParameter=dd/MM/yyyy}" />
59+
</Grid>
60+
```
61+
62+
**Note**, the converter supports any of the standard and custom formats supported by the `DateTime.ToString()` method. You can [find more information on these in the Microsoft documentation](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).

docs/articles/intro.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ dotnet add package MADE.UI
2323
| MADE.UI.Controls.ChipBox | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Controls.ChipBox)](https://www.nuget.org/packages/MADE.UI.Controls.ChipBox/) |
2424
| MADE.UI.Controls.DropDownList | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Controls.DropDownList)](https://www.nuget.org/packages/MADE.UI.Controls.DropDownList/) |
2525
| MADE.UI.Controls.FilePicker | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Controls.FilePicker)](https://www.nuget.org/packages/MADE.UI.Controls.FilePicker/) |
26+
| MADE.UI.Controls.RichEditToolbar | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Controls.RichEditToolbar)](https://www.nuget.org/packages/MADE.UI.Controls.RichEditToolbar/) |
2627
| MADE.UI.Controls.Validator | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Controls.Validator)](https://www.nuget.org/packages/MADE.UI.Controls.Validator/) |
28+
| MADE.UI.Data.Converters | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Data.Converters)](https://www.nuget.org/packages/MADE.UI.Data.Converters/) |
2729
| MADE.UI.Styling | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.Styling)](https://www.nuget.org/packages/MADE.UI.Styling/) |
2830
| MADE.UI.ViewManagement | [![NuGet](https://img.shields.io/nuget/v/MADE.UI.ViewManagement)](https://www.nuget.org/packages/MADE.UI.ViewManagement/) |
2931

3032
#### UI
3133

32-
The UI package is a base library for building out great user experiences for applications built for Windows, Android, iOS, and the web.
34+
The UI package is a base library for building out great user experiences for applications built for Windows, Android, iOS, and the web.
3335

3436
Taking advantage of the Uno Platform, the UI packages provide extensible features such as:
3537

@@ -67,7 +69,7 @@ The control works in a similar way to the `ComboBox` element in the Windows SDK,
6769

6870
#### UI.Controls.FilePicker
6971

70-
The UI Controls FilePicker library contains a cross-platform UI element that provides a web-like `<input type="file" />` equivalent for native applications.
72+
The UI Controls FilePicker library contains a cross-platform UI element that provides a web-like `<input type="file" />` equivalent for native applications.
7173

7274
The control provides the capability to select one or multiple files of given types and show them within the UI.
7375

@@ -77,6 +79,18 @@ The control provides the capability to select one or multiple files of given typ
7779

7880
</span>
7981

82+
#### UI.Controls.RichEditToolbar
83+
84+
The UI Controls RichEditToolbar library contains a cross-platform UI element that provides customizable and extensible collection of buttons that activate rich text features in an associated RichEditBox.
85+
86+
Think the InkToolbar equivalent for RichEditBox controls!
87+
88+
<span class="button">
89+
90+
[Discover UI.Controls.RichEditToolbar](features/ui-controls-filepicker.md)
91+
92+
</span>
93+
8094
#### UI.Controls.Validator
8195

8296
The UI Controls Validator library contains a cross-platform UI element that provides validation capabilities over any input element.
@@ -89,6 +103,16 @@ Taking advantage of the Data Validation library, you can simply and easily setup
89103

90104
</span>
91105

106+
#### UI.Data.Converters
107+
108+
The UI Data Converters package is designed for making the conversion of data objects to a different type in native applications for Windows, Android, iOS, macOS, Linux, and the web easier.
109+
110+
<span class="button">
111+
112+
[Discover UI.Data.Converters](features/ui-data-converters.md)
113+
114+
</span>
115+
92116
#### UI.Styling
93117

94118
The UI Styling library contains a collection of cross-platform UI styling components for improving the designing of applications.
@@ -98,3 +122,13 @@ The UI Styling library contains a collection of cross-platform UI styling compon
98122
[Discover UI.Styling](features/ui-styling.md)
99123

100124
</span>
125+
126+
#### UI.ViewManagement
127+
128+
The UI View Management package is designed for improving how your applications can create and manage additional windows in Windows applications.
129+
130+
<span class="button">
131+
132+
[Discover UI.ViewManagement](features/ui-view-management.md)
133+
134+
</span>

docs/articles/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
href: features/ui-controls-dropdownlist.md
1515
- name: FilePicker
1616
href: features/ui-controls-filepicker.md
17+
- name: RichEditToolbar
18+
href: features/ui-controls-richedittoolbar.md
1719
- name: Validator
1820
href: features/ui-controls-validator.md
21+
- name: Data Converters
22+
href: features/ui-data-converters.md
1923
- name: Styling
2024
href: features/ui-styling.md
2125
- name: View Management

samples/MADE.Samples/MADE.Samples.Droid/MADE.Samples.Droid.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<PackageReference Include="Microsoft.Extensions.Logging.Console">
8181
<Version>5.0.0</Version>
8282
</PackageReference>
83+
<PackageReference Include="System.Net.Http">
84+
<Version>4.3.4</Version>
85+
</PackageReference>
8386
<PackageReference Include="Uno.ColorCode.UWP">
8487
<Version>2.1.0-uno.32</Version>
8588
</PackageReference>
@@ -133,6 +136,10 @@
133136
<Project>{e2b20928-dae2-4a9c-bdaf-d787b4f48391}</Project>
134137
<Name>MADE.UI.Controls.Validator</Name>
135138
</ProjectReference>
139+
<ProjectReference Include="..\..\..\src\MADE.UI.Data.Converters\MADE.UI.Data.Converters.csproj">
140+
<Project>{55d12223-8b53-4ec7-8cd2-05fc8a84ba7c}</Project>
141+
<Name>MADE.UI.Data.Converters</Name>
142+
</ProjectReference>
136143
<ProjectReference Include="..\..\..\src\MADE.UI.Styling\MADE.UI.Styling.csproj">
137144
<Project>{f8d00106-0598-45e7-b92e-ef408249c02e}</Project>
138145
<Name>MADE.UI.Styling</Name>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
<Application
1+
<Application
22
x:Class="MADE.Samples.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:local="using:MADE.Samples">
66

7+
<Application.Resources>
8+
</Application.Resources>
9+
710
</Application>

samples/MADE.Samples/MADE.Samples.Shared/Features/Home/ViewModels/MainPageViewModel.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public MainPageViewModel(INavigationService navigationService, IMessenger messen
2525

2626
public ICollection<SampleGroup> SampleGroups { get; } = GetSampleGroups();
2727

28+
public ICollection<Sample> Samples => SampleGroups.SelectMany(x => x.Samples).ToList();
29+
2830
private static ICollection<SampleGroup> GetSampleGroups()
2931
{
3032
var controls = new SampleGroup
@@ -48,13 +50,18 @@ private static ICollection<SampleGroup> GetSampleGroups()
4850
"InputValidator",
4951
typeof(InputValidatorPage),
5052
"/Features/Samples/Assets/InputValidator/InputValidator.png"),
51-
new Sample(
52-
"RichEditToolbar",
53-
typeof(RichEditToolbarPage),
54-
"/Features/Samples/Assets/RichEditToolbar/RichEditToolbar.png")
5553
}
5654
};
5755

56+
#if WINDOWS_UWP
57+
AddPlatformSpecificSample(
58+
controls,
59+
new Sample(
60+
"RichEditToolbar",
61+
typeof(RichEditToolbarPage),
62+
"/Features/Samples/Assets/RichEditToolbar/RichEditToolbar.png"));
63+
#endif
64+
5865
var helpers = new SampleGroup
5966
{
6067
Name = "Helpers",
@@ -63,26 +70,35 @@ private static ICollection<SampleGroup> GetSampleGroups()
6370
new Sample(
6471
"AppDialog",
6572
typeof(AppDialogPage),
66-
"/Features/Samples/Assets/AppDialog/AppDialog.png")
73+
"/Features/Samples/Assets/AppDialog/AppDialog.png"),
74+
new Sample(
75+
"Value Converters",
76+
typeof(ValueConvertersPage),
77+
"/Features/Samples/Assets/ValueConverters/ValueConverters.png")
6778
}
6879
};
6980

7081
if (PlatformApiHelper.IsTypeSupported(typeof(WindowManager)))
7182
{
72-
helpers.Samples.InsertAtPotentialIndex(
83+
AddPlatformSpecificSample(
84+
helpers,
7385
new Sample(
7486
"WindowManager",
7587
typeof(WindowManagerPage),
76-
"/Features/Samples/Assets/WindowManager/WindowManager.png"),
77-
(item, compare) => compare.Name.IsLessThanOrEqualTo(item.Name));
88+
"/Features/Samples/Assets/WindowManager/WindowManager.png"));
7889
}
7990

80-
var list = new List<SampleGroup> { controls, helpers };
91+
var list = new List<SampleGroup> {controls, helpers};
8192

8293
return list;
8394
}
8495

85-
public ICollection<Sample> Samples => SampleGroups.SelectMany(x => x.Samples).ToList();
96+
private static void AddPlatformSpecificSample(SampleGroup sampleGroup, Sample sample)
97+
{
98+
sampleGroup.Samples.InsertAtPotentialIndex(
99+
sample,
100+
(item, compare) => compare.Name.IsLessThanOrEqualTo(item.Name));
101+
}
86102

87103
private void NavigateToSample(Sample sample)
88104
{

0 commit comments

Comments
 (0)