indusbit-test
Version:
Test package for IndusBit
164 lines (121 loc) • 3.92 kB
Markdown
A simple React Native package that provides both native module functionality and UI components.
```sh
npm install indusbit-test --save
```
or
```sh
yarn add indusbit-test
```
Add the following to your `android/settings.gradle`:
```gradle
include ':indusbit-test'
project(':indusbit-test').projectDir = new File(rootProject.projectDir, '../node_modules/indusbit-test/android')
```
Add the implementation line to the dependencies in `android/app/build.gradle`:
```gradle
dependencies {
// ...
implementation project(':indusbit-test')
}
```
Add the import and link the package in `MainApplication.java`:
```java
import com.indusbit.test.IndusBitTestPackage; // <-- Add this import
public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new IndusBitTestPackage()); // <-- Add this line
return packages;
}
}
```
Add the following line to your `Podfile`:
```ruby
pod 'indusbit-test', :path => '../node_modules/indusbit-test'
```
Then run:
```sh
pod install
```
You can use the native module in three different ways:
```javascript
import IndusBitTest from "indusbit-test";
// Multiply two numbers
IndusBitTest.multiply(5, 3)
.then((result) => {
console.log(`Result: ${result}`); // 15
})
.catch((error) => {
console.error(error);
});
```
```javascript
import { multiply } from "indusbit-test";
// Use the multiply method directly
multiply(5, 3)
.then((result) => {
console.log(`Result: ${result}`); // 15
})
.catch((error) => {
console.error(error);
});
```
```javascript
import { multiply } from "indusbit-test";
async function calculateProduct() {
try {
const result = await multiply(5, 3);
console.log(`Result: ${result}`); // 15
} catch (error) {
console.error(error);
}
}
```
The package also includes ready-to-use React Native UI components:
```javascript
import { Components } from 'indusbit-test';
// In your component:
<Components.Card title="My Card">
<Text>This is a card component</Text>
</Components.Card>
<Components.MultiplyButton
defaultValueA="5"
defaultValueB="3"
title="Calculate"
onResult={(result) => console.log(`The result is ${result}`)}
/>
```
| Prop | Type | Description |
| -------------- | -------- | ---------------------------------- |
| buttonStyle | Object | Custom styles for the button |
| textStyle | Object | Custom styles for the button text |
| resultStyle | Object | Custom styles for the result text |
| containerStyle | Object | Custom styles for the container |
| title | String | Button text (default: "Multiply") |
| defaultValueA | String | Default value for the first input |
| defaultValueB | String | Default value for the second input |
| onResult | Function | Callback when result is calculated |
#### Card Props
| Prop | Type | Description |
| ------------ | ---------- | ------------------------------------------ |
| title | String | Card title |
| cardStyle | Object | Custom styles for the card |
| titleStyle | Object | Custom styles for the title |
| contentStyle | Object | Custom styles for the content area |
| children | React Node | Child components to render inside the card |
## License
MIT