import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-vital-sign-viewmodel.dart';
import 'package:doctor_app_flutter/core/model/patient/vital_sign/patient-vital-sign-history.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/utils/date-utils.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:flutter/material.dart';

class VitalSignDetailPainScale extends StatelessWidget {
  final List<VitalSignHistory> vitalList;

  VitalSignDetailPainScale(this.vitalList);

  @override
  Widget build(BuildContext context) {
    return BaseView<VitalSignsViewModel>(
      builder: (_, model, w) => NetworkBaseView(
        baseViewModel: model,
        child: SingleChildScrollView(
          child: Column(
            children: [
              ...List.generate(
                vitalList.length,
                (index) => Container(
                  margin: EdgeInsets.all(5),
                  color: Colors.white,
                  child: Column(
                    children: [
                      Row(
                        children: [
                          Expanded(
                            child: Container(
                              child: Center(
                                child: AppText(
                                  TranslationBase.of(context).description,
                                  color: Colors.black,
                                  bold: true,
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              child: Center(
                                child: AppText(
                                  TranslationBase.of(context).value,
                                  color: Colors.black,
                                  bold: true,
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              child: Center(
                                child: AppText(
                                  TranslationBase.of(context).date,
                                  color: Colors.black,
                                  bold: true,
                                ),
                              ),
                            ),
                          )
                        ],
                      ),
                      SizedBox(
                        height: 7,
                      ),
                      Divider(
                        color: Colors.black,
                        thickness: 1,
                      ),
                      SizedBox(
                        height: 12,
                      ),
                      Container(
                        margin: EdgeInsets.symmetric(horizontal: 16),
                        padding: EdgeInsets.only(left: 8),
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.start,

                          children: [
                            Expanded(
                              flex: 2,
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                mainAxisAlignment: MainAxisAlignment.start,
                                children: [
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.start,
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            TranslationBase.of(context)
                                                .painScale,
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].painScoreDesc ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.start,
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            "Location",
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].painLocation ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            "Character",
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].painCharacter ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            "Duration",
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].painDuration ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            TranslationBase.of(context)
                                                .painManagement,
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].isPainManagementDone ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Expanded(
                                        child: Container(
                                          child: AppText(
                                            "Frequency",
                                            fontSize:
                                                SizeConfig.textMultiplier! * 1.5,
                                            color: Color(0XFF28353E),
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: Container(
                                          child: Center(
                                            child: AppText(
                                              "${vitalList[index].painFrequency ?? "-"}",
                                              fontWeight: FontWeight.w700,
                                              color: Color(0XFF28353E),
                                              fontSize:
                                                  SizeConfig.textMultiplier! *
                                                      1.3,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            ),
                            Expanded(
                              child: Container(
                                padding: EdgeInsets.symmetric(horizontal: 8),
                                child: Center(
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: [
                                      AppText(
                                        "${AppDateUtils.convertDateFromServerFormat(vitalList[index].createdOn, "E , dd MMM")}",
                                        fontWeight: FontWeight.w700,
                                        color: Color(0XFF28353E),
                                        fontSize: SizeConfig.textMultiplier! * 1.6,
                                      ),
                                      AppText(
                                        "${AppDateUtils.convertDateFromServerFormat(vitalList[index].createdOn, "hh:mm a")}",
                                        fontWeight: FontWeight.w700,
                                        color: Color(0XFF28353E),
                                        fontSize: SizeConfig.textMultiplier! * 1.6,
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: 8,
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
