import 'package:doctor_app_flutter/providers/referral_patient_provider.dart';
import 'package:doctor_app_flutter/providers/schedule_provider.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/doctor/my_referral_patient_widget.dart';
import 'package:doctor_app_flutter/widgets/doctor/my_schedule_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../widgets/shared/app_scaffold_widget.dart';

class MyReferralPatient extends StatelessWidget {
  MyReferralPatientProvider referralPatientProvider;

  @override
  Widget build(BuildContext context) {
    referralPatientProvider = Provider.of(context);
    return AppScaffold(
      appBarTitle: TranslationBase.of(context).myReferralPatient,
      body: referralPatientProvider.isLoading
          ? DrAppCircularProgressIndeicator()
          : referralPatientProvider.isError
              ? Center(
                  child: AppText(
                    referralPatientProvider.error,
                    color: Theme.of(context).errorColor,
                  ),
                )
              : referralPatientProvider.listMyReferralPatientModel.length == 0
                  ? Center(
                      child: AppText(
                        TranslationBase.of(context).errorNoSchedule,
                        color: Theme.of(context).errorColor,
                      ),
                    )
                  : Container(
                      padding: EdgeInsetsDirectional.fromSTEB(20, 0, 20, 0),
                      child: ListView(
                        children: <Widget>[
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              SizedBox(
                                height: 10,
                              ),
                              Container(
                                child: Column(
                                  children: referralPatientProvider
                                      .listMyReferralPatientModel
                                      .map((item) {
                                    return MyReferralPatientWidget(
                                      myReferralPatientModel: item,
                                    );
                                  }).toList(),
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
    );
  }
}
