Skip to content

Support maxlines #596

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

Merged
merged 15 commits into from
May 3, 2021
Merged

Support maxlines #596

merged 15 commits into from
May 3, 2021

Conversation

nguyenxdat
Copy link

No description provided.

@tneotia
Copy link
Contributor

tneotia commented Apr 1, 2021

We want to support this feature but it is not immediately intuitive how maxLines should work. What if there is an image/video/audio? How would that get treated? How are tables treated? We have a full discussion on the maxLines issue at #29.

@erickok
Copy link
Contributor

erickok commented Apr 1, 2021

Agreed with @tneotia though I have to say supporting maxLines on a style (and for simplistic use-cases therefor supporting maxLines entirely) is quite unobtrusive and effective. I tend to approve the solution for these reasons.

@tneotia
Copy link
Contributor

tneotia commented Apr 26, 2021

@erickok if you want to do something like this then what do you say about adding selectable text? Technically it has the same limitations as this feature - e.g. Flutter cannot handle selectable image/audio/video, tables, etc.

@erickok
Copy link
Contributor

erickok commented Apr 26, 2021

Selectable text is also desirable. Both are the proposed solution in the pr is good for me, as it doesn't claim to limit the output to some number of lines, but directly as text style.

@erickok
Copy link
Contributor

erickok commented Apr 26, 2021

I haven't tested this yet, which is the only reason I didn't yet merge.

lib/style.dart Outdated
///
///
///
int? maxLine;

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, this should be named maxLines.

Comment on lines 311 to 315
Html(
data: htmlDataLines,
style: {
'html': Style(maxLine: 1, textOverflow: TextOverflow.ellipsis),
},

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes the example code here isn't the best to show of this feature. But I like the implementation itself. @nguyenxdat could you follow @tneotia 's suggestion and update the example app?

Copy link
Contributor

@erickok erickok left a comment

Choose a reason for hiding this comment

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

Please reduce the changes in the example app and rename maxLine to maxLines and we will merge this PR. Thanks agian for the contribution.

Comment on lines 248 to 251
body: SingleChildScrollView(
child: Html(
data: htmlData,
style: {
"table": Style(
backgroundColor: Color.fromARGB(0x50, 0xee, 0xee, 0xee),
),
"tr": Style(
border: Border(bottom: BorderSide(color: Colors.grey)),
),
"th": Style(
padding: EdgeInsets.all(6),
backgroundColor: Colors.grey,
child: Column(
children: [
Html(

This comment was marked as resolved.

Copy link
Contributor

@tneotia tneotia left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks so much for this PR. @erickok this should be ready to go now.

@erickok erickok merged commit c15d499 into Sub6Resources:master May 3, 2021
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.

3 participants