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

class AttireBottomBar extends StatelessWidget {
  final bool canSave;
  final bool allMandatorySelected;
  final bool allMandatoryHavePhotos;
  final bool attestationChecked;
  final VoidCallback onSave;

  const AttireBottomBar({
    super.key,
    required this.canSave,
    required this.allMandatorySelected,
    required this.allMandatoryHavePhotos,
    required this.attestationChecked,
    required this.onSave,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(UiConstants.space5),
      decoration: const BoxDecoration(
        color: UiColors.white,
        border: Border(top: BorderSide(color: UiColors.border)),
      ),
      child: SafeArea(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            if (!canSave)
              Padding(
                padding: const EdgeInsets.only(bottom: UiConstants.space3),
                child: Column(
                  children: <Widget>[
                    if (!allMandatorySelected)
                      _buildValidationError(t.staff_profile_attire.validation.select_required),
                    if (!allMandatoryHavePhotos)
                      _buildValidationError(t.staff_profile_attire.validation.upload_required),
                    if (!attestationChecked)
                      _buildValidationError(t.staff_profile_attire.validation.accept_attestation),
                  ],
                ),
              ),
            UiButton.primary(
              text: t.staff_profile_attire.actions.save,
              onPressed: canSave ? onSave : null, // UiButton handles disabled/null?
              // UiButton usually takes nullable onPressed to disable.
              fullWidth: true,
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildValidationError(String text) {
    return Text(
      text,
      style: UiTypography.body3r.copyWith(color: UiColors.destructive),
    );
  }
}
