From daa719a2de32a3a7f6805ad65e277fe6d6cc2e59 Mon Sep 17 00:00:00 2001 From: Satoshi Nakamura Date: Tue, 5 Dec 2023 20:02:16 +0900 Subject: [PATCH] Fix TapGestureRecognizer not working --- AiForms.Maui.SettingsView.sln | 3 - Sample/MauiProgram.cs | 1 + Sample/ViewModels/MainViewModel.cs | 2 +- Sample/ViewModels/TapSurveyViewModel.cs | 10 +++ Sample/Views/TapSurveyPage.xaml | 67 +++++++++++++++++++ Sample/Views/TapSurveyPage.xaml.cs | 29 ++++++++ .../Platforms/Android/FormsViewContainer.cs | 5 ++ .../Android/HeaderFooterContainer.cs | 5 ++ .../Platforms/iOS/Cells/CustomCellContent.cs | 10 +++ .../Platforms/iOS/CustomHeaderFooterView.cs | 5 ++ SettingsView/SettingsView.csproj | 2 +- nuget/AzurePipelines.nuspec | 44 ------------ 12 files changed, 134 insertions(+), 49 deletions(-) create mode 100644 Sample/ViewModels/TapSurveyViewModel.cs create mode 100644 Sample/Views/TapSurveyPage.xaml create mode 100644 Sample/Views/TapSurveyPage.xaml.cs delete mode 100644 nuget/AzurePipelines.nuspec diff --git a/AiForms.Maui.SettingsView.sln b/AiForms.Maui.SettingsView.sln index 41cef18..a55f8de 100644 --- a/AiForms.Maui.SettingsView.sln +++ b/AiForms.Maui.SettingsView.sln @@ -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 diff --git a/Sample/MauiProgram.cs b/Sample/MauiProgram.cs index 648a686..aa11cc9 100644 --- a/Sample/MauiProgram.cs +++ b/Sample/MauiProgram.cs @@ -25,6 +25,7 @@ public static MauiApp CreateMauiApp() containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); }) .OnAppStart(async(container, navigation) => { diff --git a/Sample/ViewModels/MainViewModel.cs b/Sample/ViewModels/MainViewModel.cs index 52b98bf..f4f59cb 100644 --- a/Sample/ViewModels/MainViewModel.cs +++ b/Sample/ViewModels/MainViewModel.cs @@ -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(_ => diff --git a/Sample/ViewModels/TapSurveyViewModel.cs b/Sample/ViewModels/TapSurveyViewModel.cs new file mode 100644 index 0000000..482a02a --- /dev/null +++ b/Sample/ViewModels/TapSurveyViewModel.cs @@ -0,0 +1,10 @@ +using System; +namespace Sample.ViewModels; + +public class TapSurveyViewModel:BindableBase +{ + public TapSurveyViewModel() + { + } +} + diff --git a/Sample/Views/TapSurveyPage.xaml b/Sample/Views/TapSurveyPage.xaml new file mode 100644 index 0000000..8f8d201 --- /dev/null +++ b/Sample/Views/TapSurveyPage.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/Views/TapSurveyPage.xaml.cs b/Sample/Views/TapSurveyPage.xaml.cs new file mode 100644 index 0000000..bf85057 --- /dev/null +++ b/Sample/Views/TapSurveyPage.xaml.cs @@ -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) + { + } +} diff --git a/SettingsView/Platforms/Android/FormsViewContainer.cs b/SettingsView/Platforms/Android/FormsViewContainer.cs index d2b0197..177229b 100644 --- a/SettingsView/Platforms/Android/FormsViewContainer.cs +++ b/SettingsView/Platforms/Android/FormsViewContainer.cs @@ -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; diff --git a/SettingsView/Platforms/Android/HeaderFooterContainer.cs b/SettingsView/Platforms/Android/HeaderFooterContainer.cs index 2260e64..4cf4c49 100644 --- a/SettingsView/Platforms/Android/HeaderFooterContainer.cs +++ b/SettingsView/Platforms/Android/HeaderFooterContainer.cs @@ -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; diff --git a/SettingsView/Platforms/iOS/Cells/CustomCellContent.cs b/SettingsView/Platforms/iOS/Cells/CustomCellContent.cs index 5f24125..1dde962 100644 --- a/SettingsView/Platforms/iOS/Cells/CustomCellContent.cs +++ b/SettingsView/Platforms/iOS/Cells/CustomCellContent.cs @@ -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; @@ -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()); } diff --git a/SettingsView/Platforms/iOS/CustomHeaderFooterView.cs b/SettingsView/Platforms/iOS/CustomHeaderFooterView.cs index 70a319b..278f44a 100644 --- a/SettingsView/Platforms/iOS/CustomHeaderFooterView.cs +++ b/SettingsView/Platforms/iOS/CustomHeaderFooterView.cs @@ -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; diff --git a/SettingsView/SettingsView.csproj b/SettingsView/SettingsView.csproj index a1045be..9d99eba 100644 --- a/SettingsView/SettingsView.csproj +++ b/SettingsView/SettingsView.csproj @@ -20,7 +20,7 @@ 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) - Supported .NET8 + Fix TapGestureRecognizer issue MAUI TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop diff --git a/nuget/AzurePipelines.nuspec b/nuget/AzurePipelines.nuspec deleted file mode 100644 index 5a9d6c6..0000000 --- a/nuget/AzurePipelines.nuspec +++ /dev/null @@ -1,44 +0,0 @@ - - - - AiForms.Maui.SettingsView - 0.1.0-pre - SettingsView for .NET MAUI - kamu - kamu - https://github.com/muak/AiForms.Maui.SettingsView - https://github.com/muak/AiForms.Maui.SettingsView/blob/master/LICENSE.txt - https://raw.githubusercontent.com/muak/AiForms.Maui.SettingsView/master/images/icon.png - false - 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) - - - -- Fix Android CustomCell Size -- Update .NET 7.0 -- Fix PickerCell SingleSelectMode not working. - - MAUI TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop - en-US - - - - - - - - - - - - - - - - - - - - -