import 'package:diplomaticquarterapp/core/model/ask_doctor/DoctorResponse.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/ask_doctor_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ViewDoctorResponsesPage extends StatelessWidget {
  final DoctorResponse doctorResponse;

  const ViewDoctorResponsesPage({Key key, this.doctorResponse}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BaseView<AskDoctorViewModel>(
      onModelReady: (model) => model.updateReadStatus(transactionNo: doctorResponse.transactionNo),
      builder: (_, model, w) => AppScaffold(
        isShowAppBar: true,
        showNewAppBar: true,
        showNewAppBarTitle: true,
        backgroundColor: Color(0xffF8F8F8),
        isShowDecPage: false,
        appBarTitle: TranslationBase.of(context).viewDoctorResponses,
        baseViewModel: model,
        body: SingleChildScrollView(
          child: Container(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [getResponsesList()],
            ),
          ),
        ),
      ),
    );
  }

  Widget getResponsesList() {
    return ListView.separated(
        shrinkWrap: true,
        physics: NeverScrollableScrollPhysics(),
        padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21),
        itemBuilder: (context, _index) {
          return Container(
            padding: const EdgeInsets.only(left: 20, right: 12, top: 12, bottom: 12),
            height: 130,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(
                  Radius.circular(10.0),
                ),
                border: Border.all(width: 1, color: Color(0xffEFEFEF)),
                boxShadow: [
                  BoxShadow(
                    color: Color(0xff000000).withOpacity(.05),
                    //spreadRadius: 5,
                    blurRadius: 27,
                    offset: Offset(0, -3),
                  ),
                ],
                color: Colors.white),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  child: Text(
                    (doctorResponse.doctorName ?? ""),
                    style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w600,
                      color: Color(0xff2E303A),
                      letterSpacing: -0.64,
                    ),
                  ),
                ),
                Container(
                  child: Text(
                    (DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(doctorResponse.createdOn)) ?? ""),
                    style: TextStyle(
                      fontSize: 14,
                      color: Color(0xff2E303A),
                      letterSpacing: -0.64,
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 10.0),
                  child: Text(
                    doctorResponse.transactions[_index]['InfoStatusDescription'],
                    style: TextStyle(
                      fontSize: 16,
                      color: Color(0xff2E303A),
                      letterSpacing: -0.64,
                    ),
                  ),
                ),
              ],
            ),
          );
        },
        separatorBuilder: (context, index) => SizedBox(height: 14),
        itemCount: doctorResponse.transactions.length);
  }
}
