Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Add TypedBindings to GesturesExtensions #191

Closed
8 tasks done
brminnick opened this issue Feb 26, 2023 · 1 comment · Fixed by #192
Closed
8 tasks done

[Proposal] Add TypedBindings to GesturesExtensions #191

brminnick opened this issue Feb 26, 2023 · 1 comment · Fixed by #192
Assignees
Labels
approved champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature documentation approved in-progress proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail

Comments

@brminnick
Copy link
Collaborator

brminnick commented Feb 26, 2023

Feature name

Add TypedBindings to GesturesExtensions

Progress tracker

Summary

This proposal augments GesturesExtensions by adding the following APIs that support Typed Bindings

  • .BindClickGesture()
  • .BindSwipeGesture()
  • .BindTapGesture()

Motivation

This is a continuation of #155 adding the ability to use Typed Bindings in CommunityToolkit.Maui.Markup

Detailed Design

public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Expression<Func<TCommandBindingContext, ICommand>> getter,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

public static TGestureElement BindClickGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Func<TCommandBindingContext, ICommand>> getter,
  (Func<TCommandBindingContext, object?>, string)[] handlers,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

public static TGestureElement BindSwipeGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Expression<Func<TCommandBindingContext, ICommand>> getter,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

public static TGestureElement BindSwipeGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Func<TCommandBindingContext, ICommand>> getter,
  (Func<TCommandBindingContext, object?>, string)[] handlers,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

public static TGestureElement BindTapGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Expression<Func<TCommandBindingContext, ICommand>> getter,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

public static TGestureElement BindTapGesture<TGestureElement, TCommandBindingContext, TParameterBindingContext,
  TParameterSource>(
  this TGestureElement gestureElement,
  Func<TCommandBindingContext, ICommand>> getter,
  (Func<TCommandBindingContext, object?>, string)[] handlers,
  Action<TCommandBindingContext, ICommand>? setter = null,
  TCommandBindingContext? source = default,
  BindingMode commandBindingMode = BindingMode.Default,
  Expression<Func<TParameterBindingContext, TParameterSource>>? parameterGetter = null,
  Action<TParameterBindingContext, TParameterSource>? parameterSetter = null,
  BindingMode parameterBindingMode = BindingMode.Default,
  TParameterBindingContext? parameterSource = default,
  int? numberOfClicksRequired = null) where TGestureElement : BindableObject, IGestureRecognizers;

Usage Syntax

new Label().BindTapGesture(static (ViewModel vm) => vm.TapGestureCommand, mode: BindingMode.OneWay)

Drawbacks

None

Alternatives

The following APIs currently exist without support for Typed Bindings (require reflection):

  • BindClickGesture
  • BindSwipeGesture
  • BindTapGesture

Unresolved Questions

None

@brminnick brminnick added proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail new labels Feb 26, 2023
@brminnick brminnick added the champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature label Feb 26, 2023
@brminnick brminnick self-assigned this Feb 26, 2023
@ghost ghost removed the new label Feb 26, 2023
@brminnick brminnick added the needs discussion The team will aim to discuss this at the next monthly standup label Feb 28, 2023
@ghost ghost added approved help wanted This proposal has been approved and is ready to be implemented labels Mar 2, 2023
@brminnick brminnick added in-progress and removed help wanted This proposal has been approved and is ready to be implemented labels Mar 2, 2023
@brminnick brminnick removed the needs discussion The team will aim to discuss this at the next monthly standup label Apr 3, 2023
@ghost ghost reopened this May 18, 2023
@ghost
Copy link

ghost commented May 18, 2023

Reopening Proposal.

Only Proposals moved to the Closed Project Column and Completed Project Column can be closed.

@ghost ghost closed this as completed Jun 1, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature documentation approved in-progress proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant