Skip to main content
플러그인으로 돌아가기
@capgo/capacitor-native-loader
튜토리얼
@capgo/capacitor-native-loader

네이티브 로더

자바스크립트 또는 네이티브 code에서 로딩 상태를 보여주는 애니메이션 로더, 투명 오버레이, Lottie 자산 및 WebView 리사이징 로딩 상태를 표시합니다.

Guide

__CAPGO_KEEP_0__ Native Loader에 대한 튜토리얼

__CAPGO_KEEP_0__ 기기에서 테스트

Capgo 앱을 다운로드한 후 QR code을 스캔하세요.

code Native Loader 플러그인 미리보기 QR

capgo/capacitor-native-loader를 사용하여 @capgo

@capgo/capacitor-native-loader iOS와 Android의 원생 뷰를 통해 로딩 상태를 렌더링합니다. WebView가 바쁠 때 로더가 smooth하게 유지되도록 하거나, transparent fullscreen 효과가 CSS에서 비용이 많이 드는 경우, 또는 JavaScript가 준비되기 전에 다른 원생 플러그인이 로딩 UI를 표시해야 할 때 사용하세요.

설치

npm install @capgo/capacitor-native-loader
npx cap sync

원생 풀스크린 로더

import { NativeLoader } from '@capgo/capacitor-native-loader';

const { id } = await NativeLoader.show({
  style: 'siri',
  placement: 'fullscreen',
  message: 'Preparing your session',
  colors: ['#71f6ff', '#8b5cf6', '#ff4ecd', '#fff7ad'],
  scrimColor: 'rgba(3, 7, 18, 0.42)',
  interactionMode: 'block',
});

await initializeAppData();
await NativeLoader.hide({ id });

WebView 크기 조정을 지원하는 Edge 로더

await NativeLoader.setWebViewLayout({
  mode: 'inset',
  insets: { top: 96 },
  animated: true,
});

await NativeLoader.show({
  style: 'wave',
  placement: 'top',
  message: 'Syncing changes',
  interactionMode: 'passThrough',
});

로딩이 완료되면 WebView를 복원하세요.

await NativeLoader.hideAll({ restoreWebView: true });

Chrome-Style Top Progress

원생 상단 진행 로더를 사용하여 WebView 위에 브라우저와 같은 로딩 바를 표시하고 싶다면 CSS가 중량 작업 중에 애니메이션을 요청하지 않도록 하세요.

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 });

Siri V2 Edge Loader

사용 siri-v2 원생 풀스크린 로더를 사용하여 WebView가 표시되는 동안 화면의 색상이 움직이는 로더를 표시하세요.

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 });

Lottie Loader

await NativeLoader.show({
  style: 'lottie',
  placement: 'center',
  asset: {
    type: 'lottie',
    source: 'loader.json',
    loop: true,
  },
});

시작 로더에 적합한 것은 네트워크 요청과 JavaScript 초기화 전에 사용할 수 있는 패키지된 자산입니다.

자연 플러그인 호출

플러그인은 로더를 직접 표시하거나 숨기기 위해 다른 플러그인이 노출하는 공개 네이티브 API를 노출합니다.

Swift:

import CapgoCapacitorNativeLoader

let id = NativeLoader.shared.show(options: [
  "style": "orbit",
  "placement": "fullscreen",
  "message": "Opening secure session"
])

NativeLoader.shared.hide(id: id)

Kotlin:

import app.capgo.nativeloader.NativeLoader

val id = NativeLoader.show(
  activity = activity,
  options = mapOf(
    "style" to "orbit",
    "placement" to "fullscreen",
    "message" to "Loading profile",
  ),
  webView = bridge.webView,
)

NativeLoader.hide(id)

유용한 링크

Using @capgo/capacitor-native-loader

__CAPGO_KEEP_0__를 사용하여 capgo/capacitor-native-loader를 사용하여 네이티브 미디어 및 인터페이스 동작을 계획하는 경우 네이티브 로더와 연결하세요. @capgo/capacitor-native-loader implementation 세부 사항을 참조하십시오. Getting Started 설치에 대한 정보를 참조하십시오. Using @capgo/capacitor-native-navigation 네이티브 크롬과 WebView 레이아웃을 위한 Using @capgo/capacitor-transitions WebView 경로 동작을 위한