triniwiz / triniwiz/nativescript-plugins

[Accordion][IOS] Plugin doesn't work

Open
#183 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
87
Forks
57
Avg merge
1h 36m
Merged PRs (30d)
4

Description

Hi @triniwiz,

The plugin show this:

The problem come from this line at the init time itemHeaderTemplate is undefined and for that the plugin set the json data to the view instead of the template for that we see [object object]

I tried setTimeOut on the constructor but it doesn't solve it but if I did that it work for the header and need to be set for all templates! :

this._defaultItemHeaderTemplate = {
            key: 'default',
            createView: () => {
                
                return Builder.parse(`<StackLayout id="headerTemplate" backgroundColor="green" >
                <Label text="{{headerText}}"/>
            </StackLayout>`, this);
            }
        };

What can we do on this scenario ?

my code is same as the doc, here it:

<accordion:Accordion height="100%" items="{{items}}" allowMultiple="false" selectedIndexes="{{selectedIndexes}}">

                <accordion:Accordion.headerTemplate>
                    <StackLayout id="headerTemplate" backgroundColor="green" >
                        <Label text="{{headerText}}"/>
                    </StackLayout>
                </accordion:Accordion.headerTemplate>


                <accordion:Accordion.itemHeaderTemplate>
                    <GridLayout backgroundColor="blue">
                    <Label height="100%" text="{{title}}"/>
                    </GridLayout>
                </accordion:Accordion.itemHeaderTemplate>

                <accordion:Accordion.itemContentTemplate>
                    <StackLayout backgroundColor="orange">
                    <Image height="200" decodeWidth="200" decodeHeight="200"  src="{{image}}"/>
                    <Label text="{{text}}"/>
                    </StackLayout>
                </accordion:Accordion.itemContentTemplate>


                <accordion:Accordion.footerTemplate>
                    <StackLayout backgroundColor="yellow">
                    <Label text="{{footerText}}"/>
                    </StackLayout>
                </accordion:Accordion.footerTemplate>
            </accordion:Accordion>

export class HowToViewModel extends Observable {

    selectedIndexes = [0]
    items: ObservableArray<any>

	constructor() {
		super();
        this.items = new ObservableArray([
            {
              title: '1',
              footer: '10',
              headerText: 'First',
              footerText: '4',
              image: 'http://placehold.it/120x120&text=First',
              items: [
                {image: '~/images/a9ff17db85f8136619feb0d5a200c0e4.png', text: 'Stop'},
                {
                  text: 'Drop',
                  image: '~/images/shazam.jpg'
                }]
            },
            {
              title: '2',
              footer: '20',
              headerText: 'Second',
              footerText: '5',
              image: 'http://placehold.it/120x120&text=Second',
              items: [{
                text: 'Drop',
                image: '~/images/batman.jpg'
              }, {text: 'Drop', image: '~/images/f29.png'}]
            },
            {
              title: '3',
              footer: '30',
              headerText: 'Third',
              footerText: '6',
              image: 'http://placehold.it/120x120&text=Third',
              items: [{text: 'Drop', image: '~/images/strider.png'}, {
                text: 'Drop',
                image: '~/images/f29.png'
              }]
            }
          ]);
	}

}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/nativescript-accordion/common.ts at line 129 and reproduce the issue with the XML and ObservableArray example in the report. Trace when itemHeaderTemplate is initialized relative to the template bindings; done means the item header and other templates render their bound views on initialization without requiring setTimeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.