UNPKG

react-native-smkit-ui

Version:

React Native library for SMKit UI - Advanced fitness assessments and workout programs with AI-powered motion detection and real-time performance tracking

92 lines (83 loc) 4.56 kB
import { NativeModules, Platform } from 'react-native'; const LINKING_ERROR = `The package 'react-native-smkit-ui' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; // Fix: Use bracket notation to access NativeModules property const SMKitUIManager = NativeModules['SMKitUIManager'] ? NativeModules['SMKitUIManager'] : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); /** * This function will configure the sdk * @param {string} key - your auth key */ export function configure(key) { return SMKitUIManager.configure(key); } /** * start an assessment session. * * @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start. * @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion. * @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided. * @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided. * @param {string} customAssessmentID - A unique identifier for a custom assessment session. * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished. */ export function startAssessment(type, showSummary = true, userData, forceShowUserDataScreen = false, customAssessmentID) { return SMKitUIManager.startAssessment(type, showSummary, userData === null || userData === void 0 ? void 0 : userData.toJson(), forceShowUserDataScreen, customAssessmentID); } /** * Starts a custom workout session. * * @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration. * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout session finished. */ export function startCustomWorkout(workout) { return SMKitUIManager.startCustomWorkout(workout.toJson()); } /** * Initiates a custom assessment session. * * @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session. * @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided. * @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided. * @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion. * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished. */ export function startCustomAssessment(assessment, userData, forceShowUserDataScreen = false, showSummary = true) { return SMKitUIManager.startCustomAssessment(assessment.toJson(), userData === null || userData === void 0 ? void 0 : userData.toJson(), forceShowUserDataScreen, showSummary); } /** * Starts a workout program using the provided workout configuration. * * @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program. * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout program finished. */ export function startWorkoutProgram(workoutConfig) { return SMKitUIManager.startWorkoutProgram(workoutConfig.toJson()); } /** * Sets a text language for the current workout session * @param {SMWorkoutLibrary} language - The language that you would like to set. */ export function setSessionLanguage(language) { SMKitUIManager.setSessionLanguage(language); } /** * Sets the closure target for the workout session. * @param {SMWorkoutLibrary.EndExercisePreferences} endExercisePreferences - The closure target to set. */ export function setEndExercisePreferences(endExercisePreferences) { SMKitUIManager.setEndExercisePreferences(endExercisePreferences); } /** * Sets the counter preferences for the workout session. * @param {SMWorkoutLibrary.CounterPreferences} counterPreferences - The counter preferences to set. */ export function setCounterPreferences(counterPreferences) { SMKitUIManager.setCounterPreferences(counterPreferences); } //# sourceMappingURL=index.js.map