UNPKG

@revrag-ai/embed-react-native

Version:

A powerful React Native library for integrating AI-powered voice agents into mobile applications. Features real-time voice communication, intelligent speech processing, customizable UI components, and comprehensive event handling for building conversation

80 lines (67 loc) 2.16 kB
"use strict"; /** * @file EmbedButton.helpers.ts * @description Helper functions and utilities for the EmbedButton component */ import { Dimensions } from 'react-native'; // ==================== CONSTANTS ==================== export const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window'); export const BUTTON_DIMENSIONS = { WIDTH: 60, HEIGHT: 60, EXPANDED_WIDTH: SCREEN_WIDTH * 0.9 }; export const ICON_URLS = { MIC_ON: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/Mute+button.png', MIC_OFF: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/unmute.png', END_CALL: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/end+button.png', AMPLIFY_ANIMATION: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/amplify.json' }; export const DEFAULT_GRADIENT_COLORS = ['#1E0844', '#B391F3']; export const DEFAULT_POPUP_DELAY_MS = 15000; // ==================== TYPES ==================== // ==================== HELPER FUNCTIONS ==================== /** * Safely parse delay value to ensure it's a valid number */ export const parseDelayMs = delay => { if (typeof delay === 'number') { return delay; } const parsed = Number(delay); return Number.isFinite(parsed) ? parsed : DEFAULT_POPUP_DELAY_MS; }; /** * Format seconds to MM:SS format */ export const formatDuration = seconds => { const minutes = Math.floor(seconds / 60); const remainingSeconds = seconds % 60; return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`; }; /** * Calculate the max X position for button drag constraints */ export const calculateMaxX = isOpen => { 'worklet'; const width = isOpen ? BUTTON_DIMENSIONS.EXPANDED_WIDTH : BUTTON_DIMENSIONS.WIDTH; return SCREEN_WIDTH - width - 35; }; /** * Calculate the max Y position for button drag constraints */ export const calculateMaxY = () => { 'worklet'; return SCREEN_HEIGHT - 150; }; /** * Clamp a value between a min and max */ export const clamp = (value, min, max) => { 'worklet'; return Math.min(Math.max(value, min), max); }; //# sourceMappingURL=EmbedButton.helpers.js.map