Skip to content

Commit eae9c65

Browse files
authored
Merge branch 'main' into feature/version
2 parents 718b679 + 30b549c commit eae9c65

File tree

70 files changed

+4758
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4758
-103
lines changed

Directory.Build.targets

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Project>
3+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net7.0-ios')) != true AND $(TargetFramework.StartsWith('net7.0-maccatalyst')) != true ">
4+
<Compile Remove="**\**\*.ios.cs" />
5+
<None Include="**\**\*.ios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
6+
<Compile Remove="**\ios\**\*.cs" />
7+
<None Include="**\ios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
8+
</ItemGroup>
9+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true ">
10+
<Compile Remove="**\*.macos.cs" />
11+
<None Include="**\*.macos.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
12+
<Compile Remove="**\macos\**\*.cs" />
13+
<None Include="**\macos\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
14+
</ItemGroup>
15+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net7.0-ios')) != true AND $(TargetFramework.StartsWith('net7.0-maccatalyst')) != true">
16+
<Compile Remove="**\*.macios.cs" />
17+
<None Include="**\*.macios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
18+
<Compile Remove="**\macios\**\*.cs" />
19+
<None Include="**\macios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
20+
</ItemGroup>
21+
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('net7.0-android')) != true ">
22+
<Compile Remove="**\**\*.android.cs" />
23+
<None Include="**\**\*.android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
24+
<Compile Remove="**\android\**\*.cs" />
25+
<None Include="**\android\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
26+
</ItemGroup>
27+
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) != true ">
28+
<Compile Remove="**\*.windows.cs" />
29+
<None Include="**\*.windows.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
30+
<Compile Remove="**\windows\**\*.cs" />
31+
<None Include="**\windows\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
32+
</ItemGroup>
33+
<ItemGroup Condition="$(TargetFramework.Contains('-tizen')) != true ">
34+
<Compile Remove="**\*.tizen.cs" />
35+
<None Include="**\*.tizen.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
36+
<Compile Remove="**\tizen\**\*.cs" />
37+
<None Include="**\tizen\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
38+
</ItemGroup>
39+
<ItemGroup Condition="!($(TargetFramework.StartsWith('net')) == true AND $(TargetFramework.EndsWith('.0')) == true AND $(TargetFramework.Contains('-')) != true)"> <!-- e.g net6.0 or net7.0 -->
40+
<Compile Remove="**\*.net.cs" />
41+
<None Include="**\*.net.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
42+
<Compile Remove="**\net\**\*.cs" />
43+
<None Include="**\net\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
44+
</ItemGroup>
45+
</Project>

azure-pipelines.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ variables:
99
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
1010
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
1111
PathToCommunityToolkitCoreCsproj: 'src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj'
12+
PathToCommunityToolkitMediaElementCsproj: 'src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj'
1213
PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj'
1314
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj'
1415
PathToCommunityToolkitAnalyzersCsproj: 'src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj'
16+
PathToCommunityToolkitMediaElementAnalyzersCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj'
1517
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj'
1618
PathToCommunityToolkitAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj'
19+
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
1720
PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj'
1821
DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/7.0.49.json'
1922
Latest_Xcode_Version: '14.1.0'
@@ -142,6 +145,16 @@ jobs:
142145
inputs:
143146
script: 'dotnet build -c Release $(PathToCommunityToolkitAnalyzersCodeFixCsproj)'
144147

148+
- task: CmdLine@2
149+
displayName: 'Build CommunityToolkit.Maui.MediaElement.Analyzers'
150+
inputs:
151+
script: 'dotnet build -c Release $(PathToCommunityToolkitMediaElementAnalyzersCsproj)'
152+
153+
- task: CmdLine@2
154+
displayName: 'Build CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes'
155+
inputs:
156+
script: 'dotnet build -c Release $(PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj)'
157+
145158
- task: CmdLine@2
146159
displayName: 'Build CommunityToolkit.Maui.SourceGenerators'
147160
inputs:
@@ -183,6 +196,11 @@ jobs:
183196
inputs:
184197
script: 'dotnet pack $(PathToCommunityToolkitCsproj) -c Release -p:PackageVersion=$(NugetPackageVersion)'
185198

199+
- task: CmdLine@2
200+
displayName: 'Pack CommunityToolkit.Maui.MediaElement NuGet'
201+
inputs:
202+
script: 'dotnet pack $(PathToCommunityToolkitMediaElementCsproj) -c Release -p:PackageVersion=$(NugetPackageVersion)'
203+
186204
# check vulnerabilities
187205
- powershell: |
188206
dotnet list $(PathToLibrarySolution) package --vulnerable --include-transitive | findstr /S /c:"has the following vulnerable packages";

samples/CommunityToolkit.Maui.Sample.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{9F7D54C0
3232
EndProject
3333
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.Analyzers.UnitTests", "..\src\CommunityToolkit.Maui.Analyzers.UnitTests\CommunityToolkit.Maui.Analyzers.UnitTests.csproj", "{60B976B2-F3FA-494E-A28B-7BED2EAE990E}"
3434
EndProject
35+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.MediaElement", "..\src\CommunityToolkit.Maui.MediaElement\CommunityToolkit.Maui.MediaElement.csproj", "{A651D248-B102-4B8B-90C2-3C4C28425EFF}"
36+
EndProject
37+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.MediaElement.Analyzers", "..\src\CommunityToolkit.Maui.MediaElement.Analyzers\CommunityToolkit.Maui.MediaElement.Analyzers.csproj", "{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE}"
38+
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes", "..\src\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj", "{215083C8-D9CA-48FA-8B0A-1D21A989D055}"
40+
EndProject
3541
Global
3642
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3743
Debug|Any CPU = Debug|Any CPU
@@ -74,6 +80,18 @@ Global
7480
{60B976B2-F3FA-494E-A28B-7BED2EAE990E}.Debug|Any CPU.Build.0 = Debug|Any CPU
7581
{60B976B2-F3FA-494E-A28B-7BED2EAE990E}.Release|Any CPU.ActiveCfg = Release|Any CPU
7682
{60B976B2-F3FA-494E-A28B-7BED2EAE990E}.Release|Any CPU.Build.0 = Release|Any CPU
83+
{A651D248-B102-4B8B-90C2-3C4C28425EFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84+
{A651D248-B102-4B8B-90C2-3C4C28425EFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
85+
{A651D248-B102-4B8B-90C2-3C4C28425EFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
86+
{A651D248-B102-4B8B-90C2-3C4C28425EFF}.Release|Any CPU.Build.0 = Release|Any CPU
87+
{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88+
{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
89+
{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
90+
{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE}.Release|Any CPU.Build.0 = Release|Any CPU
91+
{215083C8-D9CA-48FA-8B0A-1D21A989D055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
92+
{215083C8-D9CA-48FA-8B0A-1D21A989D055}.Debug|Any CPU.Build.0 = Debug|Any CPU
93+
{215083C8-D9CA-48FA-8B0A-1D21A989D055}.Release|Any CPU.ActiveCfg = Release|Any CPU
94+
{215083C8-D9CA-48FA-8B0A-1D21A989D055}.Release|Any CPU.Build.0 = Release|Any CPU
7795
EndGlobalSection
7896
GlobalSection(SolutionProperties) = preSolution
7997
HideSolutionNode = FALSE
@@ -85,6 +103,8 @@ Global
85103
{BB7A6C2F-B8F1-49FF-8E67-C436EF062A22} = {9BFC4026-BC8F-43E2-BAA9-5BC2D764D37D}
86104
{20792D38-690A-4760-82FD-94E9510F86C9} = {9BFC4026-BC8F-43E2-BAA9-5BC2D764D37D}
87105
{60B976B2-F3FA-494E-A28B-7BED2EAE990E} = {9F7D54C0-EA17-409A-804F-B2E8D7F4A7F3}
106+
{85B875BD-62F6-4EC3-BCFF-4DC25E94BCAE} = {9BFC4026-BC8F-43E2-BAA9-5BC2D764D37D}
107+
{215083C8-D9CA-48FA-8B0A-1D21A989D055} = {9BFC4026-BC8F-43E2-BAA9-5BC2D764D37D}
88108
EndGlobalSection
89109
GlobalSection(ExtensibilityGlobals) = postSolution
90110
SolutionGuid = {1E9E61C1-5CB7-4C8E-87BA-6C1D38238679}

samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public partial class AppShell : Shell
110110
CreateViewModelMapping<AvatarViewSizesPage, AvatarViewSizesViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
111111
CreateViewModelMapping<DrawingViewPage, DrawingViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
112112
CreateViewModelMapping<ExpanderPage, ExpanderViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
113+
CreateViewModelMapping<MediaElementPage, MediaElementViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
113114
CreateViewModelMapping<MultiplePopupPage, MultiplePopupViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
114115
CreateViewModelMapping<PopupAnchorPage, PopupAnchorViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
115116
CreateViewModelMapping<PopupPositionPage, PopupPositionViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),

samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@
3939

4040
<!-- Images -->
4141
<MauiImage Include="Resources\Images\*" />
42+
43+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
44+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
45+
4246
<EmbeddedResource Include="Resources\Embedded\*" />
4347

4448
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="2.1.0" />
4549
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
4650
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.2" />
51+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
4752
</ItemGroup>
4853

4954
<PropertyGroup>
@@ -56,10 +61,11 @@
5661
</PropertyGroup>
5762

5863
<ItemGroup>
59-
<ProjectReference Include="..\..\src\CommunityToolkit.Maui\CommunityToolkit.Maui.csproj" />
6064
<ProjectReference Include="..\..\src\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
6165
<ProjectReference Include="..\..\src\CommunityToolkit.Maui.Analyzers\CommunityToolkit.Maui.Analyzers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
6266
<ProjectReference Include="..\..\src\CommunityToolkit.Maui.Analyzers.CodeFixes\CommunityToolkit.Maui.Analyzers.CodeFixes.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
67+
<ProjectReference Include="..\..\src\CommunityToolkit.Maui.MediaElement\CommunityToolkit.Maui.MediaElement.csproj" />
68+
<ProjectReference Include="..\..\src\CommunityToolkit.Maui\CommunityToolkit.Maui.csproj" />
6369
</ItemGroup>
6470

6571
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))=='android'">
@@ -70,7 +76,13 @@
7076
<RuntimeIdentifiers>maccatalyst-arm64;maccatalyst-x64</RuntimeIdentifiers>
7177
</PropertyGroup>
7278

73-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
74-
<CreatePackage>false</CreatePackage>
75-
</PropertyGroup>
79+
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
80+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221209.1" />
81+
</ItemGroup>
82+
83+
<ItemGroup>
84+
<Compile Update="Pages\Views\MediaElement\MediaElementPage.xaml.cs">
85+
<DependentUpon>MediaElementPage.xaml</DependentUpon>
86+
</Compile>
87+
</ItemGroup>
7688
</Project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Globalization;
2+
using System.Text;
3+
4+
namespace CommunityToolkit.Maui.Sample.Converters;
5+
6+
sealed class SecondsToStringConverter : IValueConverter
7+
{
8+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9+
{
10+
if (value is not double && value is not TimeSpan)
11+
{
12+
return value;
13+
}
14+
15+
StringBuilder formatBuilder = new();
16+
17+
if (value is double doubleValue)
18+
{
19+
var timeSpan = TimeSpan.FromSeconds(doubleValue);
20+
21+
if (timeSpan.Hours > 0)
22+
{
23+
formatBuilder.Append(@"hh\:");
24+
}
25+
26+
formatBuilder.Append(@"mm\:ss");
27+
28+
return timeSpan.ToString(formatBuilder.ToString());
29+
}
30+
else if (value is TimeSpan timespanValue)
31+
{
32+
if (timespanValue.Hours > 0)
33+
{
34+
formatBuilder.Append(@"hh\:");
35+
}
36+
37+
formatBuilder.Append(@"mm\:ss");
38+
39+
return timespanValue.ToString(formatBuilder.ToString());
40+
}
41+
42+
return value;
43+
}
44+
45+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
46+
{
47+
throw new NotSupportedException();
48+
}
49+
}

samples/CommunityToolkit.Maui.Sample/MauiProgram.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using CommunityToolkit.Maui.Core;
21
using CommunityToolkit.Maui.Markup;
32
using CommunityToolkit.Maui.Sample.Models;
43
using CommunityToolkit.Maui.Sample.Pages;
@@ -20,6 +19,7 @@
2019
using CommunityToolkit.Maui.Sample.ViewModels.Views;
2120
using CommunityToolkit.Maui.Sample.ViewModels.Views.AvatarView;
2221
using CommunityToolkit.Maui.Storage;
22+
using Microsoft.Extensions.Logging;
2323
using Polly;
2424

2525
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
@@ -42,6 +42,7 @@ public static MauiApp CreateMauiApp()
4242
})
4343
#endif
4444
.UseMauiCommunityToolkitMarkup()
45+
.UseMauiCommunityToolkitMediaElement()
4546
.UseMauiApp<App>();
4647

4748
builder.Services.AddHttpClient<ByteArrayToImageSourceConverterViewModel>()
@@ -52,6 +53,10 @@ public static MauiApp CreateMauiApp()
5253
RegisterViewsAndViewModels(builder.Services);
5354
RegisterEssentials(builder.Services);
5455

56+
#if DEBUG
57+
builder.Logging.AddDebug().SetMinimumLevel(LogLevel.Trace);
58+
#endif
59+
5560
return builder.Build();
5661

5762
static TimeSpan sleepDurationProvider(int attemptNumber) => TimeSpan.FromSeconds(Math.Pow(2, attemptNumber));
@@ -158,6 +163,7 @@ static void RegisterViewsAndViewModels(in IServiceCollection services)
158163
// Add Views Pages + ViewModels
159164
services.AddTransientWithShellRoute<DrawingViewPage, DrawingViewViewModel>();
160165
services.AddTransientWithShellRoute<ExpanderPage, ExpanderViewModel>();
166+
services.AddTransientWithShellRoute<MediaElementPage, MediaElementViewModel>();
161167
services.AddTransientWithShellRoute<MultiplePopupPage, MultiplePopupViewModel>();
162168
services.AddTransientWithShellRoute<PopupAnchorPage, PopupAnchorViewModel>();
163169
services.AddTransientWithShellRoute<PopupPositionPage, PopupPositionViewModel>();

0 commit comments

Comments
 (0)