import 'package:flutter/material.dart';

import '../theme/kc_colors.dart';
import '../theme/kc_spacing.dart';

/// A shared loading-state widget for use across Kell Creations apps.
///
/// Displays a centered [CircularProgressIndicator] with an optional
/// [message] below it. Useful as a placeholder while data is being fetched.
class KcLoadingState extends StatelessWidget {
  /// Optional message displayed below the spinner.
  final String? message;

  const KcLoadingState({super.key, this.message});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Padding(
        padding: const EdgeInsets.symmetric(vertical: KcSpacing.xl),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const CircularProgressIndicator(),
            if (message != null) ...[
              const SizedBox(height: KcSpacing.md),
              Text(
                message!,
                style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: KcColors.neutral),
                textAlign: TextAlign.center,
              ),
            ],
          ],
        ),
      ),
    );
  }
}
