indusbit-test
v1.0.8
Published
Test package for IndusBit
Maintainers
Readme
indusbit-test
A simple React Native package that provides both native module functionality and UI components.
Installation
npm install indusbit-test --saveor
yarn add indusbit-testAndroid
Add the following to your android/settings.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:
dependencies {
// ...
implementation project(':indusbit-test')
}Add the import and link the package in MainApplication.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;
}
}iOS
Using CocoaPods
Add the following line to your Podfile:
pod 'indusbit-test', :path => '../node_modules/indusbit-test'Then run:
pod installUsage
Native Module
You can use the native module in three different ways:
Method 1: Using the default export
import IndusBitTest from "indusbit-test";
// Multiply two numbers
IndusBitTest.multiply(5, 3)
.then((result) => {
console.log(`Result: ${result}`); // 15
})
.catch((error) => {
console.error(error);
});Method 2: Directly importing the multiply method
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);
});Method 3: Using async/await
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);
}
}UI Components
The package also includes ready-to-use React Native UI components:
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}`)}
/>MultiplyButton Props
| 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
