Skip to content

Commit

Permalink
Add Maui Images
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Jun 7, 2022
1 parent 441a5a5 commit 3eb03d4
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 31 deletions.
6 changes: 5 additions & 1 deletion src/Common.Essentials.Maui/Common.Essentials.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@
</Compile>
</ItemGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI.Maui" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common.CoreLib\Common.CoreLib.csproj" />
<ProjectReference Include="..\Common.Essentials\Common.Essentials.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions src/Common.Essentials.Xamarin/MauiHandlersCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#if MAUI
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Maui.Hosting;

public static class MauiHandlersCollectionExtensions
{
public static IMauiHandlersCollection ReplaceHandler<TType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TTypeRender>(this IMauiHandlersCollection handlersCollection)
where TType : IElement
where TTypeRender : IElementHandler
{
var serviceType = typeof(TType);
var items = handlersCollection.Where(x => x.ServiceType == serviceType).ToArray();
Array.ForEach(items, x => handlersCollection.Remove(x));
handlersCollection.AddHandler<TType, TTypeRender>();
return handlersCollection;
}
}
#endif
7 changes: 3 additions & 4 deletions src/ST.Client.Maui.App/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ static int Main(string[] args)

host.ConfigureServicesDelegate = level =>
{
builder = MauiApp.CreateBuilder();
builder
builder = MauiApp.CreateBuilder()
.UseMauiApp(_ => new App(host))
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
})
;
ConfigureServices(host, level, builder.Services);
};
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client.Maui.App/ST.Client.Maui.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,4 @@
<ProjectReference Include="..\ST.Client.JumpList\ST.Client.JumpList.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
</ItemGroup>

</Project>
32 changes: 24 additions & 8 deletions src/ST.Client.Maui/ST.Client.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<RootNamespace>System.Application</RootNamespace>
<AssemblyName>System.Application.SteamTools.Client.Maui</AssemblyName>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<DefineConstants>MAUI;$(DefineConstants)</DefineConstants>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -50,19 +54,31 @@
</Compile>
</ItemGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI.Maui" />
</ItemGroup>
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<SupportedOSPlatformVersion>14.2</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">
<SupportedOSPlatformVersion>6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Common.Essentials.Maui\Common.Essentials.Maui.csproj" />
<ProjectReference Include="..\ST.Client\ST.Client.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Remove="**\*.xaml" />
</ItemGroup>
Expand Down
30 changes: 17 additions & 13 deletions src/ST.Client.Maui/UI/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@
x:DataType="vm:MainWindowViewModel">
<Shell.FlyoutHeaderTemplate>
<DataTemplate>
<StackLayout Padding="16" Orientation="Horizontal">
<StackLayout Padding="24,24,24,22" Orientation="Horizontal">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="OnFlyoutHeaderTapped" />
</StackLayout.GestureRecognizers>
<Image
HeightRequest="64"
Source="avatar_default"
WidthRequest="64" />
<Label
Margin="16,0,0,0"
FontSize="16"
LineBreakMode="TailTruncation"
MaxLines="2"
Text="{x:Static resx:AppResources.User_UnLogin}"
TextColor="{DynamicResource ShellTitleColor}"
VerticalTextAlignment="Center" />
<Image Source="avatar.jpg"
HeightRequest="64"
WidthRequest="64">
<Image.Clip>
<EllipseGeometry Center="32,32"
RadiusX="32"
RadiusY="32" />
</Image.Clip>
</Image>
<Label Margin="16,0,0,0"
FontSize="16"
LineBreakMode="TailTruncation"
MaxLines="2"
Text="{x:Static resx:AppResources.User_UnLogin}"
TextColor="{DynamicResource ShellTitleColor}"
VerticalTextAlignment="Center" />
</StackLayout>
</DataTemplate>
</Shell.FlyoutHeaderTemplate>
Expand Down
7 changes: 7 additions & 0 deletions src/ST.Client.Maui/UI/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public AppShell(MainWindowViewModel viewModel)

InitializeComponent();

//#if WINDOWS
// Microsoft.Maui.Controls.Handlers.ShellHandler.Mapper.AppendToMapping(nameof(AppShell), (handler, view) =>
// {
// handler.PlatformView.PaneDisplayMode = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftCompact;
// });
//#endif

if (!IsUseBottomNav)
{
#region Flyout
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/ST.Client.Maui/UI/Assets/Images/avatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/ST.Client/UI/ViewModels/Base/TabItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public virtual IList<MenuItemViewModel>? MenuItems

protected TabItemViewModelBase() : base()
{
IconKey = this.GetType().Name;
var typeName = GetType().Name;
IconKey = OperatingSystem2.Application.UseMaui() ? $"{typeName.ToLowerInvariant()}.png" : typeName;
}

public virtual void Initialize()
Expand Down
2 changes: 2 additions & 0 deletions src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
using Microsoft.Extensions.Http;
using Xamarin.Android.Net;
using Program = System.Application.UI.MainApplication;
#if !NET6_0_OR_GREATER
using PlatformApplication = System.Application.UI.MainApplication;
#endif
#elif __IOS__
using Program = System.Application.UI.AppDelegate;
#elif !__MOBILE__
Expand Down

0 comments on commit 3eb03d4

Please sign in to comment.