-
-
Notifications
You must be signed in to change notification settings - Fork 197
fix(assets): Fix asset genration #3485
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
63109ad
fix(assets): Fix asset generation
rosen-vladimirov 35e2594
chore: Update to latest common lib
rosen-vladimirov c9d4d8f
fix(assets): Improve image definitions for iOS
rosen-vladimirov 920cb8e
chore: fix incorrect assets definitions
rosen-vladimirov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,25 +137,35 @@ export class ProjectDataService implements IProjectDataService { | |
image.path = path.join(dirPath, image.filename); | ||
} | ||
|
||
if (image.size) { | ||
// size is basically <width>x<height> | ||
const [width, height] = image.size.toString().split(AssetConstants.sizeDelimiter); | ||
if (width && height) { | ||
image.width = +width; | ||
image.height = +height; | ||
} | ||
} else { | ||
// Find the image size based on the hardcoded values in the image-definitions.json | ||
_.each(imageDefinitions, (assetSubGroup: IAssetItem[]) => { | ||
_.each(assetSubGroup, assetItem => { | ||
if (assetItem.filename === image.filename && path.basename(assetItem.directory) === path.basename(dirPath)) { | ||
image.width = assetItem.width; | ||
image.height = assetItem.height; | ||
image.size = `${assetItem.width}${AssetConstants.sizeDelimiter}${assetItem.height}`; | ||
// Find the image size based on the hardcoded values in the image-definitions.json | ||
_.each(imageDefinitions, (assetSubGroup: IAssetItem[]) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion (not a merge stopper), not sure if it is working correctly.
|
||
const assetItem = _.find(assetSubGroup, assetElement => | ||
assetElement.filename === image.filename && path.basename(assetElement.directory) === path.basename(dirPath) | ||
); | ||
|
||
if (assetItem) { | ||
if (image.size) { | ||
// size is basically <width>x<height> | ||
const [width, height] = image.size.toString().split(AssetConstants.sizeDelimiter); | ||
if (width && height) { | ||
image.width = +width; | ||
image.height = +height; | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
if (!image.width || !image.height) { | ||
image.width = assetItem.width; | ||
image.height = assetItem.height; | ||
image.size = image.size || `${assetItem.width}${AssetConstants.sizeDelimiter}${assetItem.height}`; | ||
} | ||
|
||
image.resizeOperation = image.resizeOperation || assetItem.resizeOperation; | ||
image.overlayImageScale = image.overlayImageScale || assetItem.overlayImageScale; | ||
image.scale = image.scale || assetItem.scale; | ||
// break each | ||
return false; | ||
} | ||
}); | ||
}); | ||
|
||
return content; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In case when
assetItem.scale
is a number,scale
will always be0.8
andassetItem.scale
will be disregarded. Is it the desired behaviour?If not it should be
let tempScale = assetItem.scale
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 , I've fixed it in the code below