スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
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アシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
bunx 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.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
-
パッケージをインストール
ターミナル bun add @capgo/capacitor-native-loaderbunx 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 });
クイックスタート
「クイックスタート」セクションimport { NativeLoader } from '@capgo/capacitor-native-loader';
await NativeLoader.configure({ defaults: {} });例: 表示
セクション「Example: show」import { NativeLoader } from '@capgo/capacitor-native-loader';
const result = await NativeLoader.show();console.log(result);import { NativeLoader } from '@capgo/capacitor-native-loader';
await NativeLoader.update({ id: 'id-123' });よくある落とし穴
「よくある落とし穴」セクション- 一度だけ初期化: アプリの起動時にセットアップを実行します。
- ネイティブ同期: 実行
bunx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
デフォルトを設定
「デフォルト設定」というセクションawait NativeLoader.configure({ defaults: { style: 'orbit', placement: 'center', size: 96, colors: ['#38bdf8', '#a78bfa'], reducedMotion: 'system', interactionMode: 'passThrough', },});Chrome風トップローダー
「Chromeスタイルのトップローダー」セクション使用する style: 'chrome' ブラウザでおなじみの上部プログレスバーを表示し、その下のWebViewを引き続き操作できるようにしたい場合。
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 エッジローダー
「Siri V2 エッジローダー」セクション使用する 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 });WebViewをリサイズ
「WebViewのリサイズ」セクション使用する setWebViewLayout Webコンテンツを表示・操作可能な状態に保ちつつ、ネイティブローダーが画面の一部を占有すべきケースです。
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', },});Native 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)Native Kotlin呼び出し
「ネイティブ Kotlin 呼び出し」セクション他の Android プラグインは Kotlin または Java から public オブジェクトを呼び出せます。
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' | Loader レンダラー |
placement | 'center' | 'top' | 'bottom' | 'left' | 'right' | 'fullscreen' | 'around' | 'custom' | ネイティブサーフェスの位置 |
interactionMode | 'passThrough' | 'block' | 'loaderOnly' | タッチハンドリング |
backgroundColor | string | オーバーレイの色(アルファ値を含む) |
scrimColor | string | フルスクリーンまたは画面周辺の scrim カラー |
colors | string[] | Loader のグラデーションカラー |
progress | number | Determinate 値の取得元 0 まで 1 |
autoHide | number | 自動で非表示にするまでのミリ秒数 |
asset | object | Lottieまたは画像アセットのソース |
使用する reducedMotion: 'system' ユーザーのプラットフォームのモーション設定を尊重するため。