import { HapticTab } from "@/components/haptic-tab"; import { ThemedView } from '@/components/themed-view'; import { useThemeColor } from '@/hooks/use-theme-color'; import { RefObject } from "react"; import { StyleSheet, Text, View } from "react-native"; import { WebView } from "react-native-webview"; import { UNA_URL } from "../constants/settings"; import { Bars, Bell, Chat, Plus, Search, User } from "./icons"; type Props = { webViewRef: RefObject; data: any; }; export default function BottomTabs({ webViewRef, data }: Props) { const iconColor = useThemeColor({}, 'icon'); const runFuncJS = (js: string) => { webViewRef.current?.injectJavaScript(` if (window.${js}) { ${js}(); } true; `); }; const runJS = (js: string) => { webViewRef.current?.injectJavaScript(` ${js}; true; `); }; const renderBadge = (number: number) => { if (number <= 0) return null; return ( {number} ); }; return ( runFuncJS("bx_mobile_apps_show_main_menu")}> runJS(`document.location = "${UNA_URL}/page.php?i=notifications-view"`)}> {renderBadge(data.bubbles?.['notifications-preview'] ?? 0)} runFuncJS("bx_mobile_apps_show_add_menu")}> runFuncJS("bx_mobile_apps_show_messenger_menu")}> {renderBadge(data.bubbles?.['notifications-messenger'] ?? 0)} runJS(`document.location = "${UNA_URL}/searchKeyword.php"`)}> runFuncJS("bx_mobile_apps_show_profile_menu")}> {renderBadge(data.bubbles?.account ?? 0)} ); } const styles = StyleSheet.create({ container: { height: 56, flexDirection: "row", justifyContent: "space-around", alignItems: "center", borderTopWidth: 1, }, tab: { justifyContent: "center", alignItems: "center", position: "relative", }, badge: { position: "absolute", top: -6, right: -10, backgroundColor: "red", borderRadius: 8, minWidth: 16, height: 16, justifyContent: "center", alignItems: "center", paddingHorizontal: 3, }, badgeText: { color: "#fff", fontSize: 10, fontWeight: "bold", }, });