@capgo/capacitor-자연 로더를 사용합니다.
@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가 바쁠 때 로딩이 완료되면 WebView를 복원하세요:
await NativeLoader.setWebViewLayout({
mode: 'inset',
insets: { top: 96 },
animated: true,
});
await NativeLoader.show({
style: 'wave',
placement: 'top',
message: 'Syncing changes',
interactionMode: 'passThrough',
});
Chrome-Style 상단 진행
await NativeLoader.hideAll({ restoreWebView: true });
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 });
WebView가 표시되는 동안 화면의 테두리에서 색상을 움직이는 네이티브 전면 로더를 사용하세요.
for siri-v2 for a native full-screen loader that moves color around the screen edge while the WebView remains visible.
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 });
로티 로더
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)
유용한 링크
- GitHub: https://GitHub.com/Cap-go/__CAPGO_KEEP_1__-native-loader/ https://github.com/Cap-go/capacitor-native-loader/
- __CAPGO_KEEP_0__-native-loader를 사용하는 데서 계속 진행하세요.
Keep going from Using @capgo/capacitor-native-loader
__CAPGO_KEEP_0__ capgo/capacitor-native-loader를 사용하여 자연스러운 네이티브 미디어 및 인터페이스 동작을 계획하고 capgo/capacitor-native-loader와 연결합니다. implementation 세부 사항을 참조하세요. Getting Started 설정에 대한 안내 capgo/capacitor-native-navigation을 사용하여 네이티브 크롬 및 WebView 레이아웃을 관리합니다. capgo/capacitor-transitions를 사용하여 WebView 경로 동작을 관리합니다.