import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/radiology/final_radiology.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.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.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/Text.dart';
import 'package:doctor_app_flutter/widgets/shared/app_button.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.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",
            orderNo: finalRadiology.orderNo.toString(),
            appointmentDate:finalRadiology.orderDate,
            doctorName: finalRadiology.doctorName,
            profileUrl: finalRadiology.doctorImageURL,
            invoiceNO: finalRadiology.invoiceNo.toString(),
          ),
          isShowAppBar: true,
          baseViewModel: model,
          body: SingleChildScrollView(
            child: Column(
              mainAxisSize: MainAxisSize.max,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.all(8),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(12),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(height: 5,),
                      Texts(TranslationBase.of(context).generalResult),
                      SizedBox(height: 5,),
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Texts(
                          '${finalRadiology.reportData.trim()}',
                          textAlign: TextAlign.start,
                          fontSize: 17,
                          color: Colors.grey,
                        ),
                      ),
                      SizedBox(height: 25,),
                      if(model.radImageURL.isNotEmpty)
                      Center(
                        child: Container(
                          width: MediaQuery.of(context).size.width * 0.8,
                          child: Button(

                            color: Colors.red,
                            onTap: () {
                              launch(model.radImageURL);
                            },
                            title: TranslationBase.of(context).openRad,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          ),
    );
  }
}
