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

[Feature request] Use Font Awesome Duotone Style #8162

Closed
Pandishpan opened this issue Dec 3, 2019 · 12 comments
Closed

[Feature request] Use Font Awesome Duotone Style #8162

Pandishpan opened this issue Dec 3, 2019 · 12 comments

Comments

@Pandishpan
Copy link

Is your feature request related to a problem? Please describe.
Font Awesome recently introduced a new style of their awesome icons, the Duotone one where they use 2 separate glyphs stacked on top of each other to allow you to create some really awesome icons in two tones.

Currently, I can't see a way how you can use it with Nativescript.

Describe the solution you'd like
Would be great to be able to use them and to be able to control the opacity/colour of each layer exactly how you can easily do it on the web.
https://fontawesome.com/how-to-use/on-the-web/styling/duotone-icons

Additional context
https://blog.fontawesome.com/introducing-duotone/

@mehdinourollah
Copy link

Nothing yet ?! I need to use FontAwesome 5 DuoTone class for my fonts but the secondary color and opacity doesn't take effect.

@NathanaelA

This comment was marked as abuse.

@Pandishpan
Copy link
Author

Hi @NathanaelA,

Can you please confirm what version of NativeScript did you use to create that example and in what platform are you running it?

I just tested on Android with Nativescript "version": "6.1.2", and I'm not getting the same behaviour ...

image

Although I'm using the right Unicode for the second glyph I'm always getting the first one. (this is a side-by-side column with glyph1 and glyph2)

image

@NathanaelA

This comment was marked as abuse.

@mehdinourollah
Copy link

mehdinourollah commented Mar 1, 2020 via email

@NathanaelA

This comment was marked as abuse.

@Pandishpan
Copy link
Author

Thank you @NathanaelA for your support to the NS community.
Most of the people who are using NS + Angular and use the nested routing are sticking to 6.1.2 due to a serious BUG which is already reported NativeScript/nativescript-angular#2075

Precisely as you said, it should work fine the example with the fonts. However, the issue that I report it is due to using Angular on top of NS.

Take a look on this playground https://play.nativescript.org/?template=play-ng&id=Ye9ZYD
which is based on Angular, you can experience the same problem.
Here is the version based on TypeScript https://play.nativescript.org/?template=play-tsc&id=GwVNSp this one is working perfectly fine.

Do you have any recommendations?

@NathanaelA

This comment was marked as abuse.

@Pandishpan
Copy link
Author

I expected that you'll say to drop Angular😅 I like your humour @NathanaelA
The workaround looks quite great, futureproof 👍
Thanks again for the explanation lesson, don't forget to update your blog post I'm pretty sure that there are a lot of Angular Devs using NS.

@NathanaelA

This comment was marked as abuse.

@Pandishpan
Copy link
Author

@NathanaelA

Here is the directive that uses your fix in an organised way, according to Angular structure.

You can see an example in use on this playground https://play.nativescript.org/?template=play-ng&id=T3S2hi

import { Directive, ElementRef, OnInit } from "@angular/core";
import { Label } from "ui/label";

@Directive({
    selector: "[labelDuoTone]"
})
export class DuoToneDirective implements OnInit {

    constructor(private el: ElementRef) {
    }

    get nativeView(): Label {
        return this.el.nativeElement;
    }

    ngOnInit() {
        const nativeView = this.nativeView;

        if (nativeView instanceof Label) {
            nativeView.on(Label.loadedEvent, () => {
                let val = nativeView.text.codePointAt(0);
                // Check to see if this is already a valid unicode string above 0xffff.
                // If they fix the underlying issue in the future; we don't need to run the rest of the code...
                if (val > 65535) {
                    return;
                }

                // We found a character we need to change...
                val = val | 0x100000;
                nativeView.text = String.fromCodePoint(val);

            });
        }
    }
}

@NathanaelA

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants