Skip to content

Commit

Permalink
Merge pull request #557 from Softeq/feature/switch-PH1-to-net8
Browse files Browse the repository at this point in the history
Feature/switch ph1 to net8
  • Loading branch information
pavel-leonenko authored Jul 18, 2024
2 parents 1043521 + 122722d commit 1fe8223
Show file tree
Hide file tree
Showing 428 changed files with 5,592 additions and 6,107 deletions.
11 changes: 10 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<LangVersion>8.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<DebugType>portable</DebugType>
<MauiVersion>8.0.21</MauiVersion>
</PropertyGroup>

<!-- Assembly Info -->
<PropertyGroup>
<Product>XToolkit</Product>
<Company>Softeq Development Corporation</Company>
<Copyright>Copyright © 2024 Softeq Development Corporation</Copyright>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Softeq
Copyright (c) 2024 Softeq

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ Common | [![Softeq.XToolkit.Common](https://buildstats.info/nuget/Softeq.XToo
Bindings | [![Softeq.XToolkit.Bindings](https://buildstats.info/nuget/Softeq.XToolkit.Bindings?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.Bindings)
Permissions | [![Softeq.XToolkit.Permissions](https://buildstats.info/nuget/Softeq.XToolkit.Permissions?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.Permissions)
PushNotifications | [![Softeq.XToolkit.PushNotifications](https://buildstats.info/nuget/Softeq.XToolkit.PushNotifications?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.PushNotifications)
Remote | [![Softeq.XToolkit.Remote](https://buildstats.info/nuget/Softeq.XToolkit.Remote?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.Remote)
WhiteLabel | [![Softeq.XToolkit.WhiteLabel](https://buildstats.info/nuget/Softeq.XToolkit.WhiteLabel?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.WhiteLabel)
WhiteLabel.Essentials | [![Softeq.XToolkit.WhiteLabel.Essentials](https://buildstats.info/nuget/Softeq.XToolkit.WhiteLabel.Essentials?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.WhiteLabel.Essentials)
WhiteLabel.Forms | [![Softeq.XToolkit.WhiteLabel.Forms](https://buildstats.info/nuget/Softeq.XToolkit.WhiteLabel.Forms?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.WhiteLabel.Forms)
Remote | [![Softeq.XToolkit.Remote](https://buildstats.info/nuget/Softeq.XToolkit.Remote?includePreReleases=true)](https://www.nuget.org/packages/Softeq.XToolkit.Remote)

## Documentation

Expand Down
12 changes: 12 additions & 0 deletions Softeq.XToolkit.Bindings.Droid/Bindable/BindableViewHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AndroidX.RecyclerView.Widget;
using Softeq.XToolkit.Bindings.Abstract;
using Softeq.XToolkit.Bindings.Extensions;
using Softeq.XToolkit.Common.Disposables;
using Softeq.XToolkit.Common.Weak;

#nullable disable
Expand All @@ -16,10 +17,13 @@ namespace Softeq.XToolkit.Bindings.Droid.Bindable
public abstract class BindableViewHolder<TViewModel>
: RecyclerView.ViewHolder, IBindableViewHolder
{
private readonly DisposableSubscriptionsComponent _subscriptionsComponent;

private IDisposable _itemViewClickSubscription;

protected BindableViewHolder(View itemView) : base(itemView)
{
_subscriptionsComponent = new DisposableSubscriptionsComponent(SetCommandsWithDisposing);
}

public event EventHandler ItemClicked;
Expand Down Expand Up @@ -63,11 +67,19 @@ protected virtual void OnItemViewClick(object sender, EventArgs e)

public virtual void DoAttachBindings()
{
_subscriptionsComponent.CreateSubscriptions();
}

public virtual void DoDetachBindings()
{
this.DetachBindings();

_subscriptionsComponent.DisposeSubscriptions();
}

protected virtual IEnumerable<IDisposable> SetCommandsWithDisposing()
{
return [];
}
}
}
39 changes: 27 additions & 12 deletions Softeq.XToolkit.Bindings.Droid/DroidBindingFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Windows.Input;
using Android.Views;
using Android.Widget;
using Softeq.XToolkit.Common.Disposables;
using Softeq.XToolkit.Common.Threading;

namespace Softeq.XToolkit.Bindings.Droid
Expand Down Expand Up @@ -147,18 +148,20 @@ public override Delegate GetCommandHandler<T>(
}

/// <inheritdoc />
public override void HandleCommandCanExecute<T>(
public override IDisposable HandleCommandCanExecute<T>(
object element,
ICommand command,
Binding<T, T>? commandParameterBinding)
{
if (element is View view)
{
HandleViewEnabled(view, command, commandParameterBinding);
return HandleViewEnabled(view, command, commandParameterBinding);
}

return Disposable.Create(() => { });
}

private static void HandleViewEnabled<T>(
private static IDisposable HandleViewEnabled<T>(
View view,
ICommand command,
Binding<T, T>? commandParameterBinding)
Expand All @@ -171,20 +174,32 @@ private static void HandleViewEnabled<T>(
() => view.Enabled = command.CanExecute(commandParameter));

// set by CanExecute
command.CanExecuteChanged += (s, args) =>
{
Execute.BeginOnUIThread(
() => view.Enabled = command.CanExecute(commandParameter));
};
command.CanExecuteChanged += OnCommandCanExecuteChanged;

// set by bindable command parameter
if (commandParameterBinding != null)
{
commandParameterBinding.ValueChanged += (s, args) =>
commandParameterBinding.ValueChanged += OnCommandParameterBindingValueChanged;
}

return Disposable.Create(() =>
{
if (commandParameterBinding != null)
{
Execute.BeginOnUIThread(
() => view.Enabled = command.CanExecute(commandParameterBinding.Value));
};
commandParameterBinding.ValueChanged -= OnCommandParameterBindingValueChanged;
}

command.CanExecuteChanged -= OnCommandCanExecuteChanged;
});

void OnCommandCanExecuteChanged(object? s, EventArgs args)
{
Execute.BeginOnUIThread(() => view.Enabled = command.CanExecute(commandParameter));
}

void OnCommandParameterBindingValueChanged(object? s, EventArgs args)
{
Execute.BeginOnUIThread(() => view.Enabled = command.CanExecute(commandParameterBinding.Value));
}
}
}
Expand Down
31 changes: 0 additions & 31 deletions Softeq.XToolkit.Bindings.Droid/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,84 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2B4A678B-63B4-49DB-99B1-BFE7793110C4}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Softeq.XToolkit.Bindings.Droid</RootNamespace>
<AssemblyName>Softeq.XToolkit.Bindings.Droid</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
<TargetFramework>net8.0-android34.0</TargetFramework>
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.5" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<ProjectReference Include="..\Softeq.XToolkit.Common\Softeq.XToolkit.Common.csproj" />
<ProjectReference Include="..\Softeq.XToolkit.Common.Droid\Softeq.XToolkit.Common.Droid.csproj" />
<ProjectReference Include="..\Softeq.XToolkit.Bindings\Softeq.XToolkit.Bindings.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="DroidBinding.cs" />
<Compile Include="DroidBindingFactory.cs" />
<Compile Include="ObservableAdapter.cs" />
<Compile Include="ObservableAdapterExtended.cs" />
<Compile Include="ObservableGroupAdapter.cs" />
<Compile Include="ObservableRecyclerGroupViewAdapter.cs" />
<Compile Include="ObservableRecyclerViewAdapter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Bindable\IBindableViewHolder.cs" />
<Compile Include="Bindable\BindableViewHolder.cs" />
<Compile Include="Bindable\BindableRecyclerViewAdapter.cs" />
<Compile Include="Bindable\BindableViewHolderLayoutAttribute.cs" />
<Compile Include="Bindable\ItemType.cs" />
<Compile Include="Bindable\FlatItem.cs" />
<Compile Include="Handlers\DroidRecyclerObservableKeyGroupCollectionHandler.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Softeq.XToolkit.Bindings\Softeq.XToolkit.Bindings.csproj">
<Project>{0F1F09A8-9CDB-4933-AA1B-898AB43D394C}</Project>
<Name>Softeq.XToolkit.Bindings</Name>
</ProjectReference>
<ProjectReference Include="..\Softeq.XToolkit.Common.Droid\Softeq.XToolkit.Common.Droid.csproj">
<Project>{18d3fdc1-b0a1-401e-87f2-1c43034e610c}</Project>
<Name>Softeq.XToolkit.Common.Droid</Name>
</ProjectReference>
<ProjectReference Include="..\Softeq.XToolkit.Common\Softeq.XToolkit.Common.csproj">
<Project>{24588814-B93D-4528-8917-9C2A3C4E85CA}</Project>
<Name>Softeq.XToolkit.Common</Name>
</ProjectReference>
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.5" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
39 changes: 27 additions & 12 deletions Softeq.XToolkit.Bindings.iOS/AppleBindingFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Windows.Input;
using Softeq.XToolkit.Common.Disposables;
using UIKit;

namespace Softeq.XToolkit.Bindings.iOS
Expand Down Expand Up @@ -98,18 +99,20 @@ public override Binding<TSource, TTarget> CreateBinding<TSource, TTarget>(
}

/// <inheritdoc />
public override void HandleCommandCanExecute<T>(
public override IDisposable HandleCommandCanExecute<T>(
object element,
ICommand command,
Binding<T, T>? commandParameterBinding)
{
if (element is UIControl control)
{
HandleControlEnabled(control, command, commandParameterBinding);
return HandleControlEnabled(control, command, commandParameterBinding);
}

return Disposable.Create(() => { });
}

private static void HandleControlEnabled<T>(
private static IDisposable HandleControlEnabled<T>(
UIControl control,
ICommand command,
Binding<T, T>? commandParameterBinding)
Expand All @@ -122,20 +125,32 @@ private static void HandleControlEnabled<T>(
() => control.Enabled = command.CanExecute(commandParameter));

// set by CanExecute
command.CanExecuteChanged += (s, args) =>
{
control.BeginInvokeOnMainThread(
() => control.Enabled = command.CanExecute(commandParameter));
};
command.CanExecuteChanged += OnCommandCanExecuteChanged;

// set by bindable command parameter
if (commandParameterBinding != null)
{
commandParameterBinding.ValueChanged += (s, args) =>
commandParameterBinding.ValueChanged += OnCommandParameterBindingValueChanged;
}

return Disposable.Create(() =>
{
if (commandParameterBinding != null)
{
control.BeginInvokeOnMainThread(
() => control.Enabled = command.CanExecute(commandParameterBinding.Value));
};
commandParameterBinding.ValueChanged -= OnCommandParameterBindingValueChanged;
}

command.CanExecuteChanged -= OnCommandCanExecuteChanged;
});

void OnCommandCanExecuteChanged(object? s, EventArgs args)
{
control.BeginInvokeOnMainThread(() => control.Enabled = command.CanExecute(commandParameter));
}

void OnCommandParameterBindingValueChanged(object? s, EventArgs args)
{
control.BeginInvokeOnMainThread(() => control.Enabled = command.CanExecute(commandParameterBinding.Value));
}
}
}
Expand Down
Loading

0 comments on commit 1fe8223

Please sign in to comment.