import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'health_calculator/bmi_calculator/bmi_calculator.dart';
import 'health_calculator/bmr_calculator/bmr_calculator.dart';
import 'health_calculator/calorie_calculator/calorie_calculator.dart';
import 'health_calculator/delivery_due/delivery_due.dart';
import 'health_calculator/ideal_body/ideal_body.dart';

class HealthCalculators extends StatefulWidget {
  @override
  _HealthCalculatorsState createState() => _HealthCalculatorsState();
}

class _HealthCalculatorsState extends State<HealthCalculators> with SingleTickerProviderStateMixin {
  TabController _tabController;
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

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

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowAppBar: true,
      isShowDecPage: false,
      appBarTitle: TranslationBase.of(context).calculators,
      body: Scaffold(
        extendBodyBehindAppBar: true,
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(70.0),
          child: Stack(
            children: [
              Center(
                child: Container(
                  height: 60.0,
                  margin: EdgeInsets.only(top: 10.0),
                  width: MediaQuery.of(context).size.width * 1.9,
                  decoration: BoxDecoration(
                    border: Border(
                      bottom: BorderSide(
                        color: Theme.of(context).dividerColor,
                        width: 5.7,
                      ),
                    ),
                    color: Colors.white,
                  ),
                  child: Center(
                    child: TabBar(
                      controller: _tabController,
                      isScrollable: true,
                      indicatorWeight: 4.0,
                      indicatorColor: Colors.red,
                      labelColor: Theme.of(context).buttonColor,
                      labelPadding: EdgeInsets.symmetric(horizontal: 13.0, vertical: 2.0),
                      unselectedLabelColor: Colors.grey,
                      tabs: <Widget>[
                        Container(
                          width: MediaQuery.of(context).size.width * 0.35,
                          child: Center(
                            child: Texts(TranslationBase.of(context).generalHealth),
                          ),
                        ),
                        Container(
                          width: MediaQuery.of(context).size.width * 0.35,
                          child: Center(
                            child: Texts(TranslationBase.of(context).womanHealth),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
        body: Column(
          children: [
            Expanded(
              child: TabBarView(
                physics: BouncingScrollPhysics(),
                controller: _tabController,
                children: [
                  Container(
                    child: Column(
                      children: [
                        Container(
                          width: double.infinity,
                          height: 80,
                        ),
                        Row(
                          children: [
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(page: BMICalculator()),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).bmi,
                                  imagePath: 'bmi_health_calculator.png',
                                  subTitle: TranslationBase.of(context).calcHealth,
                                ),
                              ),
                            ),
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: CalorieCalculator(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).calories,
                                  imagePath: 'calories-calculator.png',
                                  subTitle: TranslationBase.of(context).calcHealth,
                                ),
                              ),
                            ),
                          ],
                        ),
                        Row(
                          children: [
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: BmrCalculator(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).bmr,
                                  imagePath: 'BMR_calculator.png',
                                  subTitle: TranslationBase.of(context).calcHealth,
                                ),
                              ),
                            ),
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: IdealBody(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).idealBody,
                                  imagePath: 'body_weight.png',
                                  subTitle: TranslationBase.of(context).weight,
                                ),
                              ),
                            ),
                          ],
                        ),
                        Row(
                          children: [
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: BodyFat(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).bodyWord,
                                  imagePath: 'body_fat.png',
                                  subTitle: TranslationBase.of(context).fat,
                                ),
                              ),
                            ),
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: Carbs(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).carbohydrate,
                                  imagePath: 'carb_protein.png',
                                  subTitle: TranslationBase.of(context).proteinFat,
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Container(
                    child: Column(
                      children: [
                        Container(
                          width: double.infinity,
                          height: 80,
                        ),
                        Row(
                          children: [
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(page: OvulationPeriod()),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).ovulation,
                                  imagePath: 'ovulation_period_icon.png',
                                  subTitle: TranslationBase.of(context).period,
                                ),
                              ),
                            ),
                            Expanded(
                              flex: 1,
                              child: InkWell(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    FadePage(
                                      page: DeliveryDue(),
                                    ),
                                  );
                                },
                                child: MedicalProfileItem(
                                  title: TranslationBase.of(context).delivery,
                                  imagePath: 'delivery_date_icon.png',
                                  subTitle: TranslationBase.of(context).dueDate,
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
