import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/data_display/medical/medical_profile_item.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';

import 'health_converter/blood_cholesterol.dart';
import 'health_converter/blood_sugar.dart';
import 'health_converter/triglycerides.dart';

class HealthConverter extends StatefulWidget {
  @override
  _HealthConverterState createState() => _HealthConverterState();
}

class _HealthConverterState extends State<HealthConverter> {
  @override
  Widget build(BuildContext context) {
    List<Widget> myMedicalList = myOptionsList(context);

    return AppScaffold(
      isShowAppBar: true,
      isShowDecPage: false,
      showNewAppBar: true,
      showNewAppBarTitle: true,
      appBarTitle: TranslationBase.of(context).converters,
      body: Column(
        children: [
          Padding(
            padding: EdgeInsets.only(left: 12, right: 12, top: 20.0),
            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];
              },
            ),
          ),
        ],
      ),
    );
  }

  List<Widget> myOptionsList(BuildContext context) {
    List<Widget> medical =[];

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: BloodSugar()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).bloodSugar,
        imagePath: 'sugar-blood-level.svg',
        subTitle: TranslationBase.of(context).sugar,
        isPngImage: false,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: BloodCholesterol()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).bloodCholesterol,
        imagePath: 'cholesterol.svg',
        subTitle: TranslationBase.of(context).cholesterol,
        isPngImage: false,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: Triglycerides()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).triglycerides,
        imagePath: 'fat.svg',
        subTitle: TranslationBase.of(context).fatInBlood,
        isPngImage: false,
      ),
    ));
    return medical;
  }
}
