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

Change generate-class-name for fonts, colors, assets #280

Conversation

Cu-Toof
Copy link
Contributor

@Cu-Toof Cu-Toof commented Aug 15, 2022

Change the class name that will be generated.
Update pubspec.yaml file:

flutter_gen:
  output: lib/gen/

  assets:
    outputs:
      class_name: AppAssets //default is Assets

  fonts:
    outputs:
      class_name: AppFontFamily //default is FontFamily

  colors:
    inputs:
      - assets/colors/colors.xml 
    outputs:
      class_name: AppColor //default is ColorName

@Cu-Toof Cu-Toof force-pushed the feature/change-gen-class-name-for-fonts-colors-assets branch from c2b4c6c to 0e66987 Compare August 15, 2022 14:48
throw const InvalidSettingsException(
'The value of "flutter_gen/colors:" is incorrect.');
}

final buffer = StringBuffer();
final className = genColors.outputs?.className ?? 'FontFamily';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you use FontFamily in color generator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, I have fixed it.

Copy link

@thangnc thangnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, you need to fix unit test @Cu-Toof

pubspecFile,
formatter,
flutterGen.colors,
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think you need to update this call formatter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, I have updated this code.

@thangnc
Copy link

thangnc commented Aug 17, 2022

It seems to be duplicated with this PR #279

@Cu-Toof Cu-Toof force-pushed the feature/change-gen-class-name-for-fonts-colors-assets branch 2 times, most recently from 8c66ee6 to 523b494 Compare August 18, 2022 14:02
@wasabeef wasabeef requested a review from thangnc August 21, 2022 05:44
@Cu-Toof
Copy link
Contributor Author

Cu-Toof commented Aug 21, 2022

@thangnc I have reviewed this PR #279.
I think we can custom more than one output's information. But this pr is implementing output_class is just string type.
Replace it, I implement output as an object, code is scalable with other output's customize like file name, prefix name...

Copy link

@thangnc thangnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cu-Toof please fix my PR's comments. Btw, you did not add unit test?

README.md Outdated
@@ -739,16 +739,25 @@ flutter_gen:
# - snake-case
# - dot-delimiter
style: dot-delimiter
# Optional
outputs:
class_name: Assets
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add the sample class name as MyAssets and add the comment with default value is Assets

README.md Outdated

fonts:
# Optional
enabled: true
# Optional
outputs:
class_name: FontFamily
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment. FontFamily is the default generated class name. You should add the sample class name to make it clear

README.md Outdated

colors:
# Optional
enabled: true
# Optional
inputs: []
# Optional
outputs:
class_name: ColorName
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment. ColorName is the default generated class name

}

String _dotDelimiterStyleAssetsClassDefinition(List<_Statement> statements) {
String _dotDelimiterStyleAssetsClassDefinition(
String? className, List<_Statement> statements) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

String _flatStyleAssetsClassDefinition(List<_Statement> statements) {
String _flatStyleAssetsClassDefinition(
String? className, List<_Statement> statements) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -47,13 +47,19 @@ flutter_gen:
enabled: true
package_parameter_enabled: false
style: dot-delimiter
outputs:
class_name: Assets
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becoz you checked in this line in Asset, so the default config no need outputs.class_name param, right?


colors:
enabled: true
inputs: []
outputs:
class_name: ColorName
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


fonts:
enabled: true
outputs:
class_name: FontFamily
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wasabeef wasabeef added this to the 4.4.0 milestone Aug 21, 2022
@wasabeef
Copy link
Member

I will merge this PR after all fix.

@thangnc I appreciate your help.

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.

3 participants