
import 'dart:async';

import 'package:async/async.dart';
import 'package:flutter/services.dart';
class SamsungPlatformChannel {
  final  MethodChannel _channel = MethodChannel('samsung_watch');
  Future<Result<bool>> initDevice() async {
      try{
        await _channel.invokeMethod('init');
        return Result.value(true);
      }catch(e){
        return Result.error(e);
      }
  }

  Future<Result<bool>> getRequestedPermission() async {
    try{
      await _channel.invokeMethod('getPermission');
      return Result.value(true);
    }catch(e){
      return Result.error(e);
    }
  }
  Future<Result<bool>> getHeartRate() async {
    try{
      await _channel.invokeMethod('getHeartRate');
      return Result.value(true);
    }catch(e){
      return Result.error(e);
    }
  }
  Future<Result<bool>> getSleep() async {
    try{
      await _channel.invokeMethod('getSleepData');
      return Result.value(true);
    }catch(e){
      return Result.error(e);
    }
  }
  Future<Result<bool>> getSteps() async {
    try{
      await _channel.invokeMethod('steps');
      return Result.value(true);
    }catch(e){
      return Result.error(e);
    }
  }

  Future<Result<bool>> getActivity() async {
    try{
      await _channel.invokeMethod('activitySummary');
      return Result.value(true);
    }catch(e){
      return Result.error(e);
    }
  }

  Future<Result<dynamic>> retrieveData() async {
    try{
      return Result.value(await _channel.invokeMethod('retrieveData'));
    }catch(e){
      return Result.error(e);
    }
  }

  Future<Result<dynamic>> getBloodOxygen() async {
    try{
      return Result.value(await _channel.invokeMethod('bloodOxygen'));
    }catch(e){
      return Result.error(e);
    }
  }

  Future<Result<dynamic>> getBodyTemperature() async {
    try{
      return Result.value(await _channel.invokeMethod('bodyTemperature'));
    }catch(e){
      return Result.error(e);
    }
  }

  Future<FutureOr<void>> getDistance() async {
    try{
      return Result.value(await _channel.invokeMethod('distance'));
    }catch(e){
      return Result.error(e);
    }
  }
}