/*
 * @author lsy
 * @date   2019-09-24
 **/
import 'package:flutter/services.dart';
import 'package:rxdart/rxdart.dart';

const platform = const MethodChannel('flutter_bury_channel');

Observable<bool> pageStart(String nowPage, String beforPage, int time) {
  return Observable.fromFuture(platform.invokeMethod(
      "PAGE_START", {"page_name": nowPage, "referrer": beforPage, "in": time}));
}

Observable<bool> pageEnd(String nowPage, String beforPage, int time) {
  return Observable.fromFuture(platform.invokeMethod(
      "PAGE_END", {"page_name": nowPage, "referrer": beforPage, "out": time}));
}

Observable<bool> click(String page_name, String button_name) {
  return Observable.fromFuture(platform.invokeMethod(
      "CLICK_EVENT", {"page_name": page_name, "button_name": button_name}));
}

Observable<bool> jumpToH5() {
  return Observable.fromFuture(platform.invokeMethod("FLUTTER_TO_H5"));
}

Observable<bool> jumpToPictorial(String url) {
  return Observable.fromFuture(
      platform.invokeMethod("FLUTTER_TO_PICTORIAL", {"url": url}));
}

Observable<bool> jumpToSearch() {
  return Observable.fromFuture(platform.invokeMethod("FLUTTER_TO_SEARCH"));
}
