Florian

    Florian

    1 year ago
    how could I draw only the parts of the text that are on top of the darker, filled background in white and the rest in black?
    Colton Idle

    Colton Idle

    1 year ago
    Someone had this question before (it was a progress bar filling up from the bottom of the screen and the numbers were in the middle) and it was like months ago... but I can't find it. 😭
    l

    Luis

    1 year ago
    I would draw the text twice on top of each other, and have a clipshape that clips the top text based on how much progress you have
    Florian

    Florian

    1 year ago
    Thank you @Colton Idle I'll read that
    @Luis if that works it's pretty smart
    Anastasia Rozovskaya

    Anastasia Rozovskaya

    1 year ago
    I suppose you can couple usage of
    AnnotatedString
    with your progress bar, coloring text depending on the progress made. I didn’t test it, but this sounds like a possible solution
    Florian

    Florian

    1 year ago
    @Anastasia Rozovskaya Thank you. I don't know how good that will work with localized strings tho
    @Luis can you point me to the method I have to use to clip the text depending on the progress?
    l

    Luis

    1 year ago
    there is a
    clip()
    modifier that takes a Shape
    You could create a custom Rectable Shape that is based on a percentage, and draws an outline based on that
    The
    RectangleShape
    source just draws a rectangle outline, but you can create one that outlines based on a percentage of width (or height)
    Florian

    Florian

    1 year ago
    ok, thank you very much!
    @Luis you're a genius 🙂
    l

    Luis

    1 year ago
    Glad you got it working!