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/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;

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

  @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(
          appBarTitle: TranslationBase.of(context).radiologyReport,
          isShowAppBar: true,
          baseViewModel: model,
          body: SingleChildScrollView(
            child: Column(
              mainAxisSize: MainAxisSize.max,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Texts(
                  '${finalRadiology.reportData}',
                  textAlign: TextAlign.center,
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Texts(
                    '${finalRadiology.reportData}',
                    textAlign: TextAlign.start,
                    fontSize: 17,
                  ),
                ),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.2,
                )
              ],
            ),
          ),
          bottomSheet: Container(
            width: double.infinity,
            height: MediaQuery.of(context).size.height * 0.14,
            color: Colors.grey[100],
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Divider(),
                if (finalRadiology.dIAPACSURL != "")
                  Container(
                    width: MediaQuery.of(context).size.width * 0.8,
                    child: Button(
                      onTap: () {
                        launch(model.radImageURL);
                      },
                      title: TranslationBase.of(context).openRad,
                    ),
                  ),
              ],
            ),
          )),
    );
  }
}
