Skip to content

Commit

Permalink
Merge pull request #319 from Sveske-Juice/main
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamMorrow authored Nov 18, 2024
2 parents 470fbbc + 69ef7da commit 6262ecd
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions LiftLog.Ui/Shared/Presentation/PotentialSetAdditionalActions.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<div class="flex flex-wrap gap-2 justify-center mb-2 mx-4">
@GetRepButton(@<span>-</span>,
() => OnSelectRepCount.InvokeAsync(null),
"bg-secondary-container text-on-secondary-container")
@GetRepButton(@<span>-</span>, null, "bg-secondary-container text-on-secondary-container")
@for(int i = 0; i < MaxReps + 1; i++)
{
var reps = i;
@GetRepButton(@<span class="font-bold">@reps</span>,
() => OnSelectRepCount.InvokeAsync(reps),
"bg-primary-container text-on-primary-container");
@GetRepButton(@<span class="font-bold">@reps</span>,reps, "bg-primary-container text-on-primary-container");
}
</div>
<div class="flex flex-grow gap-2 justify-center">

@for(int i = MaxReps+1; i < MaxReps + 4; i++)
{
var reps = i;
@GetRepButton(@<span class="font-bold">@reps</span>,
() => OnSelectRepCount.InvokeAsync(reps),
"bg-secondary-container text-on-secondary-container");
@GetRepButton(@<span class="font-bold">@reps</span>, reps, "bg-secondary-container text-on-secondary-container");
}
</div>

Expand All @@ -31,12 +25,31 @@

[EditorRequired] [Parameter] public EventCallback OnDeleteSet { get; set; }

private int? lastPointerDownReps = int.MinValue;

private RenderFragment GetRepButton(RenderFragment childContent, Action onClick, string color)

private RenderFragment GetRepButton(RenderFragment childContent, int? reps, string color)
{
void OnPointerDown(PointerEventArgs e)
{
lastPointerDownReps = reps;
}
// On iOS the click event is triggered when the user lifts their finger after the dialog is opened
// This is a workaround to prevent the click event from being triggered until the user has actually tapped the button
async Task OnClick()
{
if (lastPointerDownReps != reps)
{
return;
}
lastPointerDownReps = int.MinValue;
await OnSelectRepCount.InvokeAsync(reps);
}
return @<div class="flex flex-col items-center relative">
<button
@onpointerdown="onClick"
@key="reps ?? int.MaxValue"
@onclick="OnClick"
@onpointerdown="OnPointerDown"
class="
repcount
flex-shrink-0
Expand Down

0 comments on commit 6262ecd

Please sign in to comment.