import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_driver/constant/style.dart';
import 'package:sefer_driver/views/widgets/mycircular.dart';

import '../../../../controller/functions/encrypt_decrypt.dart';
import '../../../../controller/home/captin/help/help_controller.dart';
import '../../../widgets/my_scafold.dart';

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

  @override
  Widget build(BuildContext context) {
    Get.find<HelpController>();
    return GetBuilder<HelpController>(
        builder: (helpController) => MyScafolld(
              title: 'Help Details'.tr,
              body: [
                helpController.isLoading
                    ? const MyCircularProgressIndicator()
                    : Padding(
                        padding: const EdgeInsets.all(16.0),
                        child: Column(
                          children: [
                            // Question Bubble (Aligned to Start/End based on locale, usually start for sender)
                            Align(
                              alignment: AlignmentDirectional.centerStart,
                              child: Container(
                                constraints: BoxConstraints(maxWidth: Get.width * 0.75),
                                padding: const EdgeInsets.all(12),
                                decoration: BoxDecoration(
                                  color: Theme.of(context).colorScheme.primaryContainer,
                                  borderRadius: const BorderRadius.only(
                                    topRight: Radius.circular(16),
                                    bottomLeft: Radius.circular(16),
                                    bottomRight: Radius.circular(16),
                                  ),
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      'Your Question'.tr,
                                      style: Theme.of(context).textTheme.labelSmall?.copyWith(
                                        color: Theme.of(context).colorScheme.primary,
                                        fontWeight: FontWeight.bold,
                                      ),
                                    ),
                                    const SizedBox(height: 4),
                                    Text(
                                      helpController.qustion,
                                      style: Theme.of(context).textTheme.bodyLarge,
                                    ),
                                  ],
                                ),
                              ),
                            ),
                            const SizedBox(height: 24),
                            // Reply Bubble (Aligned to opposite side)
                            Align(
                              alignment: AlignmentDirectional.centerEnd,
                              child: Container(
                                constraints: BoxConstraints(maxWidth: Get.width * 0.75),
                                padding: const EdgeInsets.all(12),
                                decoration: BoxDecoration(
                                  color: Theme.of(context).colorScheme.secondaryContainer,
                                  borderRadius: const BorderRadius.only(
                                    topLeft: Radius.circular(16),
                                    bottomLeft: Radius.circular(16),
                                    bottomRight: Radius.circular(16),
                                  ),
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      'Support Reply'.tr,
                                      style: Theme.of(context).textTheme.labelSmall?.copyWith(
                                        color: Theme.of(context).colorScheme.secondary,
                                        fontWeight: FontWeight.bold,
                                      ),
                                    ),
                                    const SizedBox(height: 4),
                                    Builder(builder: (context) {
                                      final replayData = helpController.helpQuestionRepleyDate['message'];
                                      final isNoReply = helpController.status == 'not yet' ||
                                          replayData == null ||
                                          EncryptionHelper.instance.decryptData(replayData['replay']).toString() == 'not yet';
                                      
                                      return Text(
                                        isNoReply 
                                          ? 'No Response yet.'.tr 
                                          : EncryptionHelper.instance.decryptData(replayData['replay']).toString(),
                                        style: Theme.of(context).textTheme.bodyLarge,
                                      );
                                    }),
                                  ],
                                ),
                              ),
                            ),
                          ],
                        ),
                      )

              ],
              isleading: true,
            ));
  }
}
