// SPDX-FileCopyrightText: © 2025 Nøkken.io <nokken.io@proton.me>
// SPDX-License-Identifier: AGPL-3.0
//
// loading_error_views.dart
//
import 'package:flutter/material.dart';
import 'package:nokken/src/core/ui/theme/app_colors.dart';
import 'package:nokken/src/core/ui/theme/app_icons.dart';
import 'package:nokken/src/core/ui/theme/app_text_styles.dart';
import 'package:nokken/src/core/ui/widgets/shared_widgets.dart';

class LoadingErrorViews {
  static Widget loading() {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          const CircularProgressIndicator(),
          SharedWidgets.verticalSpace(24),
          Text(
            'Analyzing your health data...',
            style: AppTextStyles.titleMedium,
          ),
          SharedWidgets.verticalSpace(16),
          const Text(
            'Our AI is processing your health data to generate personalized insights.',
            textAlign: TextAlign.center,
          ),
        ],
      ),
    );
  }

  static Widget error({
    required String error,
    required VoidCallback onRetry,
    required VoidCallback onGoBack,
  }) {
    return Center(
      child: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(24.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                AppIcons.getIcon('error'),
                size: 80,
                color: AppColors.error,
              ),
              SharedWidgets.verticalSpace(24),
              Text(
                'Analysis Error',
                style: AppTextStyles.headlineSmall,
              ),
              SharedWidgets.verticalSpace(16),
              Text(
                'We encountered a problem while analyzing your health data: $error',
                textAlign: TextAlign.center,
                style: TextStyle(color: AppColors.error),
              ),
              SharedWidgets.verticalSpace(40),
              ElevatedButton.icon(
                onPressed: onRetry,
                icon: const Icon(Icons.refresh),
                label: const Text('Try Again'),
                style: ElevatedButton.styleFrom(
                  foregroundColor: Colors.white,
                  backgroundColor: AppColors.error,
                  padding:
                      const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
                ),
              ),
              SharedWidgets.verticalSpace(16),
              TextButton(
                onPressed: onGoBack,
                child: const Text('Go Back'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
