import 'dart:ui';

import 'package:diplomaticquarterapp/core/enum/filter_type.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/new_design/my_tab_view.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'ask_doctor_page.dart';
import 'doctor_response.dart';

class AskDoctorHomPage extends StatefulWidget {
  @override
  _AskDoctorHomPageState createState() => _AskDoctorHomPageState();
}

class _AskDoctorHomPageState extends State<AskDoctorHomPage> with SingleTickerProviderStateMixin {
  TabController _tabController;

  int filterType = 0;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowAppBar: true,
      appBarTitle: TranslationBase.of(context).askDoctor,
      showNewAppBar: true,
      showNewAppBarTitle: true,
      backgroundColor: Color(0xffF8F8F8),
      isShowDecPage: true,
      description: TranslationBase.of(context).infoAskDoc,
      imagesInfo: [
        ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/ask-doctor/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/ask-doctor/ar/0.png'),
        ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/ask-doctor/en/1.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/ask-doctor/ar/1.png')
      ],
      body: Column(
        children: [
          Row(
            children: [
              MyTabView(TranslationBase.of(context).askDoctor, FilterType.Clinic, filterType == 0 ? FilterType.Clinic : FilterType.Hospital, () {
                if (filterType != 0)
                  setState(() {
                    filterType = 0;
                  });
              }),
              MyTabView(TranslationBase.of(context).doctorResponses, FilterType.Hospital, filterType != 0 ? FilterType.Hospital : FilterType.Clinic, () {
                if (filterType == 0)
                  setState(() {
                    filterType = 1;
                  });
              }),
            ],
          ),
          Expanded(
            child: IndexedStack(
              index: filterType,
              children: [AskDoctorPage(), DoctorResponse()],
            ),
          )
        ],
      ),
    );
  }
}
