Skip to content

Conversation

@peoxnen
Copy link
Contributor

@peoxnen peoxnen commented Nov 5, 2017

Hello,

If you allow to change Countainer for forms you can change LinearLayout to FlexboxLayout. Its pawerful comibination and you can build dynamic dialog with many items. You can make specific dialog's layout for tablets. I send u example https://ibb.co/ks8rnb. With this change your library would be more elastic and pawerful.

tablet_poziomo_dol_dialogu

In the other way we can change this layout in your library and set default values to present in like LinearLayout but it require add FlexboxLayout https://github.com/google/flexbox-layout (its from Google).

Reargs,
Witold Sieński

@eltos
Copy link
Owner

eltos commented Nov 5, 2017

Hello,

thanks for the suggestion, this looks very interesting.

I am wondering how you are using the FlexboxLayout without changing the underlying layout resource. Could you provide a usage example on this?

Another option I see here is to extend the SimpleFormDialog and overwrite the onCreateContentView method. Any thoughts about this?

Regards

@eltos eltos added this to the v2.3 milestone Nov 5, 2017
@peoxnen
Copy link
Contributor Author

peoxnen commented Nov 5, 2017

I extends SimpleFormDialog and override onCreateContentView like you suggest in Wiki. I think better way is to extends from CustomViewDialog and add this to library. On the other hand we can create decorator.

@Override public View onCreateContentView(Bundle savedInstanceState) { View view = this.inflate(R.layout.dialog_form_flex); FlexboxLayout container = (FlexboxLayout) view.findViewById(R.id.container); setContainer(container); setFields(savedInstanceState); } return view; }

Regards

@eltos
Copy link
Owner

eltos commented Nov 5, 2017

I see.
If we go for your suggestion, i would combine the two methods into one and give it a more meaningful name.
But a decorator or simply a way of setting the layout resource file might also (or in addition) be a good idea.
Please allow some time to give it a more detailed look. Your Ideas are always welcome.

@eltos eltos merged commit 9e2de23 into eltos:master Dec 28, 2017
eltos added a commit that referenced this pull request Dec 28, 2017
…ts into peoxnen-master

Separate method to populate container with form elements
See #17
@eltos
Copy link
Owner

eltos commented Dec 28, 2017

I think the best practice is to extend SimpleFormDialog and overwrite the onCreateContentView-method, as you most likely will have to do additional set-up when using a custom layout resource.

Using the method populateContainer(@NonNull ViewGroup container, @Nullable Bundle savedInstanceState), coding work is limited to a minimum.

Here is an example on how to use it:

public class FlexboxFormDialog extends SimpleFormDialog {

    public static FlexboxFormDialog build(){
        return new FlexboxFormDialog();
    }


    @Override
    public View onCreateContentView(Bundle savedInstanceState) {

        // inflate custom view
        View view = inflate(R.layout.dialog_form_flex);
        FlexboxLayout container = (FlexboxLayout) view.findViewById(R.id.container);
        
        // TODO: set up flexbox-layout

        populateContainer(container, savedInstanceState);

        return view;
    }

}

@peoxnen
Copy link
Contributor Author

peoxnen commented Dec 28, 2017

It's good idea :) Thx.

@eltos
Copy link
Owner

eltos commented Dec 28, 2017

Linked in Wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants