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

Implement WidgetFactory.buildListMarker #511

Merged
merged 7 commits into from May 11, 2021
Merged

Conversation

daohoangson
Copy link
Owner

Refactor tag_li.dart to make it possible to customize marker widget.

@daohoangson daohoangson temporarily deployed to vercel May 10, 2021 15:44 Inactive
@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

Merging #511 (45d7372) into master (e83dd4d) will increase coverage by 0.16%.
The diff coverage is 97.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #511      +/-   ##
==========================================
+ Coverage   97.75%   97.91%   +0.16%     
==========================================
  Files          46       47       +1     
  Lines        2979     2979              
==========================================
+ Hits         2912     2917       +5     
+ Misses         67       62       -5     
Impacted Files Coverage Δ
...ackages/core/lib/src/widgets/html_list_marker.dart 97.10% <97.10%> (ø)
packages/core/lib/src/core_helpers.dart 100.00% <100.00%> (ø)
packages/core/lib/src/core_widget_factory.dart 99.55% <100.00%> (+0.01%) ⬆️
packages/core/lib/src/internal/ops/tag_li.dart 100.00% <100.00%> (+5.03%) ⬆️
packages/core/lib/src/widgets/css_sizing.dart 94.53% <100.00%> (ø)
packages/core/lib/src/widgets/html_list_item.dart 100.00% <100.00%> (ø)
packages/core/lib/src/widgets/html_table.dart 99.20% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e83dd4d...45d7372. Read the comment docs.

@daohoangson daohoangson temporarily deployed to vercel May 10, 2021 16:04 Inactive
@daohoangson daohoangson temporarily deployed to vercel May 10, 2021 16:56 Inactive
@daohoangson daohoangson temporarily deployed to vercel May 11, 2021 14:30 Inactive
@daohoangson
Copy link
Owner Author

It's now possible to use image as marker:

main.dart
class ImageListMarkerScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: Text('ImageListMarkerScreen'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: HtmlWidget(
            kHtml,
            factoryBuilder: () => _ImageListMarkerFactory(),
          ),
        ),
      );
}

class _ImageListMarkerFactory extends WidgetFactory {
  @override
  Widget buildListMarker(
    BuildMetadata meta,
    TextStyleHtml tsh,
    String listStyleType,
    int index,
  ) {
    if (index == 2) {
      final style = tsh.styleWithHeight;
      return Image.asset(
        'logos/android.png',
        height: style.fontSize,
        width: style.fontSize,
      );
    }

    return super.buildListMarker(meta, tsh, listStyleType, index);
  }
}
const kHtml = '''
<ol style="font-size: larger; line-height: 2">
  <li>One</li>
  <li>Flutter</li>
  <li>Three</li>
</ol>
''';

@daohoangson daohoangson mentioned this pull request May 11, 2021
3 tasks
@daohoangson daohoangson merged commit 0fc7a3d into master May 11, 2021
@daohoangson daohoangson deleted the feat/li_marker_widget branch May 11, 2021 14:43
@daohoangson daohoangson added this to the 0.7.0 milestone Jun 13, 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.

None yet

1 participant