Skip to content

Commit

Permalink
Merge pull request #20 from muak/dev/net8
Browse files Browse the repository at this point in the history
Dev/net8
  • Loading branch information
muak committed Jan 25, 2024
2 parents 2371092 + daa719a commit 61164a2
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 100 deletions.
3 changes: 0 additions & 3 deletions AiForms.Maui.SettingsView.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsView", "SettingsView\SettingsView.csproj", "{B73793A3-0AA7-4086-8F2B-A3CE3A5E6BE1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{547F99F7-22F8-4C24-A613-9F088A9F2BD3}"
ProjectSection(SolutionItems) = preProject
nuget\AzurePipelines.nuspec = nuget\AzurePipelines.nuspec
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
23 changes: 5 additions & 18 deletions Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ public static MauiApp CreateMauiApp()
containerRegistry.RegisterForNavigation<ContentPage>();
containerRegistry.RegisterForNavigation<ListPage, ListViewModel>();
containerRegistry.RegisterForNavigation<CustomHeaderPage, CustomHeaderViewModel>();
containerRegistry.RegisterForNavigation<TapSurveyPage, TapSurveyViewModel>();
})
.OnAppStart(navigationService =>
.OnAppStart(async(container, navigation) =>
{
navigationService.CreateBuilder()
await navigation.CreateBuilder()
.AddSegment(nameof(MyNavigationPage))
.AddSegment<MainViewModel>()
.Navigate();
.NavigateAsync();
})
.OnInitialized(container =>
{
Expand All @@ -46,21 +47,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
2 changes: 1 addition & 1 deletion Sample/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MainViewModel(INavigationService navigationService)
//Description.Value += "01234567890";
//await navigationService.NavigateAsync("ListPage");
await navigationService.NavigateAsync("CustomHeaderPage");
await navigationService.NavigateAsync("TapSurveyPage");
});

AddContentCommand.Subscribe(_ =>
Expand Down
10 changes: 10 additions & 0 deletions Sample/ViewModels/TapSurveyViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
namespace Sample.ViewModels;

public class TapSurveyViewModel:BindableBase
{
public TapSurveyViewModel()
{
}
}

67 changes: 67 additions & 0 deletions Sample/Views/TapSurveyPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:sv="clr-namespace:AiForms.Settings;assembly=SettingsView"
x:Class="Sample.Views.TapSurveyPage"
Title="TapSurveyPage">
<sv:SettingsView>

<sv:Section>
<sv:Section.HeaderView>
<HorizontalStackLayout>
<Label Text="Header" HeightRequest="44">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_3" />
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout>
</sv:Section.HeaderView>

<sv:Section.FooterView>
<HorizontalStackLayout>
<Label Text="Footer" HeightRequest="44">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_4" />
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout>
</sv:Section.FooterView>

<sv:CustomCell IsSelectable="True">

<Grid ColumnDefinitions="*,*,*">
<StackLayout Grid.Column="0">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</StackLayout.GestureRecognizers>
<Image />
<Label Text="A"
FontAttributes="Bold"
HorizontalOptions="Center"/>
</StackLayout>
<StackLayout Grid.Column="1">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1" />
</StackLayout.GestureRecognizers>
<Image />
<Label Text="B"
FontAttributes="Bold"
HorizontalOptions="Center"/>
</StackLayout>
<StackLayout Grid.Column="2">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_2" />
</StackLayout.GestureRecognizers>
<Image />
<Label Text="C"
FontAttributes="Bold"
HorizontalOptions="Center"/>
</StackLayout>
</Grid>

</sv:CustomCell>

</sv:Section>

</sv:SettingsView>
</ContentPage>
29 changes: 29 additions & 0 deletions Sample/Views/TapSurveyPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Sample.Views;

public partial class TapSurveyPage : ContentPage
{
public TapSurveyPage()
{
InitializeComponent();
}

void TapGestureRecognizer_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
}

void TapGestureRecognizer_Tapped_1(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
}

void TapGestureRecognizer_Tapped_2(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
}

void TapGestureRecognizer_Tapped_3(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
}

void TapGestureRecognizer_Tapped_4(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
}
}
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);
}



}
}

5 changes: 5 additions & 0 deletions SettingsView/Platforms/Android/FormsViewContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public void DisconnectHandler()

public void UpdateCell(View view)
{
// Workaround GestureRecognizer bug
// TODO: if fix this issue, remove the following code.
// https://github.com/dotnet/maui/issues/17948
view.Parent = Application.Current.MainPage;

if (_contentView == view && !CustomCell.IsForceLayout)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions SettingsView/Platforms/Android/HeaderFooterContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public void UpdateIsEnabled()

public void UpdateCell(View view)
{
// Workaround GestureRecognizer bug
// TODO: if fix this issue, remove the following code.
// https://github.com/dotnet/maui/issues/17948
view.Parent = Application.Current.MainPage;

if (_contentView != null)
{
_contentView.PropertyChanged -= CellPropertyChanged;
Expand Down
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()
}
}


}

10 changes: 10 additions & 0 deletions SettingsView/Platforms/iOS/Cells/CustomCellContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ protected virtual void UpdateIsEnabled()

public virtual void UpdateCell(View newCell, UITableView tableView)
{
// Workaround GestureRecognizer bug
// TODO: if fix this issue, remove the following code.
// https://github.com/dotnet/maui/issues/17948
newCell.Parent = Application.Current.MainPage;

_tableView = tableView;

var oldCell = _virtualCell;
Expand Down Expand Up @@ -149,6 +154,11 @@ public virtual void UpdateCell(View newCell, UITableView tableView)
}
else
{
// Workaround GestureRecognizer bug
// TODO: if fix this issue, remove the following code.
// https://github.com/dotnet/maui/issues/17948
newCell.Parent = Application.Current.MainPage;

// If Handler is not generated, generate it.
handler = newCell.ToHandler(newCell.FindMauiContext());
}
Expand Down
5 changes: 5 additions & 0 deletions SettingsView/Platforms/iOS/CustomHeaderFooterView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ protected virtual void UpdateIsEnabled()

public virtual void UpdateCell(View newCell,UITableView tableView)
{
// Workaround GestureRecognizer bug
// TODO: if fix this issue, remove the following code.
// https://github.com/dotnet/maui/issues/17948
newCell.Parent = Application.Current.MainPage;

if (_virtualCell == newCell)
{
return;
Expand Down
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
Loading

0 comments on commit 61164a2

Please sign in to comment.