| | | 1 | | using Microsoft.AspNetCore.Components; |
| | | 2 | | using Pomodoro.Web.Models; |
| | | 3 | | |
| | | 4 | | namespace Pomodoro.Web.Components; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Code-behind for TimerControls component |
| | | 8 | | /// Separates business logic from view |
| | | 9 | | /// </summary> |
| | | 10 | | public class TimerControlsBase : ComponentBase |
| | | 11 | | { |
| | | 12 | | #region Parameters (Model) |
| | | 13 | | |
| | | 14 | | [Parameter] |
| | 707 | 15 | | public bool IsRunning { get; set; } |
| | | 16 | | |
| | | 17 | | [Parameter] |
| | 327 | 18 | | public bool IsPaused { get; set; } |
| | | 19 | | |
| | | 20 | | [Parameter] |
| | 698 | 21 | | public bool IsStarted { get; set; } |
| | | 22 | | |
| | | 23 | | [Parameter] |
| | 1696 | 24 | | public bool CanStart { get; set; } |
| | | 25 | | |
| | | 26 | | [Parameter] |
| | 703 | 27 | | public SessionType SessionType { get; set; } |
| | | 28 | | |
| | | 29 | | [Parameter] |
| | 662 | 30 | | public EventCallback OnStart { get; set; } |
| | | 31 | | |
| | | 32 | | [Parameter] |
| | 335 | 33 | | public EventCallback OnPause { get; set; } |
| | | 34 | | |
| | | 35 | | [Parameter] |
| | 335 | 36 | | public EventCallback OnResume { get; set; } |
| | | 37 | | |
| | | 38 | | [Parameter] |
| | 345 | 39 | | public EventCallback OnReset { get; set; } |
| | | 40 | | |
| | | 41 | | #endregion |
| | | 42 | | |
| | | 43 | | #region Computed Properties |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Determines if the Start button should be disabled |
| | | 47 | | /// </summary> |
| | 1344 | 48 | | protected bool IsStartDisabled => !CanStart; |
| | | 49 | | |
| | | 50 | | #endregion |
| | | 51 | | |
| | | 52 | | #region Business Logic Methods |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets the display label for the current session type |
| | | 56 | | /// </summary> |
| | | 57 | | protected string GetSessionLabel() |
| | 4 | 58 | | { |
| | 4 | 59 | | return SessionType switch |
| | 4 | 60 | | { |
| | 1 | 61 | | SessionType.Pomodoro => Constants.SessionTypes.PomodoroDisplayName, |
| | 1 | 62 | | SessionType.ShortBreak => Constants.SessionTypes.ShortBreakDisplayName, |
| | 1 | 63 | | SessionType.LongBreak => Constants.SessionTypes.LongBreakDisplayName, |
| | 1 | 64 | | _ => string.Empty |
| | 4 | 65 | | }; |
| | 4 | 66 | | } |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// Gets the CSS class for buttons based on current session type |
| | | 70 | | /// Matches PIP window behavior for consistent styling |
| | | 71 | | /// </summary> |
| | | 72 | | protected string GetSessionClass() |
| | 346 | 73 | | { |
| | 346 | 74 | | return SessionType switch |
| | 346 | 75 | | { |
| | 335 | 76 | | SessionType.Pomodoro => Constants.SessionTypes.PomodoroClass, |
| | 5 | 77 | | SessionType.ShortBreak => Constants.SessionTypes.ShortBreakClass, |
| | 3 | 78 | | SessionType.LongBreak => Constants.SessionTypes.LongBreakClass, |
| | 3 | 79 | | _ => Constants.SessionTypes.PomodoroClass |
| | 346 | 80 | | }; |
| | 346 | 81 | | } |
| | | 82 | | |
| | | 83 | | #endregion |
| | | 84 | | } |