diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
691 stars 206 forks source link

Suggestion: Linear indicator should display only part of linear gradient #31

Closed shaxxx closed 5 years ago

shaxxx commented 5 years ago

I believe current implementation of linear gradient does not fit well with linear percent indicator use case. IMHO indicator should shade only part of linear gradient (according to progress value), not entire gradient. For example bellow I specified linear gradient with 4 colors (red, orange, yellow, green) to create 'VU effect'. Upper progress bar is the way I believe indicator should render gradient, lower one is current behavior. No matter what progress value is set entire gradient is visible.

gradient

It's just a matter of changing shader offset values in 2 places (original code below) https://github.com/diegoveloper/flutter_percent_indicator/blob/afbef0e558d8b6cbfecb45e6d9df7b58d6bbdfda/lib/linear_percent_indicator.dart#L271-L272

https://github.com/diegoveloper/flutter_percent_indicator/blob/afbef0e558d8b6cbfecb45e6d9df7b58d6bbdfda/lib/linear_percent_indicator.dart#L279-L280

I can make a PR but I feel this needs some feedback from you. Can this functionality at least be available as an option? Thanks for the great widget!

diegoveloper commented 5 years ago

I understand, you can send a PR making it customizable ;)

On Sun, Jun 23, 2019, 10:44 AM Shax notifications@github.com wrote:

I believe current implementation of linear gradient does not fit well with linear percent indicator use case. IMHO indicator should shade only part of linear gradient (according to progress value), not entire gradient. For example bellow I specified linear gradient with 4 colors (red, orange, yellow, green) to create 'VU effect'. Upper progress bar is the way I believe indicator should render gradient, lower one is current behavior. No matter what progress value is set entire gradient is visible.

[image: gradient] https://user-images.githubusercontent.com/1778875/59978371-eb536b80-95db-11e9-9cd3-5cd814ad99ad.png

It's just a matter of changing shader offset values in 2 places

https://github.com/diegoveloper/flutter_percent_indicator/blob/afbef0e558d8b6cbfecb45e6d9df7b58d6bbdfda/lib/linear_percent_indicator.dart#L271-L272

https://github.com/diegoveloper/flutter_percent_indicator/blob/afbef0e558d8b6cbfecb45e6d9df7b58d6bbdfda/lib/linear_percent_indicator.dart#L279-L280

I can make a PR but I feel this needs some feedback from you. Can this functionality at least be available as an option? Thanks for the great widget!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/31?email_source=notifications&email_token=ABFL3UAY276VNHUYOJP35L3P36K5PA5CNFSM4H2ZGGK2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3EZBFA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFL3UBOMM42Q6J5XXBKISDP36K5PANCNFSM4H2ZGGKQ .

shaxxx commented 5 years ago

Should both circular and linear indicators have same option?

diegoveloper commented 5 years ago

I think it should be available only for Linear, now we have a bug on the gradient for Circular.

On Sun, Jun 23, 2019, 1:28 PM Shax notifications@github.com wrote:

Should both circular and linear indicators have same option?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/31?email_source=notifications&email_token=ABFL3UAN5UB65ILLHWFXLW3P366FRA5CNFSM4H2ZGGK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLEIEA#issuecomment-504775696, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFL3UBVCJNA6HBDKYJI7DLP366FRANCNFSM4H2ZGGKQ .

diegoveloper commented 5 years ago

done! and published :)

MobileMon commented 4 years ago

Yeah I really need this functionality for the Circular. Any clue how to implement?

shaxxx commented 4 years ago

I had to make kinda 'hackish' solution for myself. You can see it in action HERE or in VIDEO. Source code HERE

Also since then, some new packages became available. Check out THIS one. You can see it in action HERE I've never tried it though.