import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/Steps/stepsTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/distance/distanceTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/heartrate/heartrateTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/syncHealthData.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';

// import 'package:fit_kit/fit_kit.dart';
import 'package:flutter/material.dart';

class HealthDataList extends StatefulWidget {
  @override
  _HealthDataListState createState() => _HealthDataListState();
}

class _HealthDataListState extends State<HealthDataList> {
  // List<DataType> dataTypes = List();

  @override
  void initState() {
    // dataTypes.add(DataType.DISTANCE);
    // dataTypes.add(DataType.STEP_COUNT);
    // dataTypes.add(DataType.HEART_RATE);
    // dataTypes.add(DataType.SLEEP);
    // dataTypes.add(DataType.ENERGY);

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    List<Widget> myMedicalList = myOptionsList(context);
    return AppScaffold(
      appBarTitle: TranslationBase.of(context).smartWatches,
      isShowAppBar: true,
      showNewAppBar: true,
      backgroundColor: Color(0xffF7F7F7),
      showNewAppBarTitle: true,
      body: Column(
        children: [
          Expanded(
            child: GridView.builder(
              physics: BouncingScrollPhysics(),
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
              padding: EdgeInsets.all(21),
              itemCount: myMedicalList.length,
              itemBuilder: (BuildContext context, int index) {
                return myMedicalList[index];
              },
            ),
          ),
          syncHealthDataButton(),
        ],
      ),
    );
  }

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

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: HeartRateTracker()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).heart,
        imagePath: 'assets/images/SmartWatches/heartrate_icon.png',
        subTitle: null,
        isPngImage: true,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: StepsTracker()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).steps,
        imagePath: 'assets/images/SmartWatches/steps.png',
        subTitle: null,
        isPngImage: true,
      ),
    ));

    medical.add(InkWell(
      onTap: () => Navigator.push(
        context,
        FadePage(page: DistanceTracker()),
      ),
      child: MedicalProfileItem(
        title: TranslationBase.of(context).distance,
        imagePath: 'assets/images/SmartWatches/distance.png',
        subTitle: null,
        isPngImage: true,
      ),
    ));

    return medical;
  }

// void readLast() async {
//   print("ReadLast");
//   final result = await FitKit.readLast(DataType.DISTANCE);
//   print(result);
//   print(result);
// }
//
// void readAll() async {
//   if (await FitKit.requestPermissions(dataTypes)) {
//     for (DataType type in dataTypes) {
//       final results = await FitKit.read(
//         type,
//         dateFrom: DateTime.now().subtract(Duration(days: 7)),
//         dateTo: DateTime.now(),
//         limit: 100,
//       );
//       print(results);
//       print(results.length);
//     }
//     readLast();
//   }
// }
}
