// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../top_bar.dart';

/// Private implementation type for `_IconButton` in this library.
/// It keeps supporting state and behavior scoped to the owning file so the public API stays focused on the scheduler concepts that callers use directly.
class _IconButton extends StatelessWidget {
  /// Creates a `_IconButton` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  const _IconButton({
    required this.icon,
    required this.metrics,
    required this.tooltip,
    required this.onPressed,
  });

  /// Stores the `icon` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final IconData icon;

  /// Stores the `metrics` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final _TopBarMetrics metrics;

  /// Stores the `tooltip` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final String tooltip;

  /// Stores the `onPressed` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final VoidCallback? onPressed;

  /// Builds the widget subtree for this component.
  /// The method translates the current widget configuration and state into Flutter UI without mutating scheduler domain data.
  @override
  Widget build(BuildContext context) {
    return IconButton(
      onPressed: onPressed,
      tooltip: tooltip,
      constraints: BoxConstraints.tightFor(
        width: metrics.iconButtonSize,
        height: metrics.iconButtonSize,
      ),
      color: FocusFlowTokens.textPrimary,
      iconSize: metrics.iconSize,
      padding: EdgeInsets.zero,
      icon: Icon(icon),
      visualDensity: VisualDensity.compact,
    );
  }
}
