Skip to content

Commit

Permalink
Fix TapGestureRecognizer not working
Browse files Browse the repository at this point in the history
  • Loading branch information
muak committed Dec 5, 2023
1 parent abc4b47 commit daa719a
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 49 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
1 change: 1 addition & 0 deletions Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static MauiApp CreateMauiApp()
containerRegistry.RegisterForNavigation<ContentPage>();
containerRegistry.RegisterForNavigation<ListPage, ListViewModel>();
containerRegistry.RegisterForNavigation<CustomHeaderPage, CustomHeaderViewModel>();
containerRegistry.RegisterForNavigation<TapSurveyPage, TapSurveyViewModel>();
})
.OnAppStart(async(container, navigation) =>
{
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)
{
}
}
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
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/SettingsView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<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
Fix TapGestureRecognizer issue
</PackageReleaseNotes>
<PackageTags>MAUI TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop</PackageTags>
</PropertyGroup>
Expand Down
44 changes: 0 additions & 44 deletions nuget/AzurePipelines.nuspec

This file was deleted.

0 comments on commit daa719a

Please sign in to comment.