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

네이티브 로더

JavaScript 또는 네이티브 code에서 로딩 상태, 투명 오버레이, Lottie 자산 및 WebView 리사이징 로딩 상태를 표시합니다.

가이드

자연 로더에 대한 튜토리얼

장치에서 테스트

다운로드한 Capgo 앱을 열고 QR코드 code를 스캔하세요.

Native Loader plugin preview QR code

@capgo/capacitor-native-loader 사용

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

설치

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

Fullscreen Native Loader

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

Edge Loader With WebView Resize

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 로더

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

네트워크 요청과 자바스크립트 초기화 이전에 사용할 수 있기 때문에 시작 로더에 가장 적합한 번들된 자산입니다.

자연 플러그인 호출

다른 플러그인이 로더를 직접 표시하거나 숨길 수 있도록 공개 네이티브 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에서 계속 진행하세요.

Cloudflare Using @capgo/capacitor-native-loader native 앱 미디어 및 인터페이스 동작을 계획하고 연결하기 위해 @capgo/capacitor-native-loader implementation 세부 사항을 참조하세요. Getting Started 설정을 위해 Using @capgo/capacitor-native-navigation native Chrome 및 WebView 레이아웃을 위해 Using @capgo/capacitor-transitions WebView 경로 동작을 위해