shiv19 / nativescript-cfalert-dialog

CFAlertDialog Wrapper for NativeScript
Apache License 2.0
42 stars 21 forks source link

Can I render custom elements in the dialog? #24

Closed martinsotirov closed 5 years ago

martinsotirov commented 5 years ago

Hi, I have a quick question – are the dialogs limited to the available form elements (buttons, radio buttons, checkboxes etc.) or can I freely render my own components? Like for example, I'd like to have a pill button, a linear slider etc.

sissingclay commented 5 years ago

Hi,

I can't get this to work.

@ViewChild('switch') stackRef: ElementRef;

    myNativeStack: StackLayout;

    constructor(private _page: Page) {}

    ngAfterViewInit(): void {
        this._page.getViewById(
            'switch'
        );
        this.myNativeStack = this.stackRef.nativeElement;

        const cfalertDialog = new CFAlertDialog();
        cfalertDialog
            .show({
                // Options go here
                dialogStyle:
                    CFAlertStyle.BOTTOM_SHEET,
                headerView: this
                    .myNativeStack
            })
            .then(_ =>
                console.log('test', _)
            )
            .catch(e =>
                console.log('e', e)
            );
    }

This is the error I keep getting. ERROR Error: Cannot convert object to Landroid/view/View; at index 0

shiv19 commented 5 years ago

The header and footer views only support native views. And not nativescript views.

sissingclay commented 5 years ago

@shiv19 could you give me an example of how to achieve this please? Is it possible to do in NativeScript?

shiv19 commented 5 years ago

Please refer #7