import 'package:doctor_app_flutter/config/config.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/TextFields.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:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart';
import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class PlanPage extends StatefulWidget {
  final Function changePageViewIndex;

  PlanPage({Key key, this.changePageViewIndex});

  @override
  _PlanPageState createState() => _PlanPageState();
}

class _PlanPageState extends State<PlanPage> {
  bool isProgressNoteExpand = false;

  List<dynamic> progressNoteList;

  TextEditingController progressNoteController = TextEditingController();
  BoxDecoration containerBorderDecoration(
      Color containerColor, Color borderColor) {
    return BoxDecoration(
      color: containerColor,
      shape: BoxShape.rectangle,
      borderRadius: BorderRadius.all(Radius.circular(6)),
      border: Border.fromBorderSide(BorderSide(
        color: borderColor,
        width: 0.5,
      )),
    );
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;

    return AppScaffold(
        isShowAppBar: false,
        body: SingleChildScrollView(
          physics: ScrollPhysics(),
          child: Center(
            child: FractionallySizedBox(
              widthFactor: 0.9,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  SizedBox(
                    height: 30,
                  ),
                  HeaderBodyExpandableNotifier(
                    headerWidget: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Texts('Progress Note',
                                variant:
                                isProgressNoteExpand ? "bodyText" : '',
                                bold: isProgressNoteExpand ? true : false,
                                color: Colors.black),
                            Icon(
                              FontAwesomeIcons.asterisk,
                              color: AppGlobal.appPrimaryColor,
                              size: 12,
                            )
                          ],
                        ),
                        InkWell(
                            onTap: () {
                              setState(() {
                                isProgressNoteExpand =
                                !isProgressNoteExpand;
                              });
                            },
                            child: Icon(isProgressNoteExpand
                                ? EvaIcons.minus
                                : EvaIcons.plus))
                      ],
                    ),
                    bodyWidget: Column(children: [
                      SizedBox(
                        height: 20,
                      ),
                      Column(
                        children: [
                          Container(
                            margin:
                            EdgeInsets.only(left: 10, right: 10, top: 15),
                            child: TextFields(
                                hintText: "Add Progress Note",
                                fontSize: 13.5,
                                onTapTextFields: () {
                                  openExaminationList(context);
                                },
                                readOnly: true,
                                // hintColor: Colors.black,
                                suffixIcon: EvaIcons.plusCircleOutline,
                                suffixIconColor: AppGlobal.appPrimaryColor,
                                fontWeight: FontWeight.w600,
                                // controller: messageController,
                                validator: (value) {
                                  if (value == null)
                                    return TranslationBase.of(context)
                                        .emptyMessage;
                                  else
                                    return null;
                                }),
                          ),
                          SizedBox(
                            height: 20,
                          ),
                          Container(
                            margin: EdgeInsets.only(left: 5, right: 5, top: 15),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Column(
                                      mainAxisAlignment:
                                      MainAxisAlignment.start,
                                      crossAxisAlignment:
                                      CrossAxisAlignment.start,
                                      children: [
                                        AppText(
                                          "12".toUpperCase(),
                                          fontWeight: FontWeight.bold,
                                          fontSize: 16,
                                        ),
                                        AppText(
                                          "DEC".toUpperCase(),
                                          fontSize: 10,
                                          color: Colors.grey,
                                        ),
                                      ],
                                    )
                                  ],
                                ),
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [

                                    Row(
                                      mainAxisAlignment:
                                      MainAxisAlignment.start,
                                      children: [
                                        SizedBox(
                                          height: 6,
                                        ),
                                        Padding(
                                          padding: const EdgeInsets.all(0.0),
                                          child: AppText(
                                            "Some progress note about",
                                            fontSize: 10,
                                            color: Colors.grey,
                                          ),
                                        ),
                                      ],
                                    ),SizedBox(
                                      height: 8,
                                    ),
                                    Row(
                                      mainAxisAlignment:
                                      MainAxisAlignment.start,
                                      children: [
                                        AppText(
                                          "Created By : ",
                                          fontWeight: FontWeight.bold,
                                          fontSize: 16,
                                        ),
                                        AppText(
                                          "Anas Abdullah on 12 De",
                                          fontSize: 10,
                                          color: Colors.grey,
                                        ),
                                      ],
                                    ),
                                    Row(
                                      mainAxisAlignment:
                                      MainAxisAlignment.start,
                                      children: [
                                        AppText(
                                          "Edited By : ",
                                          fontWeight: FontWeight.bold,
                                          fontSize: 16,
                                        ),
                                        AppText(
                                          "Rahim on 13 Dec",
                                          fontSize: 10,
                                          color: Colors.grey,
                                        ),
                                      ],
                                    ),

                                  ],
                                ),
                                Column(
                                  children: [
                                    InkWell(
                                      onTap: () {},
                                      child: Icon(EvaIcons.edit2Outline),
                                    )
                                  ],
                                ),
                              ],
                            ),
                          )
                        ],
                      )
                    ]),
                    isExpand: isProgressNoteExpand,
                  ),
                  DividerWithSpacesAround(height: 30,),
                  AppButton(
                    title: TranslationBase.of(context).next,
                    onPressed: () {
                      widget.changePageViewIndex(2);
                    },
                  ),
                  SizedBox(
                    height: 30,
                  ),
                ],
              ),
            ),
          ),
        ));
  }

  openExaminationList(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    InputDecoration textFieldSelectorDecoration(
        String hintText, String selectedText, bool isDropDown) {
      return InputDecoration(
        focusedBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
          borderRadius: BorderRadius.circular(8),
        ),
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
          borderRadius: BorderRadius.circular(8),
        ),
        disabledBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
          borderRadius: BorderRadius.circular(8),
        ),
        hintText: selectedText != null ? selectedText : hintText,
        suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null,
        hintStyle: TextStyle(
          fontSize: 14,
          color: Colors.grey.shade600,
        ),
      );
    }

    ;
    showModalBottomSheet(
        backgroundColor: Colors.white,
        isScrollControlled: true,
        context: context,
        builder: (context) {
          return FractionallySizedBox(
            heightFactor: 0.5,
            child: Container(
                child: FractionallySizedBox(
                  widthFactor: 0.9,
                  child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          height: 16,
                        ),
                        AppText(
                          "Add Progress Note",
                          fontWeight: FontWeight.bold,
                          fontSize: 16,
                        ),
                        SizedBox(
                          height: 10,
                        ),
                        Container(
                          margin: EdgeInsets.only(left: 0, right: 0, top: 15),
                          child: TextFields(
                              hintText: "Remarks",
                              fontSize: 13.5,
                              // hintColor: Colors.black,
                              fontWeight: FontWeight.w600,
                              maxLines: 16,
                              minLines: 8,
                              controller: progressNoteController,
                              validator: (value) {
                                if (value == null)
                                  return TranslationBase.of(context).emptyMessage;
                                else
                                  return null;
                              }),
                        ),SizedBox(
                          height: 10,
                        ),
                        AppButton(
                          title: "Add".toUpperCase(),
                          onPressed: () {
                          },
                        ),
                      ]),
                )),
          );
        });
  }
}
