import 'package:hmg_patient_app/core/model/eye/AppoimentAllHistoryResult.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/dialogs/confirm_send_email_dialog.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ClassesPage extends StatelessWidget {
  final ListHISGetGlassPerscription? glassPerscription;
  final int? appointmentNo;
  final String? projectName;
  final int? projectID;

  const ClassesPage({Key? key, this.glassPerscription, this.appointmentNo, this.projectName, this.projectID}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Container(
        margin: EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 20),
        child: Column(
          children: [
            Container(
              decoration: cardRadius(12),
              child: Container(

                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Text(
                        TranslationBase.of(context).rightEye,
                        style: TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.w600,
                          letterSpacing: -0.64,
                        ),
                      ),
                    ),
                    getRow(TranslationBase.of(context).sphere, '${glassPerscription?.rightEyeSpherical}', '-'),
                    getRow(TranslationBase.of(context).cylinder, '${glassPerscription?.rightEyeCylinder}', '-'),
                    getRow(TranslationBase.of(context).axis, '${glassPerscription?.rightEyeAxis}', '-'),
                    getRow(TranslationBase.of(context).prism, '${glassPerscription?.rightEyePrism}', '-'),
                    getRow(TranslationBase.of(context).va, '${glassPerscription?.rightEyeVA}', '-',isLast:true),
                  ],
                ),
              ),
            ),
            SizedBox(
              height: 12,
            ),
            Container(
              decoration: cardRadius(12),
              child: Container(   child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      TranslationBase.of(context).leftEye,
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w600,
                        letterSpacing: -0.64,
                      ),
                    ),
                  ),
                  getRow(TranslationBase.of(context).sphere, '${glassPerscription?.leftEyeSpherical}', '-'),
                  getRow(TranslationBase.of(context).cylinder, '${glassPerscription?.leftEyeCylinder}', '-'),
                  getRow(TranslationBase.of(context).axis, '${glassPerscription?.leftEyeAxis}', '-'),
                  getRow(TranslationBase.of(context).prism, '${glassPerscription?.leftEyePrism}', '-'),
                  getRow(TranslationBase.of(context).va, '${glassPerscription?.leftEyeVA}', '-',isLast:true),
                ],
              ),
              ),
            ),
            SizedBox(
              height: 17,
            ),
            // Container(
            //   width: double.infinity,
            //   child: SecondaryButton(
            //     label: TranslationBase.of(context).sendEmail,
            //     onTap: () {
            //       showConfirmMessage(context, () async {
            //         GifLoaderDialogUtils.showMyDialog(context);
            //         await model.sendGlassesPrescriptionEmail(appointmentNo: appointmentNo, projectName: projectName, projectID: projectID);
            //         GifLoaderDialogUtils.hideDialog(context);
            //       }, model.user.emailAddress);
            //     },
            //     textColor: Colors.white,
            //     color: Colors.red[700],
            //     icon: Icon(
            //       Icons.email,
            //       color: Colors.white,
            //     ),
            //   ),
            // )
          ],
        ),
      ),
    );
  }

  void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) {
    showDialog(
      context: context,
      builder: (cxt) => ConfirmSendEmailDialog(
        email: email,
        onTapSendEmail: () {
          onTap();
        },
      ),
    );
  }

  Widget getRow(String title, String val1, String val2,{bool isLast=false}) => Padding(
    padding: const EdgeInsets.only(left: 8,right: 8),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Expanded(flex: 4, child: Text(title,style: TextStyle(fontSize: 11, fontWeight: FontWeight.w600, letterSpacing: -0.4))),
              Expanded(
                flex: 2,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Text(
                      val1 == 'null' ? '-' : val1,
                      style: TextStyle(fontSize: 11, fontWeight: FontWeight.w600, letterSpacing: -0.4),
                    ),
                    Text(
                      val2 != 'null' ? '-' : val2,
                      style: TextStyle(fontSize: 11, fontWeight: FontWeight.w600, letterSpacing: -0.4),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
       isLast?Container(height: 4,): Divider()
      ],
    ),
  );
}
