Creating a new plugin which uses a template


#1

Hi,

I’m trying to create a plugin which wraps the scanbot sdk. I have created a plugin with a template and within this template I am using scanbot’s camera view component

<GridLayout rows="auto" columns="auto">
    <net.doo.snap.camera.ScanbotCameraView id="cameraView" row="0" col="0" />
    <Button id="but" text="Button" row="1" col="0"></Button>

</GridLayout>

In my code however I cannot seem to get an instance of my cameraView component - I added a button to test and the button works fine

    const innerComponent = builder.load(__dirname + '/barcode-scanner.xml') as View;
    innerComponent.bindingContext = this;

    this.addChild(innerComponent);
    console.log(innerComponent);
    const cameraView = innerComponent.getViewById('cameraView');
    console.log(cameraView); // this is undefined
    
    const button = innerComponent.getViewById('but');

    button.on(buttonModule.Button.tapEvent, function (args: observable.EventData) {
      console.log(args.eventName);
    });

    console.log(button);

    console.log('init');

The library is included as I can inittialize the sdk fine.


#2

For anyone else interested, this is the wrong way to go about it.

Apparently you can create a programmatic view and then add an instance of ScanbotCameraView to it.