Skip to content

Commit

Permalink
Implements tizen platform (#692)
Browse files Browse the repository at this point in the history
* Implements tizen platform

* Apply review comment

* Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs

* Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs

* Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs

* Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Apply review comment

* attempt to use 6.0.300

* 6.0.400

* 6.0.424

* 486

* 540

* Update azure-pipelines.yml

* Formatting Updates

* Add

* Remove duplicate enums

* Fix variable conflicts

* Defer to thread pool thread

* Fix MauiPopup anchor position

* Apply review comment

* Fix GetImageStream without await

* Add UnsupportedOSPlatform attribute on unsupported behaviors

Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Jay Cho <chojoong@gmail.com>
  • Loading branch information
5 people authored Nov 8, 2022
1 parent 1ea488c commit e80192b
Show file tree
Hide file tree
Showing 27 changed files with 901 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
<ItemGroup>
<InternalsVisibleTo Include="CommunityToolkit.Maui.UnitTests" />
</ItemGroup>
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' and $([MSBuild]::IsOSPlatform('windows')) == 'true'">
<IncludeTizenTargetFrameworks>true</IncludeTizenTargetFrameworks>
</PropertyGroup>
</Project>
16 changes: 13 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variables:
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
TOOLKIT_NET_VERSION: '6.0.300'
TOOLKIT_NET_VERSION: '6.0.400'
LATEST_NET_VERSION: '6.0.x'
PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
Expand All @@ -15,7 +15,7 @@ variables:
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj'
PathToCommunityToolkitAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj'
DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.312.json'
DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.540.json'
ShouldCheckDependencies: true

trigger:
Expand Down Expand Up @@ -62,6 +62,11 @@ jobs:
- powershell: dotnet workload install maui
displayName: Install Latest .NET MAUI Workload

- pwsh: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET_VERSION)
displayName: Install Tizen Workload
# build sample
- task: CmdLine@2
displayName: 'Build Community Toolkit Sample'
Expand Down Expand Up @@ -112,6 +117,11 @@ jobs:
inputs:
script: dotnet workload install maui --from-rollback-file $(DotNetMauiRollbackFile) --source https://api.nuget.org/v3/index.json

- pwsh: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET_VERSION)
displayName: Install Tizen Workload
- task: CmdLine@2
displayName: 'Build CommunityToolkit.Maui.Analyzers'
inputs:
Expand Down Expand Up @@ -205,4 +215,4 @@ jobs:
displayName: 'Publish NuGets'
inputs:
artifactName: nuget
pathToPublish: '$(Build.ArtifactStagingDirectory)'
pathToPublish: '$(Build.ArtifactStagingDirectory)'
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net6.0-tizen</TargetFrameworks>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
Expand Down Expand Up @@ -50,6 +51,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

Expand Down
16 changes: 16 additions & 0 deletions samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace CommunityToolkit.Maui.Sample;

class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="maui-application-id-placeholder" exec="CommunityToolkit.Maui.Sample.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>maui-application-title-placeholder</label>
<icon>maui-appicon-placeholder</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<shortcut-list />
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<dependencies />
<provides-appdefined-privileges />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
<Style x:Key="ConfirmButton" TargetType="Button">
<Setter Property="VerticalOptions" Value="EndAndExpand" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
</ResourceDictionary>
</VerticalStackLayout.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
<Style x:Key="CancelButton" TargetType="Button">
<Setter Property="Background" Value="#FFF" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="VerticalStackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
</ResourceDictionary>
</VerticalStackLayout.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
</ResourceDictionary>
</VerticalStackLayout.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
<Style x:Key="ConfirmButton" TargetType="Button">
<Setter Property="VerticalOptions" Value="EndAndExpand" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
</ResourceDictionary>
</VerticalStackLayout.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
<Style x:Key="ConfirmButton" TargetType="Button">
<Setter Property="VerticalOptions" Value="EndAndExpand" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Setter Property="VerticalTextAlignment" Value="Center" />
</Style>
<Style x:Key="PopupLayout" TargetType="StackLayout">
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5}" />
<Setter Property="Padding" Value="{OnPlatform Android=20, WinUI=20, iOS=5, MacCatalyst=5, Tizen=20}" />
</Style>
</ResourceDictionary>
</VerticalStackLayout.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net6.0-tizen</TargetFrameworks>
<UseMauiCore>true</UseMauiCore>
<UseMauiEssentials>true</UseMauiEssentials>
<SingleProject>true</SingleProject>
Expand Down Expand Up @@ -73,6 +74,12 @@
<Compile Remove="**\windows\**\*.cs" />
<None Include="**\windows\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-tizen')) != true ">
<Compile Remove="**\*.tizen.cs" />
<None Include="**\*.tizen.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\tizen\**\*.cs" />
<None Include="**\tizen\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="!($(TargetFramework.StartsWith('net')) == true AND $(TargetFramework.EndsWith('.0')) == true AND $(TargetFramework.Contains('-')) != true)"> <!-- e.g net6.0 or net7.0 -->
<Compile Remove="**\*.net.cs" />
<None Include="**\*.net.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public DrawingViewHandler() : this(DrawingViewMapper, DrawingViewCommandMapper)
}
}

#if ANDROID || IOS || MACCATALYST || WINDOWS
#if ANDROID || IOS || MACCATALYST || WINDOWS || TIZEN
public partial class DrawingViewHandler : ViewHandler<IDrawingView, MauiDrawingView>, IDrawingViewHandler
{

Expand Down
103 changes: 103 additions & 0 deletions src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using CommunityToolkit.Maui.Core.Views;
using Tizen.UIExtensions.NUI;

namespace CommunityToolkit.Maui.Core.Handlers;

public partial class PopupHandler : Microsoft.Maui.Handlers.ElementHandler<IPopup, MauiPopup>
{
/// <summary>
/// Action that's triggered when the Popup is closed.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
/// <param name="result">The result that should return from this Popup.</param>
public static void MapOnClosed(PopupHandler handler, IPopup view, object? result)
{
var popup = handler.PlatformView;

if (popup.IsOpen)
{
popup.Close();
}

handler.DisconnectHandler(popup);
}

/// <summary>
/// Action that's triggered when the Popup is Opened.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
/// <param name="result">We don't need to provide the result parameter here.</param>
public static void MapOnOpened(PopupHandler handler, IPopup view, object? result)
{
handler.PlatformView.ShowPopup();
}

/// <summary>
/// Action that's triggered when the Popup is dismissed by tapping outside of the Popup.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
/// <param name="result">The result that should return from this Popup.</param>
public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
{
if (view.CanBeDismissedByTappingOutsideOfPopup)
{
view.OnDismissedByTappingOutsideOfPopup();
}
}

/// <summary>
/// Action that's triggered when the Popup <see cref="IPopup.Anchor"/> property changes.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
public static void MapAnchor(PopupHandler handler, IPopup view)
{
// On Tizen, Anchor only update when popup is opened
}

/// <summary>
/// Action that's triggered when the Popup <see cref="IPopup.CanBeDismissedByTappingOutsideOfPopup"/> property changes.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
{
// this property directly access on platform view
}

/// <summary>
/// Action that's triggered when the Popup <see cref="IPopup.Color"/> property changes.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
public static void MapColor(PopupHandler handler, IPopup view)
{
// this property directly access on platform view
}

/// <summary>
/// Action that's triggered when the Popup <see cref="IPopup.Size"/> property changes.
/// </summary>
/// <param name="handler">An instance of <see cref="PopupHandler"/>.</param>
/// <param name="view">An instance of <see cref="IPopup"/>.</param>
public static void MapSize(PopupHandler handler, IPopup view)
{
handler.PlatformView.UpdateContentSize();
}

/// <inheritdoc/>
protected override void ConnectHandler(MauiPopup platformView)
{
platformView.SetElement(VirtualView);
}

/// <inheritdoc/>
protected override MauiPopup CreatePlatformElement()
{
var mauiContext = MauiContext ?? throw new InvalidOperationException("${nameof(MauiContext)} cannot be null");
return new MauiPopup(mauiContext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Runtime.Versioning;
using Microsoft.Maui.Platform;

namespace CommunityToolkit.Maui.Core.Platform;

[UnsupportedOSPlatform("Tizen")]
static partial class StatusBar
{
static void PlatformSetColor(Color color)
{
throw new NotSupportedException("Tizen does not currently support changing the status bar color");
}

static void PlatformSetStyle(StatusBarStyle style)
{
throw new NotSupportedException("Tizen does not currently support changing the status bar color");
}
}
Loading

0 comments on commit e80192b

Please sign in to comment.