UNPKG

clubzella-comic-test-v1

Version:

A clubzella widget component library for React Native.

281 lines (276 loc) 13.9 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_native_1 = require("react-native"); var react_1 = __importStar(require("react")); var Ionicons_1 = __importDefault(require("@expo/vector-icons/Ionicons")); var AntDesign_1 = __importDefault(require("@expo/vector-icons/AntDesign")); // @ts-ignore var NewReleases_1 = __importDefault(require("./NewReleases")); var InComicsPanel_1 = __importDefault(require("./InComicsPanel")); var API_URL_1 = require("./constants/API_URL"); var expo_router_1 = require("expo-router"); var vector_icons_1 = require("@expo/vector-icons"); var Pantheon_1 = __importDefault(require("./Pantheon")); var InPantheonPanel_1 = __importDefault(require("./InPantheonPanel")); var _a = react_native_1.Dimensions.get("window"), height = _a.height, width = _a.width; var EpisodesPanel = function (_a) { var _b = _a.visible, visible = _b === void 0 ? false : _b, setOpenEpisodesPanel = _a.setOpenEpisodesPanel, title = _a.title, series_id = _a.series_id, apiKey = _a.apiKey; var _c = (0, react_1.useState)(true), expand = _c[0], setExpand = _c[1]; var _d = (0, react_1.useState)(false), openInComicsPanel = _d[0], setOpenInComicsPanel = _d[1]; var _e = (0, react_1.useState)(false), openInPantheonPanel = _e[0], setOpenInPantheonPanel = _e[1]; var _f = (0, react_1.useState)(), episode = _f[0], setEpisode = _f[1]; var _g = (0, react_1.useState)(), pantheon = _g[0], setPantheon = _g[1]; var poster = require("../../assets/images/widget/clubzella-zella-poster.png"); var handleSetEpisode = function (episode) { setEpisode(episode); }; var handleSetPantheon = function (pantheon) { setPantheon(pantheon); }; var _h = (0, react_1.useState)(true), isLoading = _h[0], setIsLoading = _h[1]; var _j = (0, react_1.useState)([]), episodes = _j[0], setEpisodes = _j[1]; var fetch_url = "".concat(API_URL_1.API_URL, "/comics/episodes"); (0, react_1.useEffect)(function () { var response = fetch(fetch_url, { headers: { "merchant-x-secret": "".concat(apiKey) }, }); response.then(function (data) { return __awaiter(void 0, void 0, void 0, function () { var text, episodes_, error_1; var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, 3, 4]); return [4 /*yield*/, data.text()]; case 1: text = _b.sent(); if (text) { episodes_ = (_a = JSON.parse(text)) === null || _a === void 0 ? void 0 : _a.data; if (episodes_) { setEpisodes(episodes_); } } return [3 /*break*/, 4]; case 2: error_1 = _b.sent(); console.log(error_1); return [3 /*break*/, 4]; case 3: setIsLoading(false); return [7 /*endfinally*/]; case 4: return [2 /*return*/]; } }); }); }); }, []); (0, react_1.useEffect)(function () { if (openInComicsPanel || openInPantheonPanel) { setExpand(false); } else { setExpand(true); } }, [openInComicsPanel, openInPantheonPanel]); return (<> <react_native_1.View style={[ { zIndex: 1100, borderRadius: 15, justifyContent: "center", // alignItems: "center", position: "absolute", bottom: 20, right: 15, width: width - 30, // height: 140, backgroundColor: "#fff", height: expand ? height / 1.5 : 140, elevation: 4, }, ]}> <react_native_1.Animated.View> <react_native_1.View style={{ minHeight: 35, width: "100%", backgroundColor: "#393535", borderTopStartRadius: 15, borderTopEndRadius: 15, padding: 11, flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 10, }}> <react_native_1.Text style={{ color: "#F5F5F5", fontSize: 24, lineHeight: 24, fontFamily: "MamaKilo", textTransform: "uppercase", }}> {title} </react_native_1.Text> <react_native_1.TouchableOpacity activeOpacity={0.6} onPress={function () { return setExpand(!expand); }}> <Ionicons_1.default name="expand" size={24} color="#fff"/> </react_native_1.TouchableOpacity> <react_native_1.View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 10, }}> <react_native_1.TouchableOpacity activeOpacity={0.6} onPress={function () { return setOpenEpisodesPanel(!visible); }}> <AntDesign_1.default name="close" size={24} color="#FF4D52"/> </react_native_1.TouchableOpacity> </react_native_1.View> </react_native_1.View> </react_native_1.Animated.View> <react_native_1.ScrollView style={{ height: "100%", width: "100%" }}> <react_native_1.View style={{ gap: 16 }}> {expand && (<react_native_1.View style={{ position: "relative", padding: 12, paddingBottom: 0 }}> <react_native_1.Image source={poster} style={{ width: "100%", height: 112, borderRadius: 10 }}/> <react_native_1.View style={{ position: "absolute", padding: 26, top: 0, left: 0, width: "100%", height: "100%", }}> <react_native_1.View style={{ marginBlock: "auto" }}> <react_native_1.View style={{ flexDirection: "row", alignItems: "center", gap: 5, }}> <Ionicons_1.default name="headset-sharp" size={24} color="#5DF092"/> <react_native_1.Text style={{ color: "#fff", fontSize: 16, fontWeight: 500 }}> Zella sounds </react_native_1.Text> </react_native_1.View> <react_native_1.Text style={{ color: "#fff", fontSize: 12, fontWeight: 300, width: "50%", marginTop: 5, }}> Listen to the sound track that make the gods dance. </react_native_1.Text> <expo_router_1.Link style={{ marginTop: 5, }} href={"/"}> <react_native_1.View style={{ flexDirection: "row", alignItems: "center", gap: 5, }}> <react_native_1.Text style={{ fontSize: 12, color: "#5DF092" }}> Zellasounds.spotify </react_native_1.Text> <react_native_1.View style={{ backgroundColor: "#5DF092", height: 18, width: 18, borderRadius: 18, justifyContent: "center", alignItems: "center", }}> <vector_icons_1.MaterialCommunityIcons name="arrow-top-right" size={14} color="#000"/> </react_native_1.View> </react_native_1.View> </expo_router_1.Link> </react_native_1.View> </react_native_1.View> </react_native_1.View>)} {isLoading ? (<react_native_1.View style={{ height: expand ? 500 : "auto", justifyContent: "center", }}> <react_native_1.ActivityIndicator size={"large"}/> </react_native_1.View>) : (<react_native_1.View> <react_native_1.View style={{ paddingInline: 12 }}> <NewReleases_1.default handleSetEpisode={handleSetEpisode} openInComicsPanel={openInComicsPanel} setOpenInComicsPanel={setOpenInComicsPanel} episodes={episodes}/> </react_native_1.View> <Pantheon_1.default handleSetPantheon={handleSetPantheon} openInPantheonPanel={openInPantheonPanel} setOpenInPantheonPanel={setOpenInPantheonPanel}/> </react_native_1.View>)} </react_native_1.View> </react_native_1.ScrollView> </react_native_1.View> {openInComicsPanel && (<InComicsPanel_1.default title={episode === null || episode === void 0 ? void 0 : episode.title} visible={openInComicsPanel} setOpenInComicsPanel={setOpenInComicsPanel} episode_id={episode === null || episode === void 0 ? void 0 : episode.id} series_id={episode === null || episode === void 0 ? void 0 : episode.comics_series_id} apiKey={apiKey}/>)} {openInPantheonPanel && (<InPantheonPanel_1.default title={pantheon === null || pantheon === void 0 ? void 0 : pantheon.title} visible={openInPantheonPanel} setOpenInPantheonPanel={setOpenInPantheonPanel} apiKey={apiKey} pantheon={pantheon}/>)} </>); }; exports.default = EpisodesPanel;