-
-
Notifications
You must be signed in to change notification settings - Fork 193
feat: Add text shadow persistence in state history export/import #733
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
Conversation
Removed hardcoded height: 0.0 from the editable TextField's style. This preserves the original height from the TextStyle, ensuring proper alignment between the editable text and its rounded background. Previously, the forced height: 0.0 caused misalignment with fonts that have custom line heights (e.g., Persian/Arabic fonts), resulting in the background not properly fitting the text during editing.
- Added 'shadow': 'sh' to minified keys for compact JSON export
- Added shadow parsing in TextLayer.fromMap() to restore shadow on import
- Added shadow serialization in TextLayer.toMap() and toMapFromReference()
Shadow format in JSON:
{
"shadow": {
"color": <int>,
"blurRadius": <double>,
"offsetX": <double>,
"offsetY": <double>
}
}
This is backward compatible - projects without shadow will continue to work.
- Remove shadows: [] override in text_editor_input.dart that was clearing shadows - Add finalStyle logic in layer_widget_text_item.dart to properly merge textStyle including shadows
hm21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @faizahmaddae,
Thanks for creating the PR, that’s definitely a cool feature! I took a quick look and made just a few small changes locally but can’t push the commit to this PR, since it looks like maintainers are blocked from editing it. Here’s what I changed, feel free to either update the PR settings so I can push directly, or fix the points below yourself (would be much appreciated) what i do locally already:
- I noticed that when exporting a layer in
toMap, it currently uses only the first shadow in the list. I updated it so we export the full list of shadows instead. - I also saw you removed the hardcoded
height: 0.0from the textfield style. That value is actually important, since we had issues on various platforms where the text wasn’t perfectly centered without it. I’ve now added atextHeightoption to theTextEditorStyle, so you can set it to null or any other value you prefer.
Let me know if that works for you, once you're good with it, I’ll go ahead and merge it :)
|
Hi @hm21 Thanks for the feedback! I've pushed a commit with the following changes: ✅ Shadow export now uses the full list instead of just the first shadow |
hm21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking it out so quickly. I just had a look but didn’t see any new commits here. What I did notice, though, is that in your other PR #732, the changes seem to be mixed, it includes both the fix and the updates for that PR.
However I do now a full review here, and added a few suggestions that you can apply directly if you agree with them.
As for PR #732, I’m not entirely sure what the exact fix is at the moment since it’s currently mixed with the code from this PR. I’m totally fine if you want to apply the changes here instead, or you can clean up PR #732 so it only includes the relevant fix. Totally up to you what you prefer :)
lib/features/text_editor/widgets/rounded_background_text/rounded_background_text_field.dart
Outdated
Show resolved
Hide resolved
- Simplify shadow parsing using safeParseInt/safeParseDouble - Use 'shadows' (plural) key instead of 'shadow' for list export - Export full shadows list in both toMap and toMapFromReference - Add fontWeight and shadows to layer_widget_text_item - Use textHeight config in TextField style
|
Hi @hm21, Thanks for the detailed review! I've applied all your suggestions:
I've also closed PR #732 since all changes are now consolidated here with the proper implementation. Let me know if anything else needs adjustment! |
hm21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for fixing everything so quickly. I'll merge it now and create a new release :)
Summary
This PR adds support for persisting text shadow properties when exporting and importing state history.
Problem
When a user adds a shadow to a text layer and saves the project, the shadow is lost when reopening the project because the shadow property was not being serialized/deserialized in the export/import flow.
Changes
'shadow': 'sh'tokMinifiedLayerKeysfor compact JSON exportTextLayer.fromMap()to restore shadow on importTextLayer.toMap()andtoMapFromReference()to export shadowShadow format in JSON
{ "shadow": { "color": 3019893248, "blurRadius": 4.0, "offsetX": 2.0, "offsetY": 2.0 } }Backward Compatibility
This change is fully backward compatible:
Testing