import 'package:doctor_app_flutter/core/model/radiology/final_radiology.dart';
import 'package:doctor_app_flutter/core/viewModel/radiology_view_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_header_with_appointment_card_app_bar.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/secondary_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class RadiologyDetailsPage extends StatelessWidget {
  final FinalRadiology finalRadiology;
  final PatiantInformtion patient;
  final String patientType;
  final String arrivalType;

  RadiologyDetailsPage(
      {Key key,
      this.finalRadiology,
      this.patient,
      this.patientType,
      this.arrivalType});

  @override
  Widget build(BuildContext context) {
    return BaseView<RadiologyViewModel>(
      onModelReady: (model) => model.getRadImageURL(
          patient: patient,
          projectId: finalRadiology.projectID,
          lineItem: finalRadiology.invoiceLineItemNo,
          invoiceNo: finalRadiology.invoiceNo),
      builder: (_, model, widget) => AppScaffold(
        appBar: PatientProfileHeaderWhitAppointmentAppBar(
          patient: patient,
          patientType: patientType ?? "0",
          arrivalType: arrivalType ?? "0",
          appointmentDate: finalRadiology.orderDate,
          doctorName: finalRadiology.doctorName,
          clinic: finalRadiology.clinicDescription,
          branch: finalRadiology.projectName,
          profileUrl: finalRadiology.doctorImageURL,
          invoiceNO: finalRadiology.invoiceNo.toString(),
        ),
        isShowAppBar: true,
        baseViewModel: model,
        body: SingleChildScrollView(
          child: Column(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                width: double.maxFinite,
                margin: EdgeInsets.all(8),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SizedBox(
                      height: 5,
                    ),
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: AppText(TranslationBase.of(context).generalResult,color: Color(0xff2E303A),),
                    ),

                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: AppText(
                        '${finalRadiology.reportData.trim()}',
                        textAlign: TextAlign.start,
                        fontSize: 17,
                        color: Color(0xff575757),
                      ),
                    ),
                    SizedBox(
                      height: 100,
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        bottomSheet: model.radImageURL.isNotEmpty
            ? Container(
                height: 80,
                width: double.maxFinite,
                child: Container(
                  margin:
                      EdgeInsets.only(left: 35, right: 35, top: 12, bottom: 12),
                  child: SecondaryButton(
                    color: Color(0xffD02127),
                    disabled: finalRadiology.dIAPACSURL == "",
                    textColor: Color(0xffFFFFFF),
                    onTap: () {
                      launch(model.radImageURL);
                    },
                    label: TranslationBase.of(context).openRad,
                  ),
                ),
              )
            : null,
      ),
    );
  }
}
