import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:sigap/src/features/auth/presentasion/widgets/auth_button.dart';
import 'package:sigap/src/utils/constants/colors.dart';
import 'package:sigap/src/utils/constants/sizes.dart';
import 'package:sigap/src/utils/device/device_utility.dart';
import 'package:sigap/src/utils/helpers/helper_functions.dart';

class StateScreen extends StatelessWidget {
  const StateScreen({super.key});

  @override
  Widget build(BuildContext context) {
    // Get arguments
    final args = Get.arguments as Map<String, dynamic>;
    final type = args['type'] as String;
    final title = args['title'] as String;
    final message = args['message'] as String;
    final buttonText = args['buttonText'] as String;
    final onButtonPressed = args['onButtonPressed'] as Function();
    final isDark = THelperFunctions.isDarkMode(context);

    // Set system overlay style
    TDeviceUtils.setStatusBarColor(Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
      ),
    );

    return Scaffold(
      backgroundColor: isDark ? TColors.dark : TColors.light,
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(TSizes.defaultSpace),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              // Icon
              Icon(
                type == 'success'
                    ? Icons.check_circle_outline
                    : Icons.error_outline,
                size: TSizes.imageThumbSize + TSizes.xl,
                color: type == 'success' ? TColors.success : TColors.error,
              ),

              const SizedBox(height: TSizes.spaceBtwSections),

              // Title
              Text(
                title,
                style: Theme.of(context).textTheme.headlineMedium?.copyWith(
                  fontWeight: FontWeight.bold,
                  color: isDark ? TColors.white : TColors.textPrimary,
                ),
                textAlign: TextAlign.center,
              ),

              const SizedBox(height: TSizes.spaceBtwItems),

              // Message
              Text(
                message,
                style: Theme.of(context).textTheme.bodyLarge?.copyWith(
                  color:
                      isDark
                          ? TColors.white.withOpacity(0.7)
                          : TColors.textSecondary,
                ),
                textAlign: TextAlign.center,
              ),

              SizedBox(height: THelperFunctions.screenHeight() * 0.05),

              // Button
              AuthButton(text: buttonText, onPressed: onButtonPressed),
            ],
          ),
        ),
      ),
    );
  }
}
