Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add databinding support #20

Closed
jmpaya opened this issue Sep 9, 2020 · 5 comments
Closed

Add databinding support #20

jmpaya opened this issue Sep 9, 2020 · 5 comments

Comments

@jmpaya
Copy link

jmpaya commented Sep 9, 2020

Hi Márton,

First of all congratulations for your library, it is just a masterpiece that can save hundreds of hours to the community.

I'd like to suggest you to support in some way databinding on RainbowCakeFragment. I'm using your library on some projects and I think It could be interesting to support this pattern.

I've solved it doing that on my project:

class MyFragment : RainbowCakeFragment<MyViewState, MyViewModel>() {

    override fun getViewResource() = R.layout.my_fragment

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState) // I'm forced to call super
        binding = MyFragmentListBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun render(viewState: MyViewState) {
        TransitionManager.beginDelayedTransition(listFragmentRoot)
        binding.viewState = viewState
    }
}

As you can see it simplifies a lot the code on the Fragment side, moving the logic to the XML file. Maybe you can find a better way of allowing this on next versions of the library without having to override getViewResource() method.

@zsmb13
Copy link
Member

zsmb13 commented Sep 24, 2020

This is a good point, both ViewBinding and data binding would be interesting things to support. Have to figure out how to do this without breaking the existing APIs too much, or making the XML resource based solution too manual to use.

@jmpaya
Copy link
Author

jmpaya commented Sep 25, 2020

Awesome! 👍

@zsmb13
Copy link
Member

zsmb13 commented Oct 29, 2020

Made this nicer in 1.2.0

@jmpaya
Copy link
Author

jmpaya commented Oct 30, 2020

That's amazing @zsmb13! A million thanks for the update! 🔝

@jmpaya
Copy link
Author

jmpaya commented Oct 30, 2020

It's working fine on 1.2.0. Closing the issue. 😄

@jmpaya jmpaya closed this as completed Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants