vd-plugins/ServerDrawer/index.js

2 lines
18 KiB
JavaScript
Raw Permalink Normal View History

(function(j,s,k,n,o,F,ie){"use strict";const He="[ServerDrawer]";function Ge(e){const t=s.findByProps("useIsMobileQuestDockRendered");if(!t?.useIsMobileQuestDockRendered)return console.log(He,"WARN: useIsMobileQuestDockRendered not found"),!1;const r=t.useIsMobileQuestDockRendered;return t.useIsMobileQuestDockRendered=function(...i){return r.apply(this,i),!0},e.push(function(){t.useIsMobileQuestDockRendered=r}),!0}const We="[ServerDrawer]";function Oe(e){const t=s.findByProps("useIsMobileQuestDockRenderedBase");if(!t?.useIsMobileQuestDockRenderedBase)return console.log(We,"WARN: useIsMobileQuestDockRenderedBase not found"),!1;const r=t.useIsMobileQuestDockRenderedBase;return t.useIsMobileQuestDockRenderedBase=function(...i){return r.apply(this,i),!0},e.push(function(){t.useIsMobileQuestDockRenderedBase=r}),!0}const _e="[ServerDrawer]";function Le(e){const t=s.findByProps("useMobileQuestDock");if(!t.useMobileQuestDock)return console.log(_e,"WARN: useMobileQuestDock not found"),!1;const r=t.useMobileQuestDock;return t.useMobileQuestDock=function(...i){return r.apply(this,i)||{id:"server-drawer",config:{quest_content_type:0,assets:{questBarHeroVideo:null,questBarHero:null},features:[]},userStatus:{enrolledAt:"2099-01-01",claimedAt:null},benefits:{rewards:[]},guildId:"0",tasks:[]}},e.push(function(){t.useMobileQuestDock=r}),!0}const je="[ServerDrawer]";function ze(e){const t=s.findByProps("getQuestAsset");if(!t?.getQuestAsset)return console.log(je,"WARN: getQuestAsset not found"),!1;const r=t.getQuestAsset;return t.getQuestAsset=function(...i){try{return r.apply(this,i)}catch{return{url:null,isAnimated:!1}}},e.push(function(){t.getQuestAsset=r}),!0}const Ue=s.findByStoreName("GuildStore"),qe=s.findByProps("colors","unsafe_rawColors")?.colors;function le({id:e,size:t=48}){const r=Ue?.getGuild(e);if(!r)return null;const i=t>=40?16:8;return r.icon?n.createElement(o.Image,{source:{uri:`https://cdn.discordapp.com/icons/${r.id}/${r.icon}.png?size=${t*2}`},style:{width:t,height:t,borderRadius:i}}):n.createElement(o.View,{style:[ue.fallback,{width:t,height:t,borderRadius:i,backgroundColor:qe?.BG_ACCENT??"#5865f2"}]},n.createElement(o.Text,{style:[ue.letter,{fontSize:Math.max(10,t*.4)}]},r.name?.split(" ").map(function(l){return l[0]}).join("").slice(0,2).toUpperCase()||"?"))}const ue=o.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},letter:{color:"#fff",fontWeight:"700"}}),ae=s.findByProps("TextStyleSheet")?.TextStyleSheet,Je=s.findByStoreName("ThemeStore"),ce=s.findByProps("colors","unsafe_rawColors"),Ke=ce?.internal??ce?.meta,de=s.findByProps("triggerHapticFeedback","HapticFeedbackTypes");function V(e){const t=Je?.theme;return e&&Ke?.resolveSemanticColor(t,e)||"#000000"}const w=12,z=12,fe=42,U=220,pe=4,P=16,Q=20,ge={tension:200,friction:20};function Xe({visible:e,items:t,title:r,anchorX:i,anchorY:l,onClose:c}){const{width:d,height:S}=o.Dimensions.get("window"),C=(r?z+20+pe:0)+t.length*fe;let g=i,f=l+48+10;g+U>d-w&&(g=d-U-w),g<w&&(g=w),f+C>S-w&&(f=l-C-10),f<w&&(f=w);const E=V(F.semanticColors?.BACKGROUND_SURFACE_HIGHEST),u=V(F.semanticColors?.BORDER_SUBTLE),h=V(F.semanticColors?.TEXT_STRONG),te=V(F.semanticColors?.BACKGROUND_MOD_SUBTLE),R=n.useRef(new o.Animated.Value(0)).current,B=n.useRef(new o.Animated.Value(.5)).current,p=n.useRef(new o.Animated.Value(0)).current,[ne,oe]=n.useState(!1),A=n.useRef(!1);n.useEffect(function(){e&&!A.current&&(oe(!0),R.setValue(0),B.setValue(.5),p.setValue(0),o.Animated.parallel([o.Animated.timing(R,{toValue:1,duration:150,useNativeDriver:!0}),o.Animated.spring(B,{toValue:1,useNativeDriver:!0,...ge}),o.Animated.spring(p,{toValue:1,useNativeDriver:!0,...ge})]).start())},[e]);const T=n.useCallback(function(){A.current||(A.current=!0,o.Animated.parallel([o.Animated.timing(R,{toValue:0,duration:120,useNativeDriver:!0}),o.Animated.timing(B,{toValue:.8,duration:120,useNativeDriver:!0}),o.Animated.timing(p,{toValue:0,duration:120,useNativeDriver:!0})]).start(function(){A.current=!1,oe(!1),c()}))},[c]);return ne?n.createElement(o.Modal,{transparent:!0,visible:ne,onRequestClose:T,s