Skip to content

Commit

Permalink
Re-enabled Maui.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Mar 6, 2024
1 parent fc1bdf5 commit cc2a287
Show file tree
Hide file tree
Showing 46 changed files with 1,798 additions and 5 deletions.
206 changes: 206 additions & 0 deletions Epoxy.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public sealed partial class WaitingBlock : UserControl

public WaitingBlock()
{
InitializeComponent();
this.DataContext = this;
this.InitializeComponent();

this.CellBrushes = Enumerable.Range(0, 8).
Select(_ => Brushes.Gray).
Expand All @@ -64,8 +63,10 @@ public WaitingBlock()
}
},
null,
TimeSpan.Zero,
TimeSpan.Zero);
Timeout.InfiniteTimeSpan,
Timeout.InfiniteTimeSpan);

this.DataContext = this;
}

private void InitializeComponent() =>
Expand All @@ -79,7 +80,7 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{
this.timer.Change(TimeSpan.Zero, TimeSpan.Zero);
this.timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
base.OnDetachedFromVisualTree(e);
}

Expand Down
14 changes: 14 additions & 0 deletions playground/EpoxyHello.Maui/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:EpoxyHello.Maui"
x:Class="EpoxyHello.Maui.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
13 changes: 13 additions & 0 deletions playground/EpoxyHello.Maui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Maui.Controls;

namespace EpoxyHello.Maui;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
12 changes: 12 additions & 0 deletions playground/EpoxyHello.Maui/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="EpoxyHello.Maui.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:EpoxyHello.Maui.Views"
Shell.FlyoutBehavior="Disabled"
Title="EpoxyHello.Maui">

<ShellContent ContentTemplate="{DataTemplate views:MainPage}" />

</Shell>
11 changes: 11 additions & 0 deletions playground/EpoxyHello.Maui/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.Maui.Controls;

namespace EpoxyHello.Maui;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
50 changes: 50 additions & 0 deletions playground/EpoxyHello.Maui/Controls/WaitingBlock.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
////////////////////////////////////////////////////////////////////////////
//
// Epoxy - An independent flexible XAML MVVM library for .NET
// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
-->
<ContentView
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EpoxyHello.Maui.Controls"
mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"
x:Class="EpoxyHello.Maui.Controls.WaitingBlock">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="16" />
<RowDefinition Height="16" />
<RowDefinition Height="16" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="16" />
<ColumnDefinition Width="16" />
<ColumnDefinition Width="16" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Fill="{Binding CellBrush0}" />
<Rectangle Grid.Row="0" Grid.Column="1" Fill="{Binding CellBrush1}" />
<Rectangle Grid.Row="0" Grid.Column="2" Fill="{Binding CellBrush2}" />
<Rectangle Grid.Row="1" Grid.Column="0" Fill="{Binding CellBrush7}" />
<Rectangle Grid.Row="1" Grid.Column="2" Fill="{Binding CellBrush3}" />
<Rectangle Grid.Row="2" Grid.Column="0" Fill="{Binding CellBrush6}" />
<Rectangle Grid.Row="2" Grid.Column="1" Fill="{Binding CellBrush5}" />
<Rectangle Grid.Row="2" Grid.Column="2" Fill="{Binding CellBrush4}" />
</Grid>
</ContentView>
179 changes: 179 additions & 0 deletions playground/EpoxyHello.Maui/Controls/WaitingBlock.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
////////////////////////////////////////////////////////////////////////////
//
// Epoxy - An independent flexible XAML MVVM library for .NET
// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

using Epoxy;
using System;
using System.Threading;

using Microsoft.Maui.Controls;
using System.Runtime.CompilerServices;

namespace EpoxyHello.Maui.Controls;

/// <summary>
/// Interaction logic for WaitingBlock.xaml
/// </summary>
public sealed partial class WaitingBlock : ContentView
{
public static readonly BindableProperty CellBrush0Property =
BindableProperty.Create(nameof(CellBrush0), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush1Property =
BindableProperty.Create(nameof(CellBrush1), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush2Property =
BindableProperty.Create(nameof(CellBrush2), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush3Property =
BindableProperty.Create(nameof(CellBrush3), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush4Property =
BindableProperty.Create(nameof(CellBrush4), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush5Property =
BindableProperty.Create(nameof(CellBrush5), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush6Property =
BindableProperty.Create(nameof(CellBrush6), typeof(Brush), typeof(WaitingBlock), Brush.Gray);
public static readonly BindableProperty CellBrush7Property =
BindableProperty.Create(nameof(CellBrush7), typeof(Brush), typeof(WaitingBlock), Brush.Gray);

private int currentPosition;
private Timer timer;

public WaitingBlock()
{
this.InitializeComponent();
this.BindingContext = this;

this.timer = new Timer(async _ =>
{
if (await UIThread.TryBind())
{
for (var index = 0; index < 8; index++)
{
var brush = index == this.currentPosition ? Brush.Red : Brush.Gray;
{
switch (index)
{
case 0:
this.CellBrush0 = brush;
break;
case 1:
this.CellBrush1 = brush;
break;
case 2:
this.CellBrush2 = brush;
break;
case 3:
this.CellBrush3 = brush;
break;
case 4:
this.CellBrush4 = brush;
break;
case 5:
this.CellBrush5 = brush;
break;
case 6:
this.CellBrush6 = brush;
break;
case 7:
this.CellBrush7 = brush;
break;
}
}
}

if (++this.currentPosition >= 8)
{
this.currentPosition = 0;
}
}
},
null,
Timeout.InfiniteTimeSpan,
Timeout.InfiniteTimeSpan);
}

protected override void OnPropertyChanging([CallerMemberName] string propertyName = null!)
{
if (propertyName == nameof(Parent))
{
if (this.Parent != null)
{
this.timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
}
}
base.OnPropertyChanging(propertyName);
}

protected override void OnPropertyChanged([CallerMemberName] string propertyName = null!)
{
base.OnPropertyChanged(propertyName);
if (propertyName == nameof(Parent))
{
if (this.Parent != null)
{
this.timer.Change(TimeSpan.Zero, TimeSpan.FromMilliseconds(300));
}
}
}

public Brush CellBrush0
{
get => (Brush?)GetValue(CellBrush0Property) ?? Brush.Gray;
set => SetValue(CellBrush0Property, value);
}

public Brush CellBrush1
{
get => (Brush?)GetValue(CellBrush1Property) ?? Brush.Gray;
set => SetValue(CellBrush1Property, value);
}

public Brush CellBrush2
{
get => (Brush?)GetValue(CellBrush2Property) ?? Brush.Gray;
set => SetValue(CellBrush2Property, value);
}

public Brush CellBrush3
{
get => (Brush?)GetValue(CellBrush3Property) ?? Brush.Gray;
set => SetValue(CellBrush3Property, value);
}

public Brush CellBrush4
{
get => (Brush?)GetValue(CellBrush4Property) ?? Brush.Gray;
set => SetValue(CellBrush4Property, value);
}

public Brush CellBrush5
{
get => (Brush?)GetValue(CellBrush5Property) ?? Brush.Gray;
set => SetValue(CellBrush5Property, value);
}

public Brush CellBrush6
{
get => (Brush?)GetValue(CellBrush6Property) ?? Brush.Gray;
set => SetValue(CellBrush6Property, value);
}

public Brush CellBrush7
{
get => (Brush?)GetValue(CellBrush7Property) ?? Brush.Gray;
set => SetValue(CellBrush7Property, value);
}
}
76 changes: 76 additions & 0 deletions playground/EpoxyHello.Maui/EpoxyHello.Maui.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\src\Epoxy.Build\build\Epoxy.Build.props" />

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.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);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>EpoxyHello.Maui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>EpoxyHello.Maui</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.epoxyhello.maui</ApplicationId>

<!-- Versions -->
<!--
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
-->

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Epoxy.Maui\Epoxy.Maui.csproj" />
<ProjectReference Include="..\EpoxyHello.Core\EpoxyHello.Core.csproj" />
</ItemGroup>

<Import Project="..\..\src\Epoxy.Build\build\Epoxy.Build.targets" />
<PropertyGroup>
<EpoxyBuildToolingDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\src\Epoxy.Build\bin\$(Configuration)\$(_EB_PlatformName)'))</EpoxyBuildToolingDir>
</PropertyGroup>
</Project>
Loading

0 comments on commit cc2a287

Please sign in to comment.