import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.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/SOAP/assessment_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/objective_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/plan_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/subjective_page.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../patient_profile_widget.dart';
import 'steps_widget.dart';

class AddSOAPIndex extends StatefulWidget {
  @override
  _AddSOAPIndexState createState() => _AddSOAPIndexState();
}

class _AddSOAPIndexState extends State<AddSOAPIndex>
    with TickerProviderStateMixin {
  PageController _controller;
  int _currentIndex = 0;
   List<MySelectedAllergy> myAllergiesList= List();
  List<MasterKeyModel> myHistoryList = List();
  List<MySelectedExamination> mySelectedExamination = List();
  changePageViewIndex(pageIndex) {
    _controller.jumpToPage(pageIndex);
  }

  @override
  void initState() {
    // TODO: implement initState
    _controller = new PageController();

    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    final routeArgs = ModalRoute.of(context).settings.arguments as Map;
    PatiantInformtion patient = routeArgs['patient'];
    return BaseView<DoctorReplayViewModel>(
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        appBarTitle: TranslationBase.of(context).healthRecordInformation,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                decoration:
                    BoxDecoration(boxShadow: <BoxShadow>[], color: Colors.white),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children:   <Widget>[
                          AvatarWidget(
                            Icon(
                              patient.genderDescription == "Male"
                                  ? DoctorApp.male
                                  : DoctorApp.female_icon,
                              size: 70,
                              color: Colors.white,
                            ),
                          ),
                          SizedBox(
                            width: 20,
                          ),
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: [
                              SizedBox(
                                height: 5,
                              ),
                              AppText(
                                patient.firstName + ' ' + patient.lastName,
                                color: Colors.black,
                                fontWeight: FontWeight.bold,
                              ),
                              Row(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  AppText(
                                    TranslationBase.of(context).age,
                                    color: Colors.black,
                                    fontWeight: FontWeight.bold,
                                  ),
                                  SizedBox(
                                    width: 20,
                                  ),
                                  AppText(
                                    patient.age.toString(),
                                    color: Colors.black,
                                    fontWeight: FontWeight.normal,
                                  ),
                                ],
                              ),
                              AppText(
                                "ALLERGIC TO: FOOD, ASPIRIN, EGG WHITE",
                                color: Color(0xFFB9382C),
                                fontWeight: FontWeight.bold,
                              ),
                            ],
                          )
                        ],
                      ),
                    ),
                    Container(
                      width: double.infinity,
                      height: 1,
                      color: Color(0xffCCCCCC),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    FractionallySizedBox(
                      child: SingleChildScrollView(
                        child: Container(
                          height: MediaQuery.of(context).size.height * 0.75,
                          child: Column(
                            children: [
                              Container(
                                margin: EdgeInsets.only(
                                    left:
                                        MediaQuery.of(context).size.width * 0.05,
                                    right:
                                        MediaQuery.of(context).size.width * 0.05),
                                child: StepsWidget(
                                  index: _currentIndex,
                                  changeCurrentTab: changePageViewIndex,
                                ),
                              ),
                              Expanded(
                                child: PageView(
                                  physics: NeverScrollableScrollPhysics(),
                                  controller: _controller,
                                  onPageChanged: (index) {
                                    setState(() {
                                      _currentIndex = index;
                                    });
                                  },
                                  scrollDirection: Axis.horizontal,
                                  children: <Widget>[
                                    SubjectivePage(changePageViewIndex: changePageViewIndex,myAllergiesList: myAllergiesList,myHistoryList: myHistoryList,),
                                    ObjectivePage(changePageViewIndex: changePageViewIndex,mySelectedExamination:mySelectedExamination),
                                    AssessmentPage(changePageViewIndex: changePageViewIndex,),
                                    PlanPage(changePageViewIndex: changePageViewIndex,)
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    )
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
