Skip to content

Conversation

Abdalqader27
Copy link
Contributor

Description

  • Introduced a new SvgImage widget to the Stac framework.
  • Added StacSvgImage model with support for asset, network, file, memory, and string sources.
  • Implemented StacSvgImageParser to parse JSON and render SvgPicture widgets.
  • Added StacColorFilter model for applying color filters to SVGs.
  • Introduced StacBytes class for handling byte arrays with Base64 encoding/decoding.
  • Updated pubspec.yaml to include flutter_svg dependency.
  • Registered StacSvgImageParser in the Stac framework.
  • Added svgImage to WidgetType enum.

Examples

  1. SVG Asset with colorFilter
{
  "type": "svgImage",
  "subtype": "asset",
  "asset": "assets/icons/sample.svg",
  "width": 100,
  "height": 100,
  "semanticsLabel": "Sample SVG Asset",
  "matchTextDirection": true,
  "colorFilter": {
    "filterType": "mode",
    "color": "#FF0000",
    "blendMode": "srcIn"
  }
}

  1. SVG Network with colorFilter
{
  "type": "svgImage",
  "subtype": "network",
  "url": "https://example.com/image.svg",
  "width": 120,
  "height": 120,
  "semanticsLabel": "Network SVG",
  "matchTextDirection": false,
  "colorFilter": {
    "filterType": "mode",
    "color": "#00FF00",
    "blendMode": "multiply"
  }
}
  1. SVG File without colorFilter
{
  "type": "svgImage",
  "subtype": "file",
  "path": "/storage/emulated/0/Download/image.svg",
  "width": 150,
  "height": 150,
  "semanticsLabel": "Local file SVG",
  "matchTextDirection": false
}
  1. SVG Memory with matrix colorFilter
{
  "type": "svgImage",
  "subtype": "memory",
  "bytes": "base64encodeddata==",
  "width": 80,
  "height": 80,
  "semanticsLabel": "Memory SVG",
  "matchTextDirection": false,
  "colorFilter": {
    "filterType": "matrix",
    "matrix": [
      1, 0, 0, 0, 0,
      0, 1, 0, 0, 0,
      0, 0, 1, 0, 0,
      0, 0, 0, 1, 0
    ]
  }
}
  1. SVG String with linearToSrgbGamma colorFilter
{
  "type": "svgImage",
  "subtype": "string",
  "svgString": "<svg>...</svg>",
  "width": 50,
  "height": 50,
  "semanticsLabel": "String SVG",
  "matchTextDirection": true,
  "colorFilter": {
    "filterType": "linearToSrgbGamma"
  }
}

Related Issues

Closes #265

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

@divyanshub024
Copy link
Member

Hey @Abdalqader27, I'm sorry, but we can't merge this PR. @Potatomonsta is already working on it. And we don't want to create a new widget for this. We want to incorporate Svg in the old image PR.

@Abdalqader27
Copy link
Contributor Author

Hey @Abdalqader27, I'm sorry, but we can't merge this PR. @Potatomonsta is already working on it. And we don't want to create a new widget for this. We want to incorporate Svg in the old image PR.

Hey @divyanshub024 There isn’t clear documentation or an assigned owner for this, which is why I proceeded to create it. However, no problem at all.

@divyanshub024
Copy link
Member

Hey @Abdalqader27, sorry it's my bad. I'll make sure there is better documentation around it.

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.

feat: Add support for SVG Images

2 participants