import 'package:flutter/material.dart';
import 'package:design_system/design_system.dart';


/// A save button widget for the bottom of the personal info page.
///
/// Displays a full-width button with a save icon and customizable label.
/// Uses only design system tokens for colors, typography, and spacing.
class SaveButton extends StatelessWidget {

  /// Creates a [SaveButton].
  const SaveButton({
    super.key,
    required this.onPressed,
    required this.label,
    this.isLoading = false,
  });
  /// Callback when the button is pressed.
  final VoidCallback? onPressed;

  /// The button label text.
  final String label;

  /// Whether to show a loading indicator.
  final bool isLoading;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(UiConstants.space5),
      decoration: const BoxDecoration(
        color: UiColors.bgPopup,
        border: Border(
          top: BorderSide(color: UiColors.border),
        ),
      ),
      child: SafeArea(
        child: SizedBox(
          width: double.infinity,
          height: 48,
          child: ElevatedButton(
            onPressed: onPressed,
            style: ElevatedButton.styleFrom(
              backgroundColor: UiColors.primary,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(UiConstants.radiusMdValue),
              ),
              elevation: 0,
            ),
            child: isLoading
                ? const SizedBox(
                    width: 20,
                    height: 20,
                    child: CircularProgressIndicator(
                      strokeWidth: 2,
                      valueColor: AlwaysStoppedAnimation<Color>(
                        UiColors.bgPopup,
                      ),
                    ),
                  )
                : Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      const Icon(UiIcons.check, color: UiColors.bgPopup, size: 20),
                      const SizedBox(width: UiConstants.space2),
                      Text(
                        label,
                        style: UiTypography.body1m.copyWith(
                          color: UiColors.bgPopup,
                        ),
                      ),
                    ],
                  ),
          ),
        ),
      ),
    );
  }
}
