PeterStaev / NativeScript-Grid-View

A NatvieScript GridView widget.
Apache License 2.0
49 stars 28 forks source link

add staggered layout or change layout in runtime #44

Closed racknoris closed 6 years ago

racknoris commented 6 years ago

Is there a way to change the layout to staggered layout in runtime? i'm specifically interested in iOS. If not, how do i change and recompile the package? I saw that when i tns plugin add this plugin, i only get js files in the node_modules folder

PeterStaev commented 6 years ago

Hey @racknoris , the plugin currently does not support a staggered layout. I think adding #31 will give you ability to create such a layout, but I do not have any ETA for that.

If you want to play with the code, you should clone this repo and then make the changes and build the JS files from TS using grunt build command in the cloned folder. The output will be in the bin/dist folder.

racknoris commented 6 years ago

@PeterStaev Great! and after the grunt build, how do I use this in my project? Just place it in the node_modules locally? Or perhaps you could please point me in the right direction for instructions?

By the way, assuming i will modify the code, would it be possible to use it in my application when i upload it to the app store? Perhaps some signature issues of some sorts because it's "unofficial" as yours

Also, I've got to say, your implementation of UICollectionView for nativescript is a life saviour for me and my project. It works far better than RadListView

PeterStaev commented 6 years ago

Usually what is run npm pack in the bin/dist folder. This will create a .gz file for the plugin. Then you can create a _packages folder in the root of your app and copy it there. You can also add it to source control. Then simply run npm install --save ./_packages/nativescript-grid-view.gz as this will install your local plugin instead of the one in npm .

racknoris commented 6 years ago

After copying the .gz file to the _packages folder- will it be available for me straight away in NativeScript such as your plugin?

PeterStaev commented 6 years ago

You need to run npm install like I wrote above, after which it should be available.

racknoris commented 6 years ago

Oh i see. Thank you!

racknoris commented 6 years ago

Did some digging and learned a bit about plugins: would it be theoretically possible to use the pod from here as a UICollectionViewFlowLayout in your plugin?

PeterStaev commented 6 years ago

It should be possible but you have to probably tweak few spots here and there where I rely that the layout is exactly the flow layout.

racknoris commented 6 years ago

A tweak I can see is instead of: _layout = UICollectionViewFlowLayout.alloc().init(); I would initiate an instance of one of those layouts, but i guess there's a lot more to it, so i'll dig in

Also, in the plugin it's written that I have to implement "ContentDynamicLayoutDelegate protocol"

public protocol ContentDynamicLayoutDelegate: class {
    func cellSize(indexPath: IndexPath) -> CGSize
}

func cellSize(indexPath: IndexPath) -> CGSize {
    return cellsSizes[indexPath.row]
}

Is that possible in typescript?

racknoris commented 6 years ago

Actually, I think it would be simpler to just add custom flow layout code to your list

PeterStaev commented 6 years ago

Completely custom flow layout I dont think will be on my list, since every layout has different specifics, not to mention that the same layout will have to be replicated for android to keep plugin compatibility.

The only thing i'm considering to add is the rowSpan and colSpan properties mentioned above. But do not have ETA for those as well.

racknoris commented 6 years ago

Ok I understand, what I meant was that i'll experiment with that, sorry for the misunderstanding