-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/141-propertysetterscontextextens…
…ion-binding-multibinding-and-dynamicresource-support' into develop
- Loading branch information
Showing
9 changed files
with
382 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net8.0-android</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.19041.0</TargetFrameworks> | ||
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-tizen</TargetFrameworks> --> | ||
<TargetFrameworks>$(TargetFrameworks);net8.0</TargetFrameworks> | ||
<OutputType Condition="'$(TargetFramework)' != 'net8.0'">Exe</OutputType> | ||
<PropertyGroup> | ||
<TargetFrameworks>net8.0-android</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.19041.0</TargetFrameworks> | ||
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-tizen</TargetFrameworks> --> | ||
<TargetFrameworks>$(TargetFrameworks);net8.0</TargetFrameworks> | ||
<OutputType Condition="'$(TargetFramework)' != 'net8.0'">Exe</OutputType> | ||
|
||
<!-- .NET MAUI --> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<!-- .NET MAUI --> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
|
||
<!-- Project Options --> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RootNamespace>MyOrderApp</RootNamespace> | ||
<!-- Project Options --> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RootNamespace>MyOrderApp</RootNamespace> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>MyOrderApp</ApplicationTitle> | ||
<!-- Display name --> | ||
<ApplicationTitle>MyOrderApp</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.myorderapp</ApplicationId> | ||
<ApplicationIdGuid>0f1f5ccb-47f5-4b4b-8927-96cc6840eea4</ApplicationIdGuid> | ||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.myorderapp</ApplicationId> | ||
<ApplicationIdGuid>0f1f5ccb-47f5-4b4b-8927-96cc6840eea4</ApplicationIdGuid> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<!-- Target Platform Options --> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
<!-- Target Platform Options --> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
|
||
<!-- Minimum Target OS Version for Windows Platform --> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
<!-- Minimum Target OS Version for Windows Platform --> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" /> | ||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" /> | ||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" /> | ||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" /> | ||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="MyOrderApp.code-workspace" /> | ||
<None Remove="Resources\Images\background.jpg" /> | ||
<None Remove="Resources\Images\basket.png" /> | ||
<None Remove="Resources\Images\categories.png" /> | ||
<None Remove="Resources\Images\chevron.png" /> | ||
<None Remove="Resources\Images\favorite.png" /> | ||
<None Remove="Resources\Images\favorites.png" /> | ||
<None Remove="Resources\Images\home.png" /> | ||
<None Remove="Resources\Images\not_favorite.png" /> | ||
<None Remove="Resources\Images\products.png" /> | ||
<None Remove="Resources\Images\remove.png" /> | ||
<None Remove="Resources\Images\white_bread.png" /> | ||
<None Remove="Resources\Raw\completed.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoMapper" Version="13.0.1" /> | ||
<PackageReference Include="FmgLib.MauiMarkup" Version="8.8.1" /> | ||
<PackageReference Include="LiteDB" Version="5.0.20" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.*" Condition="'$(Configuration)' == 'Debug'" /> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" /> | ||
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" /> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" /> | ||
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Remove="MyOrderApp.code-workspace" /> | ||
<None Remove="Resources\Images\background.jpg" /> | ||
<None Remove="Resources\Images\basket.png" /> | ||
<None Remove="Resources\Images\categories.png" /> | ||
<None Remove="Resources\Images\chevron.png" /> | ||
<None Remove="Resources\Images\favorite.png" /> | ||
<None Remove="Resources\Images\favorites.png" /> | ||
<None Remove="Resources\Images\home.png" /> | ||
<None Remove="Resources\Images\not_favorite.png" /> | ||
<None Remove="Resources\Images\products.png" /> | ||
<None Remove="Resources\Images\remove.png" /> | ||
<None Remove="Resources\Images\white_bread.png" /> | ||
<None Remove="Resources\Raw\completed.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\FmgLib.MauiMarkup\FmgLib.MauiMarkup.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="AutoMapper" Version="13.0.1" /> | ||
<PackageReference Include="LiteDB" Version="5.0.20" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.*" Condition="'$(Configuration)' == 'Debug'" /> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" /> | ||
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" /> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" /> | ||
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/FmgLib.MauiMarkup/Core/Builder/PropertySettersBindingBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
using System.Globalization; | ||
|
||
namespace FmgLib.MauiMarkup; | ||
|
||
public sealed class PropertySettersBindingBuilder<T> : IPropertySettersBuilder<T> | ||
{ | ||
public class ValueConverter : IValueConverter | ||
{ | ||
internal Func<object, T> ConvertFunction; | ||
|
||
internal Func<T, object> ConvertBackFunction; | ||
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value != null && ConvertFunction != null) | ||
{ | ||
return ConvertFunction(value); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value != null && ConvertBackFunction != null) | ||
{ | ||
return ConvertBackFunction((T)value); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
|
||
private string path; | ||
|
||
private BindingMode bindingMode; | ||
|
||
private IValueConverter converter; | ||
|
||
private ValueConverter valueConverter; | ||
|
||
private string converterParameter; | ||
|
||
private string stringFormat; | ||
|
||
private object source; | ||
|
||
private object fallbackValue; | ||
|
||
private object targetNullValue; | ||
|
||
public PropertySettersContext<T> Context { get; set; } | ||
|
||
public PropertySettersBindingBuilder(PropertySettersContext<T> context) | ||
{ | ||
Context = context; | ||
} | ||
|
||
public bool Build() | ||
{ | ||
if (path != null) | ||
{ | ||
Context.XamlSetters.Add( | ||
new Setter | ||
{ | ||
Property = Context.Property, | ||
Value = new Binding(path, bindingMode, converter, converterParameter, stringFormat, source) | ||
.FallbackValue(fallbackValue) | ||
.TargetNullValue(targetNullValue) | ||
} | ||
); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> Path(string path) | ||
{ | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> StringFormat(string stringFormat) | ||
{ | ||
this.stringFormat = stringFormat; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> BindingMode(BindingMode bindingMode) | ||
{ | ||
this.bindingMode = bindingMode; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> Converter(IValueConverter converter) | ||
{ | ||
this.converter = converter; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> Parameter(string converterParameter) | ||
{ | ||
this.converterParameter = converterParameter; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> Source(object source) | ||
{ | ||
this.source = source; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> FallbackValue(object fallbackValue) | ||
{ | ||
this.fallbackValue = fallbackValue; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> TargetNullValue(object targetNullValue) | ||
{ | ||
this.targetNullValue = targetNullValue; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> Convert<Q>(Func<Q, T> convert) | ||
{ | ||
if (valueConverter == null) | ||
{ | ||
valueConverter = new ValueConverter(); | ||
} | ||
|
||
valueConverter.ConvertFunction = (object e) => convert((Q)e); | ||
converter = valueConverter; | ||
return this; | ||
} | ||
|
||
public PropertySettersBindingBuilder<T> ConvertBack<Q>(Func<T, Q> convert) | ||
{ | ||
if (valueConverter == null) | ||
{ | ||
valueConverter = new ValueConverter(); | ||
} | ||
|
||
valueConverter.ConvertBackFunction = (T e) => convert(e); | ||
converter = valueConverter; | ||
return this; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/FmgLib.MauiMarkup/Core/Builder/PropertySettersDynamicResourcesBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace FmgLib.MauiMarkup; | ||
|
||
public sealed class PropertySettersDynamicResourcesBuilder<T> : IPropertySettersBuilder<T> | ||
{ | ||
public PropertySettersContext<T> Context { get; set; } | ||
|
||
string key = null; | ||
|
||
public PropertySettersDynamicResourcesBuilder(PropertySettersContext<T> context) | ||
{ | ||
Context = context; | ||
} | ||
|
||
public bool Build() | ||
{ | ||
if (!string.IsNullOrEmpty(key)) | ||
{ | ||
Context.XamlSetters.Add(new Setter { Property = Context.Property, Value = new Microsoft.Maui.Controls.Internals.DynamicResource(key) }); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public PropertySettersDynamicResourcesBuilder<T> DynamicResource(string key) { this.key = key; return this; } | ||
} |
Oops, something went wrong.