replyke-rn
Version:
Replyke React Native components: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
47 lines • 2.28 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.SheetManagerProvider = exports.SheetManagerContext = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
exports.SheetManagerContext = (0, react_1.createContext)({});
var SheetManagerProvider = function (_a) {
var children = _a.children;
var commentOptionsSheetRef = (0, react_1.useRef)(null);
var reportCommentSheetRef = (0, react_1.useRef)(null);
var _b = (0, react_1.useState)(null), optionsComment = _b[0], setOptionsComment = _b[1];
var _c = (0, react_1.useState)(null), reportedComment = _c[0], setReportedComment = _c[1];
var openCommentOptionsSheet = function (newComment) {
var _a;
if (newComment)
setOptionsComment(newComment);
(_a = commentOptionsSheetRef.current) === null || _a === void 0 ? void 0 : _a.snapToIndex(0);
};
var closeCommentOptionsSheet = function () {
var _a;
(_a = commentOptionsSheetRef.current) === null || _a === void 0 ? void 0 : _a.close();
};
var openReportCommentSheet = function (newComment) {
var _a;
if (newComment)
setOptionsComment(newComment);
(_a = reportCommentSheetRef.current) === null || _a === void 0 ? void 0 : _a.snapToIndex(0);
};
var closeReportCommentSheet = function () {
var _a;
(_a = reportCommentSheetRef.current) === null || _a === void 0 ? void 0 : _a.close();
};
return ((0, jsx_runtime_1.jsx)(exports.SheetManagerContext.Provider, { value: {
commentOptionsSheetRef: commentOptionsSheetRef,
reportCommentSheetRef: reportCommentSheetRef,
openCommentOptionsSheet: openCommentOptionsSheet,
closeCommentOptionsSheet: closeCommentOptionsSheet,
openReportCommentSheet: openReportCommentSheet,
closeReportCommentSheet: closeReportCommentSheet,
optionsComment: optionsComment,
setOptionsComment: setOptionsComment,
reportedComment: reportedComment,
setReportedComment: setReportedComment,
}, children: children }));
};
exports.SheetManagerProvider = SheetManagerProvider;
//# sourceMappingURL=SheetManagerContext.js.map
;