import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';

import '../../../generated/locale_keys.g.dart';

class PatientQrCodeWidget extends StatelessWidget {
  PatientQrCodeWidget({super.key});

  late AppState appState;

  @override
  Widget build(BuildContext context) {
    appState = getIt.get<AppState>();
    return Column(
      children: [
        SizedBox(height: 8.h),
        "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}".toText18(isBold: true, textOverflow: TextOverflow.ellipsis, maxlines: 2),
        SizedBox(height: 8.h),
        Wrap(
          direction: Axis.horizontal,
          spacing: 4.w,
          runSpacing: 6.w,
          children: [
            AppCustomChipWidget(
              icon: AppAssets.file_icon,
              labelText: "${LocaleKeys.fileno.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}",
              labelPadding: EdgeInsetsDirectional.only(start: -4.w, end: 6.w),
            ),
            AppCustomChipWidget(
              icon: AppAssets.checkmark_icon,
              labelText: LocaleKeys.verified.tr(context: context),
              iconColor: AppColors.successColor,
              labelPadding: EdgeInsetsDirectional.only(start: -4.w, end: 6.w),
            ),
          ],
        ),
        SizedBox(height: 16.h),
        Image.network(
          "https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${appState.getAuthenticatedUser()!.patientId.toString()}",
          fit: BoxFit.fill,
          height: 156.h,
          width: 156.h,
        ),
        SizedBox(height: 16.h),
      ],
    );
  }
}
