Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Oct 22, 2024
1 parent 7ff62c7 commit a501d12
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Masa.Blazor/Components/DigitalClock/MDigitalClock.razor
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@
}
}

<li class="@_itemModifierBuilder.Add(active).Add(adjacent).Add(Disabled)"
@onclick="() => HandleOnTimeClick(time)">
@ItemContentRenderFragment(time.ToString(Format == TimeFormat.Hr24 ? "HH:mm" : "hh:mm tt"), active)
</li>
@GenSingleItem(active, adjacent, Disabled, time)
}
}
else
Expand All @@ -109,6 +106,7 @@
var index = i;
var time = _singleSectionItems[index];

var disabled = Disabled || IsAllowedTimeCallback?.Invoke(time) is false;
var active = time == InternalTime;
var adjacent = false;
if (!haveGotActive)
Expand All @@ -124,10 +122,7 @@
}
}

<li class="@_itemModifierBuilder.Add(active).Add(adjacent).Add(Disabled)"
@onclick="() => HandleOnTimeClick(time)">
@ItemContentRenderFragment(time.ToString(Format == TimeFormat.Hr24 ? "HH:mm" : "hh:mm tt"), active)
</li>
@GenSingleItem(active, adjacent, disabled, time)
}
}
}
Expand All @@ -137,6 +132,14 @@

@code {

private RenderFragment GenSingleItem(bool active, bool adjacent, bool disabled, TimeOnly time) => __builder =>
{
<li class="@_itemModifierBuilder.Add(active).Add(adjacent).Add(disabled)"
@onclick="() => HandleOnTimeClick(time)">
@ItemContentRenderFragment(time.ToString(Format == TimeFormat.Hr24 ? "HH:mm" : "hh:mm tt"), active)
</li>
};

private RenderFragment ItemsRenderFragment(int count, int step, int? current, Func<int, bool>? isAllowedCb, Func<int, Task> onClick) => __builder =>
{
@for (var i = 0; i < count; i = i + step)
Expand Down

0 comments on commit a501d12

Please sign in to comment.