Primeros pasos
Copia un prompt de configuración con los pasos de instalación y la guía completa en markdown para este plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-native-loader`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/native-loader/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Instalación
Sección titulada “Instalación”Puedes usar nuestro setup asistido por IA para instalar el plugin. Añade las skills de Capgo a tu herramienta de IA con el siguiente comando:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLuego usa el siguiente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-native-loader` plugin in my project.Si prefieres la configuración manual, instala el plugin ejecutando estos comandos y sigue las instrucciones de cada plataforma:
-
Instala el paquete
Ventana de terminal bun add @capgo/capacitor-native-loaderbunx cap sync -
Muestra un loader nativo desde JavaScript
import { NativeLoader } from '@capgo/capacitor-native-loader';const { id } = await NativeLoader.show({style: 'siri',placement: 'fullscreen',message: 'Preparing workspace',colors: ['#71f6ff', '#8b5cf6', '#ff4ecd', '#fff7ad'],scrimColor: 'rgba(3, 7, 18, 0.42)',interactionMode: 'block',});await doExpensiveWork();await NativeLoader.hide({ id });
Inicio rápido
Sección titulada “Inicio rápido”import { NativeLoader } from '@capgo/capacitor-native-loader';
await NativeLoader.configure({ defaults: {} });Ejemplo: mostrar
Sección titulada “Ejemplo: mostrar”import { NativeLoader } from '@capgo/capacitor-native-loader';
const result = await NativeLoader.show();console.log(result);Ejemplo: actualizar
Sección titulada “Ejemplo: actualizar”import { NativeLoader } from '@capgo/capacitor-native-loader';
await NativeLoader.update({ id: 'id-123' });Errores comunes
Sección titulada “Errores comunes”- Inicializa una vez: ejecuta setup durante el bootstrap de la app.
- Sync nativo: ejecuta
bunx cap synctras actualizar los plugins. - Fuente de verdad: confianza
src/definitions.tsen el repo de GitHub.
Configurar valores por defecto
Sección titulada “Configurar valores por defecto”await NativeLoader.configure({ defaults: { style: 'orbit', placement: 'center', size: 96, colors: ['#38bdf8', '#a78bfa'], reducedMotion: 'system', interactionMode: 'passThrough', },});Loader superior estilo Chrome
Sección titulada “Cargador superior estilo Chrome”Usa style: 'chrome' cuando se desea la barra de progreso superior familiar del navegador y el WebView debe permanecer utilizable debajo de ella.
const { id } = await NativeLoader.show({ style: 'chrome', placement: 'top', colors: ['#4285f4', '#34a853', '#fbbc05', '#ea4335'], thickness: 4, interactionMode: 'passThrough', webView: { mode: 'resize', insets: { top: 12 }, restoreOnHide: true, },});
await NativeLoader.hide({ id, restoreWebView: true });Cargador de borde Siri V2
Sección titulada “Cargador de borde Siri V2”Usa style: 'siri-v2' cuando el estado de carga debe ser un movimiento de color nativo a pantalla completa alrededor del borde de la app, en lugar de una tarjeta centrada.
const { id } = await NativeLoader.show({ style: 'siri-v2', placement: 'fullscreen', colors: ['#71f6ff', '#8b5cf6', '#ff4ecd', '#fff7ad'], thickness: 10, scrimColor: 'rgba(3, 7, 18, 0.10)', interactionMode: 'passThrough',});
await NativeLoader.hide({ id });Progreso de la actualización
Sección titulada “Progreso de la actualización”const { id } = await NativeLoader.show({ style: 'ring', message: 'Uploading', progress: 0,});
for await (const progress of uploadFile(file)) { await NativeLoader.setProgress({ id, progress });}
await NativeLoader.hide({ id });Redimensionar el WebView
Sección titulada “Redimensionar el WebView”Usa setWebViewLayout cuando un native loader debe ocupar parte de la pantalla mientras el contenido web sigue siendo visible y utilizable.
await NativeLoader.setWebViewLayout({ mode: 'inset', insets: { top: 96, bottom: 24 }, animated: true,});
await NativeLoader.show({ style: 'wave', placement: 'top', size: 72, message: 'Syncing', interactionMode: 'passThrough',});Restaura el diseño original cuando la superficie nativa desaparezca:
await NativeLoader.hideAll({ restoreWebView: true });Loaders de Lottie e imágenes
Sección titulada “Loaders de Lottie e imágenes”Incluye los assets Lottie JSON o de imágenes en la app nativa y refiérete a ellos desde JavaScript.
await NativeLoader.show({ style: 'lottie', placement: 'center', asset: { type: 'lottie', source: 'rocket-loader.json', loop: true, },});await NativeLoader.show({ style: 'image', placement: 'bottom', asset: { type: 'image', source: 'loader-frame', },});Llamadas nativas en Swift
Sección titulada “Llamadas nativas en Swift”Otros plugins de iOS pueden llamar directamente al cargador compartido.
import CapgoCapacitorNativeLoader
let id = NativeLoader.shared.show(options: [ "style": "siri", "placement": "fullscreen", "message": "Opening secure session", "interactionMode": "block"])
NativeLoader.shared.setProgress(id: id, progress: 0.6)NativeLoader.shared.hide(id: id)Llamadas nativas en Kotlin
Sección titulada “Llamadas nativas en Kotlin”Otros plugins de Android pueden llamar al objeto público desde Kotlin o Java.
import app.capgo.nativeloader.NativeLoader
val id = NativeLoader.show( activity = activity, options = mapOf( "style" to "orbit", "placement" to "fullscreen", "message" to "Loading profile", "interactionMode" to "block", ), webView = bridge.webView,)
NativeLoader.setProgress(id, 0.6)NativeLoader.hide(id)Opciones comunes
Sección titulada “Opciones comunes”| Opción | Tipo | Descripción |
|---|---|---|
style | 'siri' | 'siri-v2' | 'chrome' | 'orbit' | 'ring' | 'pulse' | 'dots' | 'bars' | 'wave' | 'halo' | 'lottie' | 'image' | Renderer del loader |
placement | 'center' | 'top' | 'bottom' | 'left' | 'right' | 'fullscreen' | 'around' | 'custom' | Posición en la superficie nativa |
interactionMode | 'passThrough' | 'block' | 'loaderOnly' | Manejo táctil |
backgroundColor | string | Color del overlay (con alfa) |
scrimColor | string | Color del scrim (pantalla completa o perimetral) |
colors | string[] | Colores del gradiente del loader |
progress | number | Valor determinado de 0 a 1 |
autoHide | number | Milisegundos antes de ocultar automáticamente |
asset | object | Origen del recurso Lottie o imagen |
Usa reducedMotion: 'system' to respect the user’s platform motion settings.