import 'dart:async';

import 'package:async/src/result/result.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:hmg_patient_app_new/features/smartwatch_health_data/watch_connectors/watch_helper.dart';
import 'package:huawei_health/huawei_health.dart';

class HuaweiHealthDataConnector  extends WatchHelper{
  final  MethodChannel _channel = MethodChannel('huawei_watch');
  @override
  Future<Result<bool>> initDevice() async{
    try{
      await _channel.invokeMethod('init');

    }catch(e){

    }
    // List of scopes to ask for authorization.
  // Note: These scopes should also be authorized on the Huawei Developer Console.
    List<Scope> scopes = [
      Scope.HEALTHKIT_STEP_READ, Scope.HEALTHKIT_OXYGEN_SATURATION_READ,  // View and store height and weight data in Health Service Kit.
      Scope.HEALTHKIT_HEARTRATE_READ, Scope.HEALTHKIT_SLEEP_READ,
      Scope.HEALTHKIT_BODYTEMPERATURE_READ, Scope.HEALTHKIT_CALORIES_READ
    ];
    try {
      bool? result = await SettingController.getHealthAppAuthorization();
      debugPrint(
        'Granted Scopes for result == is $result}',
      );
      return Result.value(true);
    } catch (e) {
      debugPrint('Error on authorization, Error:${e.toString()}');
      return Result.error(false);
    }
  }

  @override
  Future<void> getActivity() async {
    DataType dataTypeResult = await SettingController.readDataType(
     DataType.DT_CONTINUOUS_STEPS_DELTA.name
    );


  }

  @override
  Future getBloodOxygen() {
    throw UnimplementedError();

  }

  @override
  Future getBodyTemperature() {

    throw UnimplementedError();
  }

  @override
  FutureOr<void> getHeartRate() {
    throw UnimplementedError();
  }

  @override
  FutureOr<void> getSleep() {
    throw UnimplementedError();
  }

  @override
  FutureOr<void> getSteps() {
    throw UnimplementedError();
  }


  @override
  Future retrieveData() {
    throw UnimplementedError();
  }

  @override
  FutureOr<void> getDistance() {
    // TODO: implement getDistance
    throw UnimplementedError();
  }

}