-
-
Notifications
You must be signed in to change notification settings - Fork 197
feat: introduce assets generation #3435
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
10 commits
Select commit
Hold shift + click to select a range
bd1098d
feat: introduce assets generation
ivanovit 6143320
Expose assets-generation-service
ivanovit 9aabb6c
Fixes after review
ivanovit 5493cef
Fix the linter
ivanovit 25f63c3
Add platform parameter
ivanovit 075686c
feat: Introduce methods to get current assets structure
rosen-vladimirov 5a97228
chore: Remove commented code and improve variables names
rosen-vladimirov b5e3bc9
docs: Add help for resources generate commands
rosen-vladimirov d5bfec2
chore: Improve code for getting assets to be generated
rosen-vladimirov dd2c26d
docs: Add new methods to PublicAPI
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
28 changes: 28 additions & 0 deletions
28
docs/man_pages/project/configuration/resources/resources-generate-icons.md
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<% if (isJekyll) { %>--- | ||
title: tns resources generate icons | ||
position: 11 | ||
---<% } %> | ||
# tns resources generate icons | ||
|
||
Usage | Synopsis | ||
------|------- | ||
`$ tns resources generate icons <Path to image>` | Generate all icons for Android and iOS based on the specified image. | ||
|
||
Generates all icons for Android and iOS platforms and places the generated images in the correct directories under `App_Resources/<platform>` directory. | ||
|
||
### Attributes | ||
* `<Path to image>` is a valid path to an image that will be used to generate all icons. | ||
|
||
<% if(isHtml) { %> | ||
### Related Commands | ||
|
||
Command | Description | ||
----------|---------- | ||
[install](../install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory. | ||
[platform add](../platform-add.html) | Configures the current project to target the selected platform. | ||
[platform remove](../platform-remove.html) | Removes the selected platform from the platforms that the project currently targets. | ||
[platform](../platform.html) | Lists all platforms that the project currently targets. | ||
[prepare](../prepare.html) | Copies common and relevant platform-specific content from the app directory to the subdirectory for the selected target platform in the platforms directory. | ||
[resources update](resources-update.md) | Updates the `App_Resources/Android` internal folder structure to conform to that of an Android Studio project. | ||
[resources generate splashes](resources-generate-splashes.md) | Generates splashscreens for Android and iOS. | ||
<% } %> |
29 changes: 29 additions & 0 deletions
29
docs/man_pages/project/configuration/resources/resources-generate-splashes.md
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<% if (isJekyll) { %>--- | ||
title: tns resources generate splashes | ||
position: 12 | ||
---<% } %> | ||
# tns resources generate splashes | ||
|
||
Usage | Synopsis | ||
------|------- | ||
`$ tns resources generate splashes <Path to image> [<background>]` | Generate all splashscreens for Android and iOS based on the specified image. | ||
|
||
Generates all icons for Android and iOS platforms and places the generated images in the correct directories under `App_Resources/<platform>` directory. | ||
|
||
### Attributes | ||
* `<Path to image>` is a valid path to an image that will be used to generate all splashscreens. | ||
* `<background>` is a valid path to an image that will be used as a background of the splashscreen. Defaults to white in case it is not specified. | ||
|
||
<% if(isHtml) { %> | ||
### Related Commands | ||
|
||
Command | Description | ||
----------|---------- | ||
[install](../install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory. | ||
[platform add](../platform-add.html) | Configures the current project to target the selected platform. | ||
[platform remove](../platform-remove.html) | Removes the selected platform from the platforms that the project currently targets. | ||
[platform](../platform.html) | Lists all platforms that the project currently targets. | ||
[prepare](../prepare.html) | Copies common and relevant platform-specific content from the app directory to the subdirectory for the selected target platform in the platforms directory. | ||
[resources update](resources-update.md) | Updates the `App_Resources/Android` internal folder structure to conform to that of an Android Studio project. | ||
[resources generate icons](resources-generate-icons.md) | Generates icons for Android and iOS. | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
export abstract class GenerateCommandBase implements ICommand { | ||
public allowedParameters: ICommandParameter[] = [this.$stringParameterBuilder.createMandatoryParameter("You have to provide path to image to generate other images based on it.")]; | ||
|
||
constructor(protected $options: IOptions, | ||
protected $injector: IInjector, | ||
protected $projectData: IProjectData, | ||
protected $stringParameterBuilder: IStringParameterBuilder, | ||
protected $assetsGenerationService: IAssetsGenerationService) { | ||
this.$projectData.initializeProjectData(); | ||
} | ||
|
||
public async execute(args: string[]): Promise<void> { | ||
const [ imagePath ] = args; | ||
await this.generate(imagePath, this.$options.background); | ||
} | ||
|
||
protected abstract generate(imagePath: string, background?: string): Promise<void>; | ||
} | ||
|
||
export class GenerateIconsCommand extends GenerateCommandBase implements ICommand { | ||
constructor(protected $options: IOptions, | ||
$injector: IInjector, | ||
protected $projectData: IProjectData, | ||
protected $stringParameterBuilder: IStringParameterBuilder, | ||
$assetsGenerationService: IAssetsGenerationService) { | ||
super($options, $injector, $projectData, $stringParameterBuilder, $assetsGenerationService); | ||
} | ||
|
||
protected async generate(imagePath: string, background?: string): Promise<void> { | ||
await this.$assetsGenerationService.generateIcons({ imagePath, projectDir: this.$projectData.projectDir }); | ||
} | ||
} | ||
|
||
$injector.registerCommand("resources|generate|icons", GenerateIconsCommand); | ||
|
||
export class GenerateSplashScreensCommand extends GenerateCommandBase implements ICommand { | ||
constructor(protected $options: IOptions, | ||
$injector: IInjector, | ||
protected $projectData: IProjectData, | ||
protected $stringParameterBuilder: IStringParameterBuilder, | ||
$assetsGenerationService: IAssetsGenerationService) { | ||
super($options, $injector, $projectData, $stringParameterBuilder, $assetsGenerationService); | ||
} | ||
|
||
protected async generate(imagePath: string, background?: string): Promise<void> { | ||
await this.$assetsGenerationService.generateSplashScreens({ imagePath, background, projectDir: this.$projectData.projectDir }); | ||
} | ||
} | ||
|
||
$injector.registerCommand("resources|generate|splashes", GenerateSplashScreensCommand); |
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
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.
The second argument here is unnecessary and could be omitted (I think it would still conform to the signature of the Base command)
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.
I prefer to keep it just to ensure the same signature