コンテンツにスキップ

はじめに

GitHub

CapgoのAI-Assisted Setupを使用してプラグインをインストールできます。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 Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

  1. パッケージをインストールする

    ターミナル画面
    npm install @capgo/capacitor-native-loader
    npx cap sync
  2. 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 });
await NativeLoader.configure({
defaults: {
style: 'orbit',
placement: 'center',
size: 96,
colors: ['#38bdf8', '#a78bfa'],
reducedMotion: 'system',
interactionMode: 'passThrough',
},
});

ブラウザスタイルのトップローダー

「ブラウザスタイルのトップローダー」のセクション

使用する 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 });

使用 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 ネイティブローダーが画面の一部を占有しながら、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 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 Calls

Native Swift Calls

他の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 Calls

Native Kotlin Calls

他の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)

Common Options

Common Options
オプション説明
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'タッチ ハンドリング
backgroundColorstringオーバーレイの色、アルファ含む
scrimColorstringフルスクリーンまたは周囲スクリーン スクリムの色
colorsstring[]ローダーのグラデーション色
progressnumber__CAPGO_KEEP_0__ 0 __CAPGO_KEEP_1__ 1
autoHidenumber__CAPGO_KEEP_2__
assetobjectLottieまたは画像アセットのソース

使用 reducedMotion: 'system' __CAPGO_KEEP_0__をユーザーのプラットフォームの動きの設定を尊重する。