Skip to content

Commit

Permalink
Upgrade .NET8
Browse files Browse the repository at this point in the history
  • Loading branch information
muak committed Nov 16, 2023
1 parent 42febaf commit abc4b47
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 52 deletions.
22 changes: 4 additions & 18 deletions Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public static MauiApp CreateMauiApp()
containerRegistry.RegisterForNavigation<ListPage, ListViewModel>();
containerRegistry.RegisterForNavigation<CustomHeaderPage, CustomHeaderViewModel>();
})
.OnAppStart(navigationService =>
.OnAppStart(async(container, navigation) =>
{
navigationService.CreateBuilder()
await navigation.CreateBuilder()
.AddSegment(nameof(MyNavigationPage))
.AddSegment<MainViewModel>()
.Navigate();
.NavigateAsync();
})
.OnInitialized(container =>
{
Expand All @@ -46,21 +46,7 @@ public static MauiApp CreateMauiApp()
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

ViewModelLocationProvider2.SetDefaultViewTypeToViewModelTypeResolver(viewType =>
{
// Hoge -> HogeViewModel
// HogePage -> HogeViewModel
// HogeView -> HogeViewModel
var viewName = viewType.FullName;
viewName = viewName.Replace(".Views.", ".ViewModels.");
viewName = viewName.EndsWith("Page") ? viewName.Replace("Page", "") : viewName;
var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
var suffix = viewName.EndsWith("View") ? "Model" : "ViewModel";
var viewModelName = String.Format(CultureInfo.InvariantCulture, "{0}{1}, {2}", viewName, suffix, viewAssemblyName);
return Type.GetType(viewModelName);
});
});

return builder.Build();
}
Expand Down
15 changes: 8 additions & 7 deletions Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Sample</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -31,22 +31,22 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchLink>None</MtouchLink>
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<!--<CodesignProvision>自動</CodesignProvision>-->
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-maccatalyst|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
<CodesignKey>Mac Developer</CodesignKey>
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -76,8 +76,9 @@
<None Remove="Resources\Images\ic_close.svg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Prism.DryIoc.Maui" Version="8.1.273-pre" />
<PackageReference Include="ReactiveProperty" Version="8.1.2" />
<PackageReference Include="Prism.DryIoc.Maui" Version="9.0.271-pre" />
<PackageReference Include="ReactiveProperty" Version="9.3.4" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
Expand Down
25 changes: 13 additions & 12 deletions SettingsView/Platforms/Android/Cells/CellBaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace AiForms.Settings.Platforms.Droid;
/// Cell base view.
/// </summary>
[Android.Runtime.Preserve(AllMembers = true)]
public class CellBaseView : ARelativeLayout
public class CellBaseView : ARelativeLayout, IImageSourcePartSetter
{
CellBase _cell;
public CellBase Cell
Expand Down Expand Up @@ -81,8 +81,12 @@ public CellBase Cell
/// Gets the hint label.
/// </summary>
/// <value>The hint label.</value>
public TextView HintLabel { get; private set; }

public TextView HintLabel { get; private set; }

IElementHandler IImageSourcePartSetter.Handler => Cell.Handler;

IImageSourcePart IImageSourcePartSetter.ImageSourcePart => Cell;

protected Lazy<IFontManager> _fontManager;
ImageSourcePartLoader _imageLoader;
/// <summary>
Expand Down Expand Up @@ -554,18 +558,18 @@ internal void UpdateIcon(bool forceLoad = false)
{
IconView.Visibility = ViewStates.Visible;

_imageLoader = new ImageSourcePartLoader(Cell.Handler, () => Cell, OnSetImageSource);
_imageLoader = new ImageSourcePartLoader(this);
_imageLoader?.UpdateImageSourceAsync();
}
else
{
IconView.Visibility = ViewStates.Gone;
}
}

private void OnSetImageSource(Drawable drawable)
}

void IImageSourcePartSetter.SetImageSource(Drawable platformImage)
{
IconView?.SetImageDrawable(drawable);
IconView?.SetImageDrawable(platformImage);
}

Bitmap CreateRoundImage(Bitmap image)
Expand Down Expand Up @@ -653,9 +657,6 @@ protected override void Dispose(bool disposing)
Background = null;
}
base.Dispose(disposing);
}



}
}

16 changes: 10 additions & 6 deletions SettingsView/Platforms/iOS/Cells/CellBaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace AiForms.Settings.Platforms.iOS;
/// Cell base view.
/// </summary>
[Foundation.Preserve(AllMembers = true)]
public class CellBaseView : UITableViewCell
public class CellBaseView : UITableViewCell, IImageSourcePartSetter
{
/// <summary>
/// Gets the hint label.
Expand Down Expand Up @@ -83,6 +83,9 @@ public CellBase Cell
/// <value>The content stack.</value>
protected UIStackView ContentStack { get; private set; }

IElementHandler IImageSourcePartSetter.Handler => Cell.Handler;
IImageSourcePart IImageSourcePartSetter.ImageSourcePart => Cell;

protected UIStackView StackH;
protected UIStackView StackV;

Expand Down Expand Up @@ -505,18 +508,18 @@ internal void UpdateIcon()
//hide IconView because UIStackView Distribution won't work when a image isn't set.
IconView.Hidden = false;

_imageLoader = new ImageSourcePartLoader(Cell.Handler, () => Cell, OnSetImageSource);
_imageLoader.UpdateImageSourceAsync();
}
_imageLoader = new ImageSourcePartLoader(this);
_imageLoader.UpdateImageSourceAsync();
}
else
{
IconView.Hidden = true;
}
}

private void OnSetImageSource(UIImage image)
void IImageSourcePartSetter.SetImageSource(UIImage platformImage)
{
IconView.Image = image;
IconView.Image = platformImage;
SetNeedsLayout();
}

Expand Down Expand Up @@ -754,5 +757,6 @@ protected virtual void SetUpContentView()
}
}


}

2 changes: 1 addition & 1 deletion SettingsView/Platforms/iOS/Extensions/DisposeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AiForms.Settings.Platforms.iOS;

public static class DisposeHelpers
{
static Type ModalWrapper = typeof(Element).Assembly.GetType("Microsoft.Maui.Controls.Platform.ModalWrapper");
static Type ModalWrapper = typeof(Element).Assembly.GetType("Microsoft.Maui.Controls.Platform.ControlsModalWrapper");
static MethodInfo ModalWrapperDispose = ModalWrapper.GetMethod("Dispose");
static MethodInfo ElementDescendants = typeof(Element).GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(x => x.Name == "Descendants" && !x.IsGenericMethod);

Expand Down
2 changes: 1 addition & 1 deletion SettingsView/Section.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static void ItemsChanged(BindableObject bindable, object oldValue, object newVal
}
catch (Exception e)
{
throw e;
throw;
}

var oldObservableCollection = oldValue as INotifyCollectionChanged;
Expand Down
2 changes: 1 addition & 1 deletion SettingsView/SettingsView.DefineProperites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ static void ItemsChanged(BindableObject bindable, object oldValue, object newVal
}
catch (Exception e)
{
throw e;
throw;
}


Expand Down
29 changes: 23 additions & 6 deletions SettingsView/SettingsView.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<UseMaui>true</UseMaui>
<SingleProject>false</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">27.0</SupportedOSPlatformVersion>
<RootNamespace>AiForms.Settings</RootNamespace>

<PackageId>AiForms.Maui.SettingsView</PackageId>
<Authors>kamu</Authors>
<Company>kamu</Company>
<Product>SettingsView for .NET MAUI</Product>
<PackageProjectUrl>https://github.com/muak/AiForms.Maui.SettingsView</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/muak/AiForms.Maui.SettingsView/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/muak/AiForms.Maui.SettingsView/master/images/icon.png</PackageIconUrl>
<Description>This is a flexible TableView specialized in settings for Android / iOS.
There are various cells such as (LabelCell,ButtonCell,CommandCell,SwitchCell,CheckboxCell,RadioCell,PickerCell,EntryCell,NumberPickerCell,TimePickerCell,DatePickerCell,CustomCell)</Description>
<PackageReleaseNotes>
Supported .NET8
</PackageReleaseNotes>
<PackageTags>MAUI TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<EnableCodeSigning>False</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
</PropertyGroup>
Expand All @@ -24,7 +38,7 @@
<DebugType>pdbonly</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<EnableCodeSigning>false</EnableCodeSigning>
</PropertyGroup>
Expand All @@ -42,19 +56,19 @@
<None Include="**\iOS\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<Compile Include="**\**\*.Net.cs" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net7.0-android')) == true">
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-android')) == true">
<Compile Include="**\**\*.Android.cs" />
<Compile Include="**\Android\**\*.cs" />
<AndroidResource Include="**\Resources\**\*.axml" Generator="MSBuild:UpdateGeneratedFiles" />
<AndroidResource Include="**\Resources\**\*.xml" Generator="MSBuild:UpdateGeneratedFiles" />
<AndroidResource Include="**\Resources\**\*.png" Generator="MSBuild:UpdateGeneratedFiles" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net7.0-ios')) == true OR $(TargetFramework.StartsWith('net7.0-maccatalyst')) == true">
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) == true OR $(TargetFramework.StartsWith('net8.0-maccatalyst')) == true">
<Compile Include="**\**\*.iOS.cs" />
<Compile Include="**\iOS\**\*.cs" />
</ItemGroup>
Expand Down Expand Up @@ -126,4 +140,7 @@
<AndroidResource Include="Platforms\Android\Resources\values\styles.xml" />
<AndroidResource Include="Platforms\Android\Resources\values\attrs.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
</ItemGroup>
</Project>

0 comments on commit abc4b47

Please sign in to comment.