fluttercommunity / font_awesome_flutter

The Font Awesome Icon pack available as Flutter Icons
Other
844 stars 244 forks source link

New flutter_font_awesome package :) #174

Closed Mythar closed 3 years ago

Mythar commented 3 years ago

I needed a way to use font awesome web names, so i created this new package, hope you like it.

I only have 1 FaIcon class, it supports all types of icons, both normal and duotone. Also the FaIcon has a child so that you can stack/mix icons to create new icons.

Thanks to @michaelspiss for his great work on font_awesome_flutter :)

This is the first flutter package I have done and its not yet on Pub.dev, as i have no clue of how to do that.

Link: flutter_font_awesome_web_names

michaelspiss commented 3 years ago

Hi, it's awesome to see this package getting adapted for even more projects!

I'd suggest some things if I may:

As you've likely written a custom script to generate the names for you, it'd be awesome if you could share it with others - maybe we could even make it part of the official font_awesome_flutter repository. There are many people who may enjoy this addition, so I'd be more than happy to merge your work into this project.

Mythar commented 3 years ago

Not sure what else to call the package :) I added a remark in the https://github.com/Mythar/flutter_font_awesome/blob/master/lib/flutter_font_awesome.dart to point to you project, if that's sufficient ? Just a note, my package dose not use you package, its standalone. I made a python program to parse the icons names from the metadata icons.json

Mythar commented 3 years ago

Python code:


import json
from pathlib import Path

def generate_for_flutter(icon_json_file):
    file_name_in = Path('metadata/') / icon_json_file

    f = open(file_name_in, "r", encoding='utf-8')
    file_content = f.read()
    file_json = json.loads(file_content)

    for key in file_json:
        data = file_json[key]
        styles = data['styles']

        for style in styles:
            if style == 'solid':
                name = 'fas'
            elif style == 'regular':
                name = 'far'
            elif style == 'light':
                name = 'fal'
            elif style == 'duotone':
                name = 'fad'
            elif style == 'brands':
                name = 'fab'
            else:
                name = ''

            if name != '':
                name += ' fa-' + key.lower()
                unicode = data['unicode']

                source = '"' + name + '": 0x' + unicode.lower() + ','

                print(source)

    f.close()

    print('DONE')

if __name__ == '__main__':
    generate_for_flutter('icons.json')
michaelspiss commented 3 years ago

I'd probably append something like "web names" to the project name. This is just a suggestion and only really of importance should you decide to publish on pub where people could have trouble remembering where the "flutter" part goes to get the correct package.

Thanks for the code - do I have permission to adapt it for flutter once I have time to write the new generator?

Mythar commented 3 years ago

Sure, you can use my code :)

Mythar commented 3 years ago

I changed my package name to: flutter_font_awesome_web_names, hope that's better ? :)

michaelspiss commented 3 years ago

Haha yes, I think so. It was just a suggestion should you wish to upload to pub ;)

Mythar commented 3 years ago

I'm new to this, and i would need some help to upload to pub.. Lets see if anyone likes my new package :)

I changed the readme a bit, larger code sample and a screenshot :)