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

feat(project): setting project icon #328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

charles0122
Copy link
Contributor

before:

image

after:

image

links:

#298
#187

@charles0122
Copy link
Contributor Author

What I did was to store the String rawData of the svg format file in hive. I am not sure if it is stored correctly. I saw that what is stored in the project is ProjectRef, not FlutterProject.

@charles0122
Copy link
Contributor Author

And I don't know if @aguilaair has designed a figma drawing, so I didn't pay attention to the UI design of the change icon.

@aguilaair
Copy link
Collaborator

This is great!! I'll review ASAP

Copy link
Collaborator

@aguilaair aguilaair left a comment

Choose a reason for hiding this comment

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

I'd really like for the project icon to be a property in the pubspec of the project instead of contained in sidekick. I think it would be a cleaner way of approaching this. What do you think?

@charles0122
Copy link
Contributor Author

For this idea, the first thing that comes to my mind is to add an attribute called project-icon in pubspec, but I don't know whether this attribute is only for sidekick. In addition, it is also worth discussing what format of icons to store in pubspec, whether it is a network image, svg raw data, or other formats. If the official flutter also has this plan, I think it is feasible. If not, I think we should also implement this function from sidekick.
The inspiration for completing this pr comes from jetBrains. They store icons in svg format in the configuration file generated by IDE, but now we store it in hive. You can also think about whether you can set a directory to access the sidekick configuration, name the folder as .sidekick, etc. This method may be a good choice if you plan to do multi-device synchronization and other network functions in the future.

@charles0122
Copy link
Contributor Author

If you're worried about svg being too big in hive, consider limiting the size, or try optimizing svg tags that won't work with flutter rendering

@aguilaair
Copy link
Collaborator

I'm not worried about the size of the SVG but I like the idea that the icon is automatically detected on any sidekick install. We don't even need our own property and we can take advantage of another very popular package's property in the yaml:

https://pub.dev/packages/flutter_launcher_icons

we can just look for flutter_icons.image_path

@charles0122
Copy link
Contributor Author

This operation looks very good, but it is worth considering that not every flutter project uses this package. What should we do if the project does not use this package?

Also, after a quick look at this package, I think it needs to use image_path in its own project to access the icon. I'm not sure if we can access this icon in this project from sidekick and render it correctly.

As I understand it, the function of this package is that I can use an icon in my Flutter project to automatically generate icons required by other platforms, rather than providing accessible properties for third parties to use.

@charles0122
Copy link
Contributor Author

I think the main problem with this solution is that there is no definite property that allows us to get the location of this icon. Not all Flutter projects will use this package, and the default pubspec will not provide this property.

@charles0122
Copy link
Contributor Author

Maybe we can try this first to see if it works.

@aguilaair
Copy link
Collaborator

Yes, this is not a default property, and we are indeed misusing it because it is not designed to be interacted by other entities. However, if we have permission to see the project we can access the image. We can always have our own property that is used before that:

# Check this first
sidekick:
  banner: some/image/path.png
  icon: some/image/path.png

# Use this as a fallback
flutter_icons:
  image_path: some/image/path.png

@charles0122
Copy link
Contributor Author

Have you tested whether it works?

I still think that adding an attribute for sidekick in the project's pubspec is putting the cart before the horse. When a project that doesn't use sidekick appears, that attribute is redundant. We can't unify this attribute like Flutter does.

@aguilaair
Copy link
Collaborator

That's like saying that the .fvm is redundant when FVM is not installed; it is true, but it also does not change the usefulness of the config—maybe having a .sidekick would be better. I do not want this to be something the one would have to configure on every computer individually.

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.

2 participants