import 'package:diplomaticquarterapp/core/model/er/TriageInformationRequest.dart';
import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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';
import 'EdOnlineAgreementPage.dart';
import 'EdOnlineNotesPage.dart';
import 'EdOnlineQuestionsPage.dart';
import 'EdOnlineSelectedHospitalPage.dart';
import 'EdPaymentInformationPage.dart';

class DdServicesPage extends StatefulWidget {
  @override
  _DdServicesPageState createState() => _DdServicesPageState();
}

class _DdServicesPageState extends State<DdServicesPage> {
  PageController pageController;

  bool isAgree = false;
  TriageInformationRequest triageInformationRequest = new TriageInformationRequest();

  List<TriageQuestionsModel> selectedQuestions = List();

  @override
  void initState() {
    super.initState();
    pageController = new PageController();
  }

  _changePageViewIndex(int tab) {
    setState(() {
      pageController.jumpToPage(tab);
      pageController.animateToPage(tab, duration: Duration(milliseconds: 800), curve: Curves.easeOutQuart);
    });
  }

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return AppScaffold(
      appBarTitle: 'ED Online',
      isShowDecPage: true,
      isShowAppBar: true,
      // appBarTitle: AppBar(
      //   elevation: 0,
      //   textTheme: TextTheme(
      //     headline6: TextStyle(
      //         color: Theme.of(context).textTheme.headline1.color,
      //         fontWeight: FontWeight.bold),
      //   ),
      //   title: Text(
      //     'ED Online',
      //     style: TextStyle(
      //         fontWeight: FontWeight.bold,
      //         color: Theme.of(context).textTheme.headline1.color,
      //         fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'),
      //     // bold: true,
      //     // color: Colors.white,
      //   ),
      //   leading: Builder(
      //     builder: (BuildContext context) {
      //       return IconButton(
      //         icon: Icon(Icons.arrow_back),
      //         color: Theme.of(context).textTheme.headline1.color,
      //         onPressed: () {
      //           showConfirmMessage(context);
      //         },
      //       );
      //     },
      //   ),
      //   centerTitle: true,
      // ),
      body: PageView(
        physics: NeverScrollableScrollPhysics(),
        controller: pageController,
        onPageChanged: _changePageViewIndex,
        children: [
          EdOnlineSelectedHospitalPage(
            changePageViewIndex: _changePageViewIndex,
            triageInformationRequest: triageInformationRequest,
          ),
          EdOnlineAgreementPage(
            changePageViewIndex: _changePageViewIndex,
            isAgree: isAgree,
          ),
          EdOnlineQuestionsPage(
            changePageViewIndex: _changePageViewIndex,
            selectedQuestions: selectedQuestions,
          ),
          EdOnlineNotesPage(
            changePageViewIndex: _changePageViewIndex,
            selectedQuestions: selectedQuestions,
            triageInformationRequest: triageInformationRequest,
          ),
          EdPaymentInformationPage(
            selectedHospital: triageInformationRequest.selectedHospital,
          )
        ],
      ),
    );
  }
}
