using Newtonsoft.Json.Linq;
using ReactNative.Bridge;
using ReactNative.UIManager;
using System;
using System.IO;
using System.Collections.Generic;
namespace RNViewShot
{
///
/// A module that allows JS to share data.
///
class RNViewShotModule : ReactContextNativeModuleBase
{
private const string ErrorUnableToSnapshot = "E_UNABLE_TO_SNAPSHOT";
private readonly ReactContext _reactContext;
///
/// Instantiates the .
///
public RNViewShotModule(ReactContext reactContext) : base(reactContext)
{
this._reactContext = reactContext;
}
///
/// The name of the native module.
///
public override string Name
{
get
{
return "RNViewShot";
}
}
[ReactMethod]
public void takeSnapshot(int tag, JObject options, IPromise promise)
{
string format = options["format"] != null ? options.Value("format") : "png";
double quality = options["quality"] != null ? options.Value("quality") : 1.0;
int? width = options["width"] != null ? options.Value("width") : null;
int? height = options["height"] != null ? options.Value("height") : null;
string result = options["result"] != null ? options.Value("result") : "file";
UIManagerModule uiManager = this._reactContext.GetNativeModule();
uiManager.AddUIBlock(new ViewShot(tag, format, quality, width, height, result, promise));
}
}
}