Skip to content

Conversation

erickok
Copy link
Contributor

@erickok erickok commented May 19, 2021

Fixes #565 and #671.

The same approach is used as PR #679 where a new line is inserted (when using shrinkWrap) for block element. The difference is that the insertion is done directly when processing block style elements.

No support for list items when using shrinkWrap, though this can be easily added I think. Tables and text aligning support is untested.

For example, this code:

        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              color: Colors.yellow,
              child: Html(
                data: "<strong>shrinkWrap: </strong> false",
                shrinkWrap: false,
              ),
            ),
            Container(
              color: Colors.orange,
              child: Html(
                data: "<h2>shrinkWrap</h2><p>use <strong>shrinkWrap</strong> to minimize the widget size</p><h2>false</h2>shrinkWrap is NOT enabled here",
                shrinkWrap: false,
              ),
            ),
            Container(
              color: Colors.yellow,
              child: Html(
                data: "<strong>shrinkWrap: </strong> true",
                shrinkWrap: true,
              ),
            ),
            Container(
              color: Colors.orange,
              child: Html(
                data: "<h2>shrinkWrap</h2><p>use <strong>shrinkWrap</strong> to minimize the widget size</p><h2>true</h2>shrinkWrap is enabled here",
                shrinkWrap: true,
              ),
            ),
          ],
        )

Screenshot 2021-05-20 at 00 56 27

There is still a small issue with replaced elements, where a new line should be inserted but it is not. I am debugging that still.

@erickok
Copy link
Contributor Author

erickok commented May 20, 2021

Hmmm actually it is not working for all cases. I need to rethink my solution, based off what @tneotia already has done.

@erickok erickok closed this May 20, 2021
@tneotia
Copy link
Contributor

tneotia commented May 20, 2021

Your solution actually might work... You may also need to add the new lines in the "inline element" parseTree (last return statement).

If you see my PR I use the indices in the block element WidgetSpan and the very last TextSpan in the else condition.

@erickok erickok reopened this May 22, 2021
@erickok
Copy link
Contributor Author

erickok commented May 22, 2021

@tneotia Indeed, nice! I think this works.

Screenshot 2021-05-22 at 23 35 07

Screenshot 2021-05-22 at 23 35 25

@tneotia
Copy link
Contributor

tneotia commented May 22, 2021

Yep looks good, nice work. You do a good job with lists & list manipulation, I've seen in other PRs as well! Much cleaner than what I had.

@erickok
Copy link
Contributor Author

erickok commented May 23, 2021

@ryan-berger Could you review this?

Copy link
Contributor

@ryan-berger ryan-berger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems acceptable to me. Looking at the HTML spec, it seems that this is done anyway.

I'm fine with merging this now as it serves a purpose, but I'm wondering if we could use some sort of Flex class to achieve this functionality as well.

Either way, LGTM

@asmith20002
Copy link

@tneotia @erickok Thank you for the time you put into this. Much appreciated!

@erickok erickok merged commit 2a21971 into Sub6Resources:master May 25, 2021
@erickok
Copy link
Contributor Author

erickok commented May 25, 2021

@ryan-berger Wrap works solely on widgets but we need to be in the 'span world' for our texts, so that won't quite help.

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

Successfully merging this pull request may close these issues.

How to make the width and height of the parent component follow the space occupied by the Html component display content

4 participants