UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

46 lines (43 loc) • 1.73 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { useState } from "react"; import { StyleSheet, View } from "react-native"; import NativeKotlinHost from "../specs/OneKotlinHostNativeComponent.native.js"; import { decodeNativeSourceCallback, encodeNativeSourceProps } from "./wire.native.js"; function KotlinSourceView(param) { var { source, view, contractHash, props, wires } = param; var [contentSize, setContentSize] = useState(); var encoded = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : props; return /* @__PURE__ */ jsxs(View, { style: props.style, collapsable: false, children: [/* @__PURE__ */ jsx(View, { pointerEvents: "none", style: contentSize }), /* @__PURE__ */ jsx(NativeKotlinHost, { source, view, contractHash, props: JSON.stringify(encoded, function(_key, value) { return typeof value === "function" ? true : value; }), onHostEvent: function onHostEvent(event) { var callback = props[event.nativeEvent.name]; if (typeof callback === "function") { var _ref; var args = JSON.parse(event.nativeEvent.args); var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name]; callback(...argWires ? decodeNativeSourceCallback(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args); } }, onHostSizeChange: function onHostSizeChange(event) { setContentSize({ width: event.nativeEvent.width, height: event.nativeEvent.height }); }, style: StyleSheet.absoluteFill })] }); } export { KotlinSourceView }; //# sourceMappingURL=view.native.js.map