import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/time_line_new_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class MedicalProfilePageNew extends StatefulWidget {
  Function onTap;
  String a;
  MedicalProfilePageNew({this.onTap});
  @override
  _MedicalProfilePageState createState() => _MedicalProfilePageState();
}

class _MedicalProfilePageState extends State<MedicalProfilePageNew> {
  var authProvider = new AuthProvider();
  List<Medical> medical = List();
  ProjectViewModel projectViewModel;

  @override
  Widget build(BuildContext context) {
    projectViewModel = Provider.of(context);
    var appoCountProvider = Provider.of<ToDoCountProviderModel>(context);
    List<Widget> myMedicalList = Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin);
    return BaseView<MedicalViewModel>(
      onModelReady: (model) => model.getAppointmentHistory(),
      builder: (_, model, widget1) => AppScaffold(
        isShowDecPage: false,
        isShowAppBar: false,
        baseViewModel: model,
        showNewAppBar: true,
        isHelp: true,
        showNewAppBarTitle: true,
        appBarTitle: TranslationBase.of(context).medicalFileTitle,
        onTap: widget.onTap,
        body: Container(
          child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                TimeLineView(model.isLogin, projectViewModel.isArabic, model.appoitmentAllHistoryResultList),
                SizedBox(
                  height: 20,
                ),
                Padding(
                  padding: EdgeInsets.only(left: 12, right: 12),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      projectViewModel.isLogin
                          ? Text(
                              projectViewModel?.user?.firstName ?? "",
                              style: TextStyle(color: Colors.black, fontSize: SizeConfig.textMultiplier * 1.8),
                            )
                          : Container(),
                      Text(
                        TranslationBase.of(context).medicalFileTitle,
                        style: TextStyle(
                          color: Colors.black,
                          fontSize: SizeConfig.textMultiplier * 3,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ],
                  ),
                ),
                SizedBox(
                  height: 20,
                ),
                Padding(
                  padding: EdgeInsets.only(left: 12, right: 12),
                  child: GridView.builder(
                    shrinkWrap: true,
                    primary: false,
                    physics: NeverScrollableScrollPhysics(),
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
                    padding: EdgeInsets.zero,
                    itemCount: myMedicalList.length,
                    itemBuilder: (BuildContext context, int index) {
                      return myMedicalList[index];
                    },
                  ),
                ),
                SizedBox(
                  height: 12,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class Medical {
  final String title;
  final String imagePath;
  final String subTitle;
  final Widget page;

  Medical({this.title, this.imagePath, this.subTitle, this.page});
}
