import 'package:hmg_patient_app/core/model/doctor/patient_doctor_appointment.dart';
import 'package:hmg_patient_app/core/viewModels/medical/my_doctor_view_model.dart';
import 'package:hmg_patient_app/pages/BookAppointment/widgets/DoctorView.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DoctorProfilePage extends StatefulWidget {
  final PatientDoctorAppointment patientDoctorAppointment;

  DoctorProfilePage({required this.patientDoctorAppointment});

  @override
  _DoctorProfilePageState createState() =>
      _DoctorProfilePageState(patientDoctorAppointment);
}

class _DoctorProfilePageState extends State<DoctorProfilePage>
    with TickerProviderStateMixin {
  late TabController _tabController;
  late PatientDoctorAppointment patientDoctorAppointment;

  _DoctorProfilePageState(this.patientDoctorAppointment);

  @override
  void initState() {
    _tabController = new TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BaseView<MyDoctorViewModel>(
     /* onModelReady: (model) => model.getDoctorProfileAndRating(
          doctorId: widget.patientDoctorAppointment.doctorID,
          clinicID: widget.patientDoctorAppointment.clinicID,
          projectID: widget.patientDoctorAppointment.projectID),*/
      builder: (context, model, widget) => DoctorView(doctor: model.doctorList,)/*AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Doctor Profile',
        baseViewModel: model,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                color: Colors.white,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(top: 20.0),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: <Widget>[
                          Container(
                              margin: EdgeInsets.all(5),
                              width: 50,
                              height: 50,
                              decoration: BoxDecoration(
                                  shape: BoxShape.circle, color: Colors.grey),
                              child: Icon(
                                Icons.calendar_view_day,
                                size: 25,
                                color: Colors.white,
                              )),
                          ClipRRect(
                            borderRadius: BorderRadius.circular(100.0),
                            child: Image.network(
                                patientDoctorAppointment.doctorImageURL,
                                fit: BoxFit.fill,
                                height: 120.0,
                                width: 120.0),
                          ),
                          Container(
                              margin: EdgeInsets.all(5),
                              width: 50,
                              height: 50,
                              decoration: BoxDecoration(
                                  shape: BoxShape.circle, color: Colors.grey),
                              child: Icon(
                                Icons.format_list_bulleted,
                                size: 25,
                                color: Colors.white,
                              )),
                        ],
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      alignment: Alignment.center,
                      child: Text(patientDoctorAppointment.doctorName,
                          style: TextStyle(
                              fontSize: 20.0,
                              color: Colors.grey[900],
                              letterSpacing: 1.0)),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      alignment: Alignment.center,
                      child: Text(patientDoctorAppointment.clinicName,
                          style: TextStyle(
                              fontSize: 12.0,
                              color: Colors.grey[900],
                              letterSpacing: 1.0)),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5.0),
                      alignment: Alignment.center,
                      child: RatingBar.readOnly(
                        initialRating:
                            model.doctorRating.doctorRate?.toDouble() ?? 0.0,
                        size: 35.0,
                        filledColor: Colors.yellow[700],
                        emptyColor: Colors.grey[500],
                        isHalfAllowed: true,
                        halfFilledIcon: Icons.star_half,
                        filledIcon: Icons.star,
                        emptyIcon: Icons.star,
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5.0),
                      alignment: Alignment.center,
                      child: Text(
                          "(${model.doctorRating.patientNumber ?? 0} Reviews)",
                          style: TextStyle(
                            fontSize: 14.0,
                            color: Colors.blue[800],
                            letterSpacing: 1.0,
                            decoration: TextDecoration.underline,
                          )),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10.0),
                      child: Divider(
                        color: Colors.grey[500],
                      ),
                    ),
                    TabBar(
                      indicatorColor: Colors.red[800],
                      indicatorWeight: 3.0,
                      tabs: [
                        Tab(
                            child: Text('Doctor Information',
                                style: TextStyle(color: Colors.black))),
                        Tab(
                          child: Text(TranslationBase.of(context).availableAppo,
                              style: TextStyle(color: Colors.black)),
                        )
                      ],
                      controller: _tabController,
                    ),
                    Container(
                      height: MediaQuery.of(context).size.height * 0.8,
                      child: TabBarView(
                        physics: BouncingScrollPhysics(),
                        
                        children: [
                          DoctorInformation(
                            doctorProfile: model.doctorProfile,
                          ),
                          Container(),
//                                DocAvailableAppointments(doctor: model.doctorList,)
                        ],
                        controller: _tabController,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      )*/,
    );
  }
}
