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

part of '../top_bar.dart';

/// Private implementation type for `_ModeToggle` 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 _ModeToggle extends StatelessWidget {
  /// Creates a `_ModeToggle` 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 _ModeToggle({required this.metrics});

  /// 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;

  /// 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 Container(
      height: metrics.modeHeight,
      width: metrics.modeWidth,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(metrics.borderRadius),
        border: Border.all(
          color: FocusFlowTokens.subtleBorder,
          width: metrics.borderWidth,
        ),
      ),
      child: Row(
        children: [
          Expanded(
            child: Container(
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: FocusFlowTokens.glassPanelStrong,
                borderRadius: BorderRadius.circular(metrics.borderRadius),
                border: Border.all(
                  color: FocusFlowTokens.navBorder,
                  width: metrics.borderWidth,
                ),
              ),
              child: FittedBox(
                fit: BoxFit.scaleDown,
                child: Text(
                  'Compact',
                  style: TextStyle(fontSize: metrics.modeLabelSize),
                ),
              ),
            ),
          ),
          Expanded(
            child: TextButton(
              onPressed: () {},
              style: TextButton.styleFrom(
                minimumSize: Size.zero,
                padding: EdgeInsets.zero,
                tapTargetSize: MaterialTapTargetSize.shrinkWrap,
              ),
              child: FittedBox(
                fit: BoxFit.scaleDown,
                child: Text(
                  'Normal',
                  style: TextStyle(
                    color: FocusFlowTokens.textPrimary,
                    fontSize: metrics.modeLabelSize,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
