import 'package:diplomaticquarterapp/core/model/eye/AppoimentAllHistoryResult.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/EyeViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ClassesPage extends StatelessWidget {
  final ListHISGetGlassPerscription glassPerscription;

  const ClassesPage({Key key, this.glassPerscription}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BaseView<EyeViewModel>(
      builder: (_, model, w) => AppScaffold(
        body: SingleChildScrollView(
          child: Container(
            margin: EdgeInsets.only(top: 70, left: 15, right: 15, bottom: 15),
            child: Column(
              children: [
                Container(
                  decoration: BoxDecoration(
                      shape: BoxShape.rectangle,
                      borderRadius: BorderRadius.all(Radius.circular(8)),
                      color: Colors.white),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Texts(
                          TranslationBase.of(context).rightEye,
                          fontSize: 23,
                          bold: true,
                        ),
                      ),
                      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}', '-'),
                    ],
                  ),
                ),
                SizedBox(
                  height: 17,
                ),
                Container(
                  decoration: BoxDecoration(
                      shape: BoxShape.rectangle,
                      borderRadius: BorderRadius.all(Radius.circular(8)),
                      color: Colors.white),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Texts(
                          TranslationBase.of(context).leftEye,
                          fontSize: 23,
                          bold: true,
                        ),
                      ),
                      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}', '-'),
                    ],
                  ),
                ),
                SizedBox(
                  height: 17,
                ),
                Container(
                  width: double.infinity,
                  child: SecondaryButton(
                    label: TranslationBase.of(context).sendEmail,
                    textColor: Colors.white,
                    color: Colors.red[700],
                    icon: Icon(
                      Icons.email,
                      color: Colors.white,
                    ),
                  ),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget getRow(String title, String val1, String val2) => Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(flex: 4, child: Texts(title)),
                Expanded(
                  flex: 2,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Texts(val1 == 'null' ? '-' : val1),
                      Texts(val2 != 'null' ? '-' :val2),
                    ],
                  ),
                )
              ],
            ),
            Divider()
          ],
        ),
      );
}
