始め方
このプラグインのインストール手順とフルマークダウンガイドを含む設定コマンドをコピーしてください。
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.
インストール
インストールAI-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、AI ツールに Capgo スキルを追加します。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次のプロンプトを使用してください。
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-native-loader` plugin in my project.Manual セットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
-
パッケージのインストール
ターミナル npm install @capgo/capacitor-native-loadernpx cap sync -
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 });
__CAPGO_KEEP_1__
__CAPGO_KEEP_2__await NativeLoader.configure({ defaults: { style: 'orbit', placement: 'center', size: 96, colors: ['#38bdf8', '#a78bfa'], reducedMotion: 'system', interactionMode: 'passThrough', },});__CAPGO_KEEP_3__
__CAPGO_KEEP_4____CAPGO_KEEP_5__ style: 'chrome' __CAPGO_KEEP_6__
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 });__CAPGO_KEEP_7__
__CAPGO_KEEP_8____CAPGO_KEEP_9__ style: 'siri-v2' ロード中の状態がアプリのエッジ周りに動き回る、全画面の色のネイティブの動きで、カードの中心に表示されるのではなく。
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 });進捗状況の更新
「進捗状況の更新」のセクション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 });ウェブビューのサイズを変更
「ウェブビューのサイズを変更」のセクション使用 setWebViewLayout ネイティブのローダーが画面の一部を占めるように表示され、ウェブコンテンツは表示され、使用可能な状態になる。
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',});ネイティブのサーフェイスが消えたときに元のレイアウトを復元する:
await NativeLoader.hideAll({ restoreWebView: true });Lottie と画像ローダー
「Lottie と画像ローダー」Lottie JSON または画像資産をネイティブアプリにパッケージ化し、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', },});ネイティブ Swift の呼び出し
「ネイティブ Swift の呼び出し」他の iOS プラグインは、共有ローダーを直接呼び出すことができます。
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)ネイティブ Kotlin の呼び出し
ネイティブ Kotlin の呼び出し他の Android プラグインは、Kotlin または 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)共通のオプション
共通のオプション| オプション | タイプ | 説明 |
|---|---|---|
style | 'siri' | 'siri-v2' | 'chrome' | 'orbit' | 'ring' | 'pulse' | 'dots' | 'bars' | 'wave' | 'halo' | 'lottie' | 'image' | ローダーレンダラー |
placement | 'center' | 'top' | 'bottom' | 'left' | 'right' | 'fullscreen' | 'around' | 'custom' | ネイティブサーフェースの位置 |
interactionMode | 'passThrough' | 'block' | 'loaderOnly' | タッチハンドリング |
backgroundColor | string | オーバーレイ色(アルファ含む) |
scrimColor | string | フルスクリーンまたは周囲スクリーンシーム色 |
colors | string[] | ローダーグラデーション色 |
progress | number | __CAPGO_KEEP_0__から__CAPGO_KEEP_1__までの値 0 __CAPGO_KEEP_0__から__CAPGO_KEEP_1__までの値 1 |
autoHide | number | __CAPGO_KEEP_0__ミリ秒後自動的に非表示 |
asset | object | Lottieまたは画像アセットのソース |
__CAPGO_KEEP_0__を使用して、ユーザーのプラットフォームのモーション設定を尊重します。 reducedMotion: 'system' エディットページ