Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ionic-team/capacitor-docs
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/main/ios/custom-code.md
#	docs/main/ios/viewcontroller.md
  • Loading branch information
rdlabo committed May 6, 2024
2 parents 49b7280 + d8651c9 commit 7167f93
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 18 deletions.
161 changes: 161 additions & 0 deletions docs/apis/barcode-scanner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
title: Barcode Scanner Capacitor Plugin API
description: Capacitor plugin using Outsystems Barcode libs
custom_edit_url: https://github.com/ionic-team/capacitor-barcode-scanner/blob/main/README.md
editApiUrl: https://github.com/ionic-team/capacitor-barcode-scanner/blob/main/plugin/src/definitions.ts
sidebar_label: Barcode Scanner
---

# @capacitor/barcode-scanner

Capacitor plugin using Outsystems Barcode libs

## Install

```bash
npm install @capacitor/barcode-scanner
npx cap sync
```

#### Android

You will need to modify the `allprojects > repositories` section in your `android/build.gradle` file to include the Outsystems repository. Your `android/build.gradle` file should look similar to this after adding the repository.

```gradle
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://pkgs.dev.azure.com/OutSystemsRD/9e79bc5b-69b2-4476-9ca5-d67594972a52/_packaging/PublicArtifactRepository/maven/v1'
name 'Azure'
credentials {
username = "optional"
password = ""
}
content {
includeGroup "com.github.outsystems"
}
}
}
}
```

---

## API

<docgen-index>

* [`scanBarcode(...)`](#scanbarcode)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

Interface defining the contract for a plugin capable of scanning barcodes.
Requires implementation of the scanBarcode method, which initiates a barcode scan with given options.

### scanBarcode(...)

```typescript
scanBarcode(options: CapacitorBarcodeScannerOptions) => Promise<CapacitorBarcodeScannerScanResult>
```

| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#capacitorbarcodescanneroptions">CapacitorBarcodeScannerOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#capacitorbarcodescannerscanresult">CapacitorBarcodeScannerScanResult</a>&gt;</code>

--------------------


### Type Aliases


#### CapacitorBarcodeScannerScanResult

Defines the structure of the result returned from a barcode scan.

<code>{ ScanResult: string }</code>


#### CapacitorBarcodeScannerOptions

Defines the options for configuring a barcode scan.

<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>


#### CapacitorBarcodeScannerTypeHint

Extends supported formats from Html5Qrcode with a special 'ALL' option,
indicating support for all barcode types.
Type definition combining <a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> and OSBarcodeTypeHintALLOption
to represent the hint for the type of barcode to be scanned.

<code><a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> | <a href="#capacitorbarcodescannertypehintalloption">CapacitorBarcodeScannerTypeHintALLOption</a></code>


### Enums


#### Html5QrcodeSupportedFormats

| Members | Value |
| ----------------------- | --------------- |
| **`QR_CODE`** | <code>0</code> |
| **`AZTEC`** | <code>1</code> |
| **`CODABAR`** | <code>2</code> |
| **`CODE_39`** | <code>3</code> |
| **`CODE_93`** | <code>4</code> |
| **`CODE_128`** | <code>5</code> |
| **`DATA_MATRIX`** | <code>6</code> |
| **`MAXICODE`** | <code>7</code> |
| **`ITF`** | <code>8</code> |
| **`EAN_13`** | <code>9</code> |
| **`EAN_8`** | <code>10</code> |
| **`PDF_417`** | <code>11</code> |
| **`RSS_14`** | <code>12</code> |
| **`RSS_EXPANDED`** | <code>13</code> |
| **`UPC_A`** | <code>14</code> |
| **`UPC_E`** | <code>15</code> |
| **`UPC_EAN_EXTENSION`** | <code>16</code> |


#### CapacitorBarcodeScannerTypeHintALLOption

| Members | Value |
| --------- | --------------- |
| **`ALL`** | <code>17</code> |


#### CapacitorBarcodeScannerCameraDirection

| Members | Value |
| ----------- | -------------- |
| **`BACK`** | <code>1</code> |
| **`FRONT`** | <code>2</code> |


#### CapacitorBarcodeScannerScanOrientation

| Members | Value |
| --------------- | -------------- |
| **`PORTRAIT`** | <code>1</code> |
| **`LANDSCAPE`** | <code>2</code> |
| **`ADAPTIVE`** | <code>3</code> |


#### CapacitorBarcodeScannerAndroidScanningLibrary

| Members | Value |
| ----------- | -------------------- |
| **`ZXING`** | <code>'zxing'</code> |
| **`MLKIT`** | <code>'mlkit'</code> |

</docgen-api>
30 changes: 14 additions & 16 deletions docs/main/ios/custom-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ JavaScript とネイティブ コード間の通信を行う最も簡単な方
import Capacitor

@objc(EchoPlugin)
public class EchoPlugin: CAPPlugin {
public class EchoPlugin: CAPPlugin, CAPBridgedPlugin {
public let identifier = "EchoPlugin"
public let jsName = "Echo"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
]

@objc func echo(_ call: CAPPluginCall) {
let value = call.getString("value") ?? ""
call.resolve(["value": value])
Expand All @@ -43,26 +49,18 @@ public class EchoPlugin: CAPPlugin {

CapacitorがSwiftとJavaScriptの間を橋渡しできるように、iOSとWebの両方でカスタムプラグインを登録する必要があります。

#### `EchoPlugin.m` を作成します。

次に、Xcodeで同じようにEchoPlugin.m`ファイルを作成しますが、ウィンドウで**Objective-C**を選択します。File Type****Empty File** のままにしておきます。XcodeからBridging Headerの作成を促されたら、**Create Bridging Header**をクリックします。

> Xcodeを使用してネイティブファイルを作成することは、プロジェクトに適切にリファレンスが追加されるため、推奨されています。
>
> プロジェクトファイルへのこれらの変更は、新しいファイル自体と共にプロジェクトにコミットされるべきです。
#### `MyViewController.swift`

以下の Swift コードを `EchoPlugin.m` にコピーしてください
[カスタム`MyViewController.swift`を作成する](../ios/viewcontroller.md)

```objectivec
#import <Capacitor/Capacitor.h>
次に、`capacitorDidLoad()`メソッドをオーバーライドしてプラグインを登録します:

CAP_PLUGIN(EchoPlugin, "Echo",
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
)
```swift
override open func capacitorDidLoad() {
bridge?.registerPluginInstance(EchoPlugin())
}
```

> これらの Objective-C マクロは、あなたのプラグインを Capacitor に登録し、`EchoPlugin` とその `echo` メソッドを JavaScript から利用できるようにします。EchoPlugin.swift` のメソッドを追加または削除するたびに、このファイルは更新されなければなりません。

#### JavaScript

JavaScript では、`@capacitor/core``registerPlugin()` を使って Swift プラグインにリンクされたオブジェクトを作成します。
Expand Down
2 changes: 1 addition & 1 deletion docs/main/ios/viewcontroller.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Capacitor 3.0 では、アプリケーション内で `CAPBridgeViewController`

## サブクラスを作成する場合

サブクラス化が必要になる例としては、実行時に Capacitor の設定値をオーバーライドしたり、 [`WKWebViewConfiguration`](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration) のプロパティを変更したり、Capacitor が使用するために [`WKWebView`](https://developer.apple.com/documentation/webkit/wkwebview) のカスタムサブクラスをサブクラス化したり、 [`viewDidLoad()`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621495-viewdidload) にコードを追加することを提案するサードパーティの SDK を統合したり、画面に表示される前のネイティブビューを操作したりする場合があります
サブクラス化が必要になる例としては、実行時にCapacitorの設定値をオーバーライドしたり、[`WKWebViewConfiguration`](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration)のプロパティをしたり、[`WKWebView`](https://developer.apple. com/documentation/webkit/wkwebview))を使用したり、[`viewDidLoad()`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621495-viewdidload)にコードを追加することを提案するサードパーティSDKを統合する、画面に表示される前にネイティブビューを操作する、または [カスタムプラグインを登録する](../ios/custom-code.md) 場合があります

カスタムサブクラスを作成する必要がある場合は、いくつかの手順があります。

Expand Down
8 changes: 8 additions & 0 deletions scripts/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const pluginApis = [
'https://github.com/ionic-team/capacitor-background-runner/blob/main/packages/capacitor-plugin/src/definitions.ts',
tag: 'latest',
},
{
id: 'barcode-scanner',
isCore: false,
isExperimental: false,
npmScope: '@capacitor',
editUrl: 'https://github.com/ionic-team/capacitor-barcode-scanner/blob/main/plugin/README.md',
editApiUrl: 'https://github.com/ionic-team/capacitor-barcode-scanner/blob/main/plugin/src/definitions.ts',
},
{
id: 'browser',
isCore: false,
Expand Down
3 changes: 2 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"redirects": [
{ "source": "/", "destination": "/docs" },
{ "source": "/docs/apis/storage", "destination": "/docs/apis/preferences" },
{ "source": "/docs/cli/commands/list", "destination": "/docs/cli/commands/ls" }
{ "source": "/docs/cli/commands/list", "destination": "/docs/cli/commands/ls" },
{ "source": "/docs/next/:match*", "destination": "/docs/:match*" }
],
"rewrites": [
{ "source": "/docs", "destination": "/" },
Expand Down

0 comments on commit 7167f93

Please sign in to comment.